bowlib.py

Created by golem64

Created on December 22, 2021

3.01 KB

Mod pour Scoretab : https://my.numworks.com/python/golem64/scoretab

Comptez vos points au bowling avec cette bibliothèque !

Vous ne pouvez pas vous déplacer dans cette bibliothèque, l’ajout de joueurs se fait avec la touche OK et chaque joueur doit entrer 2 valeurs par tour : le 1er et le 2ème tir


from scoretab import *

round=1
shots=0
turn=0
global scores
scores=[]
v=""
while not v: v=input("Joueur 1 > ")
scores.append([v,0,0,0,0,0,0,0,0,0,0])

def move():
  global scores
  global turn
  global shots
  global round
  if turn>len(scores)-1:
    turn=0
    round+=1
    sleep(1)
    draw()
  if turn!=len(scores):
    if round>10: stop=1

def add():
  global shots
  global turn
  global round
  global scores
  if shots:
    if round==11: v=input("3eme tir >")
    else: v=input("2eme tir > ")
    if v:
      if int(scores[turn][round])+int(v)<=10:
        if int(scores[turn][round])+int(v)==10:
          scores[turn][round]="/"
          if round==10:
            scores[turn].append(0)
            round+=1
            shots=1
          elif round==11:
            scores[turn][round]="X"
            if turn==len(scores)-1: round=12
            else: round=10
        else:
          scores[turn][round]=str(int(scores[turn][round])+int(v))
          if round==10 or round==11:
            if turn==len(scores)-1: round=12
            else: round=10
        if round!=11:
          shots=0
          turn+=1
  else:
    e()
    v=input("1er tir > ")
    if v:
      if int(v)==10:
        scores[turn][round]="X"
        if round==10:
          scores[turn].append(0)
          round+=1
          shots=1
        else: turn+=1
      elif int(v)<10 and int(v)>-1:
        scores[turn][round]=v
        shots=1
  draw()

def rem():
  global scores
  if len(scores)!=1:
    v=input("Supprimer joueur... > ")
    if v:
      scores.pop(int(v)-1)
    turn-=1

def edit():
  global scores
  e()
  v=input("Joueur "+str(len(scores)+1)+" > ")
  if v: scores.append([v,0,0,0,0,0,0,0,0,0,0])
  draw()

def draw():
  global scores
  global turn
  global round
  width=68
  height=18
  fill_rect(0,0,320,222,(255,255,255))
  j=-1
  for j in range(len(scores)):
    player=scores[j]
    draw_string((player[0]+" "*8)[0:7],-1,100+(j-turn)*height,(255,255,255),(100,100,100))
    if 1<len(player):
      for i in range(1,len(player)):
        if j-turn==0 and i==round: sel=(255,0,0)
        else: sel=(255,255,255)
        fill_rect(width+20*(i-1)+1,100+(j-turn)*height+1,19,height-1,sel)
        draw_string(str(player[i]),width+20*(i-1)+5,100+(j-turn)*height,(0,0,0),sel)
        fill_rect(width+20*(i),100+(j-turn)*height,1,height,(0,0,0))
      fill_rect(0,100+(j-turn)*height+height,320,1,(0,0,0))
    tot=0
    for i in range(1,len(player)):
      if player[i]=="/": tot+=10
      elif player[i]=="X":
        if i!=11:
          if player[i+1]=="/" or player[i+1]=="X": tot+=20
          else: tot+=10+int(player[i+1])
        else: tot+=10
      else: tot+=int(player[i])
    draw_string((str(tot)+" "*120)[0:int(width/10)],320-31,100+(j-turn)*height,(0,0,0),(200,100,0))
    fill_rect(width+1,100-turn*height,1,height,(0,0,0))
    fill_rect(320-32,100+(j-turn)*height,1,height,(0,0,0))
    fill_rect(0,100+(j-turn)*height,320,1,(0,0,0))
    fill_rect(0,100+(j-turn)*height+height,320,1,(0,0,0))
#deplacement avec haut et bas
#barre de details tout en haut