Partie 2 de MCASE
from mcase1 import * from mcase3 import * from math import * from kandinsky import * from ion import * from time import * from random import * ########################################## def jeu(money,price,inventory,inventoryupgrade,name,paranimation,tempscaisse,page,choixpage,choixvendre,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,pourcentage,choixpourcentage,retour,proba,nom,depense,perdu,gagne): while True: if page==1: sleep(0.1) draw_string("Argent:" + str(money),200,1) draw_string("Stats:",1,1) draw_string("Page 1----",1,200) longueurinv = len(inventory) draw_string("Tu as " + str(longueurinv) + " items.",1,20) fill_rect(1,19,55,1,color(0,0,255)) draw_string("Ton dernier item:",1,40) if longueurinv == 0: draw_string("Pas d'item.",1,60) else: draw_string("[$" + price +"]" + name,1,60) total = 0 for i in inventory: total = total + float(inventory[i]) draw_string("La valeur de ton inventaire :",1,80) draw_string(" ",1,100) draw_string("[$" + str("{:.2f}".format(float(total)))+ "]",1,100) bestItem = "" highestPrice = 0 for i in inventory: if float(highestPrice) < float(inventory[i]): highestPrice = inventory[i] bestItem = i draw_string("Ton meilleur item est:",1,120) if bestItem == "": draw_string("Pas encore d'item.",1,140) else: draw_string("[$" + str(highestPrice) + "]" + str(bestItem),1,140) draw_string("Gagné/Perdu/Dépensé:",1,160) draw_string(str(gagne) + "/" + str(perdu)+ "/" + str(depense),1,180) if keydown(KEY_RIGHT)==True: print(clear()) page=2 ############ if page==2: sleep(0.1) draw_string("Argent:" + str(money),200,1) draw_string(" ",1,1) draw_string("Caisses:",1,1) fill_rect(1,19,75,1,color(0,0,255)) draw_string("1 - Falchion ($1.5):",10,30) draw_string("2 - Bravo ($2.5):",10,50) draw_string("Page -2---",1,200) if keydown(KEY_ONE)==True: print(clear()) caseChoice = 'Falchion' nom = "Falchion" if money - 1.5 >= 0: money = money - 1.5 depense = depense + 1.5 name , price = caisse(caseChoice,tempscaisse,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,inventory,paranimation,nom) else: draw_string("Solde insuffisant",85,100) sleep(2) draw_string(" ",85,100) if keydown(KEY_TWO)==True: print(clear()) caseChoice = 'Bravo' nom = "Bravo" if money - 2.5 >= 0: money = money - 2.5 depense = depense + 2.5 name , price = caisse(caseChoice,tempscaisse,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,inventory,paranimation,nom) else: draw_string("Solde insuffisant",85,100) sleep(2) draw_string(" ",85,100) if keydown(KEY_RIGHT)==True: print(clear()) page=3 if keydown(KEY_LEFT)==True: print(clear()) page=1 ############ if page==3: sleep(0.1) draw_string("Argent:" + str(money),200,1) draw_string(" ",1,1) draw_string("Vendre:",1,1) fill_rect(1,19,65,1,color(0,0,255)) draw_string("(1/4 3/6)Vendre en dessous de:",20,30) draw_string(" ",20,50) draw_string("[$" + str(choixvendre) + "]",20,50) draw_string("[OK] pour valider",20,90) draw_string("Page --3--",1,200) if choixvendre < 0: choixvendre = 0 if keydown(KEY_RIGHT)==True: print(clear()) page=4 if keydown(KEY_LEFT)==True: print(clear()) page=2 if keydown(KEY_ONE)==True: choixvendre = choixvendre - 1 sleep(0.1) if keydown(KEY_FOUR)==True: choixvendre = choixvendre + 1 sleep(0.1) if keydown(KEY_THREE)==True: choixvendre = choixvendre - 10 sleep(0.1) if keydown(KEY_SIX)==True: choixvendre = choixvendre + 10 sleep(0.1) if keydown(KEY_OK)==True: if len(inventory) == 0: draw_string("Aucun résultat.",85,120) sleep(2) draw_string(" ",85,120) else: money , inventory = vendre(choixvendre,inventory,money) ############ if page==4: retour = 0 sleep(0.1) draw_string(" ",1,1) draw_string("Inventaire:",1,1) fill_rect(1,19,105,1,color(0,0,255)) nbpage = len(inventory)/10 if nbpage != trunc(nbpage): nbpage = trunc(nbpage) + 1 if len(inventory) == 0: draw_string("Inventaire:",1,1) fill_rect(1,19,105,1,color(0,0,255)) draw_string("Aucun résultat.",85,100) draw_string("Page ---4-",1,200) if choixpage > nbpage: choixpage = choixpage - 1 if choixpage < 0: choixpage = choixpage + 1 if keydown(KEY_DOWN)==True: choixpage = choixpage + 1 sleep(0.1) print(clear()) if keydown(KEY_UP)==True: choixpage = choixpage - 1 sleep(0.1) print(clear()) else: draw_string("Inventaire:",1,1) fill_rect(1,19,105,1,color(0,0,255)) inventoryupgrade = pageinventaire(inventory,choixpage) if keydown(KEY_ONE)==True: page , objetupgrade , itemwinupgrade = pagechoix(0,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_TWO)==True: page , objetupgrade , itemwinupgrade = pagechoix(1,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_THREE)==True: page , objetupgrade , itemwinupgrade = pagechoix(2,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_FOUR)==True: page , objetupgrade , itemwinupgrade = pagechoix(3,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_FIVE)==True: page , objetupgrade , itemwinupgrade = pagechoix(4,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_SIX)==True: page , objetupgrade , itemwinupgrade = pagechoix(5,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_SEVEN)==True: page , objetupgrade , itemwinupgrade = pagechoix(6,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_EIGHT)==True: page , objetupgrade , itemwinupgrade = pagechoix(7,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_NINE)==True: page , objetupgrade , itemwinupgrade = pagechoix(8,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_ZERO)==True: page , objetupgrade , itemwinupgrade = pagechoix(9,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins) if keydown(KEY_RIGHT)==True: print(clear()) page=5 if keydown(KEY_LEFT)==True: print(clear()) page=3 ############ if page==5: sleep(0.1) draw_string("Argent:" + str(money),200,1) draw_string("Parametre:",1,1) fill_rect(1,19,95,1,color(0,0,255)) draw_string("0/1 - Animation:" + str(paranimation),10,30) draw_string("2/3 - Temps apres ouverture:" + str(tempscaisse),10,50) draw_string("Page ----5",1,200) if keydown(KEY_LEFT)==True: page=4 print(clear()) draw_string(" ",20,30) draw_string(" ",20,50) if keydown(KEY_ZERO)==True: if paranimation == "oui": paranimation = "non" if keydown(KEY_ONE)==True: if paranimation == "non": paranimation = "oui" if keydown(KEY_THREE)==True: tempscaisse = tempscaisse + 1 sleep(0.1) if keydown(KEY_TWO)==True: tempscaisse = tempscaisse - 1 sleep(0.1) ############ if page=="upgrade": prixupgrade = objetupgrade[0] * pourcentage sleep(0.1) draw_string("Argent:" + str(money),200,1) draw_string("Upgrade:",1,1) fill_rect(1,19,75,1,color(0,0,255)) draw_string("Item:" + "[$" + "{:.2f}".format(float(objetupgrade[0])) + "]" + objetupgrade[1],1,30) draw_string("0/1 - Augement les %: " + str(pourcentage) + "x",1,50) draw_string("Tu as " + str(proba) + "% de gagner " + "[$" + "{:.2f}".format(float(prixupgrade)) + "$]",1,70) if keydown(KEY_ZERO)==True: choixpourcentage = choixpourcentage - 1 print(clear()) if keydown(KEY_ONE)==True: choixpourcentage = choixpourcentage + 1 print(clear()) if keydown(KEY_BACKSPACE)==True: retour = 1 if choixpourcentage < 0: choixpourcentage = 0 draw_string("Minimum",120,100) sleep(0.5) draw_string(" ",120,100) if choixpourcentage > 3: choixpourcentage = 3 draw_string("Maximum",120,100) sleep(0.5) draw_string(" ",120,100) if choixpourcentage == 0: pourcentage = 1.5 proba = 57 if choixpourcentage == 1: pourcentage = 2 proba = 35 if choixpourcentage == 2: pourcentage = 5 proba = 23 if choixpourcentage == 3: pourcentage = 10 proba = 13 draw_string("Retour-[Supprimer]",1,200) if retour == 1: page=4 print(clear()) if keydown(KEY_OK)==True: r = randint(1,100) a = 0 if r < proba: a = 1 print(animationupgrade()) draw_string("Tu as gagner:" + str(prixupgrade) + "$",1,120) sleep(1) draw_string(" ",1,120) else: print(animationupgrade()) draw_string("Tu as perdu:" + "[$" + str(objetupgrade[0]) + "]" + objetupgrade[1],1,120) sleep(1) draw_string(" ",1,120) perdu = perdu + objetupgrade[0] for keyname,valeur in inventory.items(): if keyname == objetupgrade[1]: sup = keyname del inventory[sup] if a == 1: money = money + float(prixupgrade) gagne = gagne + float(prixupgrade) retour = 1