pok_s.py

Created by pikube

Created on December 12, 2019

3.6 KB

ATTENTION: Ce programme exige toute la mémoire de la calculatrice, et est couplé aux autres scripts commençeant par pok_ (f,c,m, et a). Il requiert OMEGA 1.16.0-0 (allez voir https://github.com/Omega-Numworks/Omega).

Ce script contient le système du jeu (tours, attaques et l’UI).


from pok_f import *
from pok_m import *
from pok_a import *
from kandinsky import *
from pok_c import *

def play():
  reload(),grass()
  draw_pokeball()
  txt("J1, choisissez votre pokemon")
  current_p1=arbor(pokemon1)
  txt("J2, choisissez votre pokemon")
  current_p2=arbor(pokemon2)
  reload()
  players=[menus1,menus2]
  pokemons=[current_p1,current_p2]
  pokedex=[pokemon1,pokemon2]
  turns=0
  #we dont need pv_pn to be accurate so far
  pv_p1=10
  pv_p2=10
  #main loop
  #checks if total status are positive
  #aka all poks are alive
  while pv_p1>0 and pv_p2>0:
    #checks if pok are dead
    if pokemons[turns%2][0].pv<=0:
      grass()
      draw_pokeball()
      txt("%s, votre pokemon est K.O."%(["J1","J2"][turns%2]))
      c=arbor(pokedex[turns%2])
      while c[0].pv<=0:
        txt("ce pokemon est mal en point")
        c=arbor(pokedex[turns%2])
      pokemons[turns%2]=c
      reload()
    if pokemons[(turns+1)%2][0].pv<=0:
      grass()
      draw_pokeball()
      txt("%s, votre pokemon est K.O."%(["J2","J1"][(turns)%2]))
      c=arbor(pokedex[(turns+1)%2])
      while c[0].pv<=0:
        txt("ce pokemon est mal en point")
        c=arbor(pokedex[(turns+1)%2])
      pokemons[(turns+1)%2]=c
      reload()
    grass()
    txt("A vous, J%s"%(turns%2+1))
    pokemons[0][0].render()
    pokemons[1][0].render()
    b_arrow([50,250][turns%2])
    health(100*(pokemons[0][0].pv/pokemons[0][0].pvmax),0,5)
    health(100*(pokemons[1][0].pv/pokemons[1][0].pvmax),220,5)
    #take the choice of the player every turn
    choice=arbor(players[turns%2])
    #every possible scenario      
    if choice[1]=="pokemon":
      while choice[0].pv<=0 or choice[0]==pokemons[(turns%2)][0]:
        if choice[0].pv<=0:
          txt("ce pokemon est mal en point")
          time.sleep(0.8)
        if choice[0]==pokemons[(turns%2)][0]:
          txt("ce pokemon se bat deja")
          time.sleep(0.8)
        #pas possible de revenir au menu 
        choice=arbor(pokedex[turns%2])
      if choice[0].pv>0:
        fill_rect(0,114,320,20,(255,255,255))
        pokemons[(turns%2)]=choice
        reload()
    if choice[1]=="soin":
      if pokemons[turns%2][0].pv+10<=pokemons[turns%2][0].pvmax:
        pokemons[turns%2][0].pv+=10
      txt("soin apportes")
      time.sleep(0.8)
    if choice[1]=="force":
      pokemons[(turns%2)][0].fear*=2
      txt("le pokemon se renforce")
      time.sleep(0.8)
    if choice[1]=="special":
      chance=randint(-5,5)
      pokemons[(turns)%2][0].special()
      pokemons[(turns+1)%2][0].pv-=20*pokemons[(turns)%2][0].fear-chance
      pokemons[(turns+1)%2][0].degat()
      pokemons[turns%2][0].pv-=copysign(1.5*chance,1)
    if choice[1]=="charge":
      pokemons[(turns)%2][0].charge()
      pokemons[(turns+1)%2][0].pv-=10*pokemons[(turns)%2][0].fear
      pokemons[(turns+1)%2][0].degat()
    if choice[1]=="rage":
      pokemons[turns%2][0].rage()
      pokemons[(turns+1)%2][0].fear*=0.5
      txt("le pokemon adverse a peur")
      time.sleep(0.8)
    #increment pv counter
    pv_p1=ispos(pokemon1.func[1].pv)+ispos(pokemon1.func[2].pv)+ispos(pokemon1.func[0].pv)+ispos(pokemon1.func[3].pv)
    pv_p2=ispos(pokemon2.func[0].pv)+ispos(pokemon2.func[1].pv)+ispos(pokemon2.func[2].pv)+ispos(pokemon2.func[3].pv)
    #refresh
    turns+=1
    reload()
  #end the game  
  #full screen grass 
  for loop in range(300):
    fill_rect(randint(0,320),randint(0,222),4,4,(200,200,200))
  #winning screen
  draw_pokedex()
  draw_string("Bravo!",105,47)
  #if player 1 wins  
  if pv_p1<=0:
    draw_string("J2 gagne",105,140)
  #if player 2 wins  
  if pv_p2<=0:
    draw_string("J1 gagne",105,140)
  time.sleep(5000)
play()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.