mcase3.py

Created by kbdechez-lidl

Created on November 06, 2022

9.21 KB

Partie 3 de MCASE


from mcase1 import *
from mcase2 import *
from math import *
from kandinsky import *
from ion import *
from time import *
from random import *
##########################################
def caisse(caseChoice,tempscaisse,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,inventory,paranimation,nom):
    tanimation = []
    tcolor = []
    acaisse = 0
    while acaisse != 11:
      adjective = None
      x = 0
      y = 0
      if randint(1,10) == 8:
        x = 1
      #Calcul Dura
      q = randint(1,100)
      if q > 90:
        adjective = wears[x][0]
        y = 0
      elif q > 75:
        adjective = wears[x][1]
        y = 1
      elif q > 35:
        adjective = wears[x][2]
        y = 2
      elif q > 10:
        adjective = wears[x][3]
        y = 3
      else:
        adjective = wears[x][4]
        y = 4
      #Calcul Arme
      rarity = randint(1,500)
      if rarity >= 150 :
        couleur = "blue"
        gun = choice(blueGuns)
      elif rarity >= 36 and rarity <150:
        couleur = "purple"
        gun = choice(purpleGuns)
      elif rarity >=6 and rarity<36:
        couleur = "pink"
        gun = choice(pinkSkins)
      elif rarity >= 2 and rarity<6:
        couleur = "red"
        gun = choice(redSkins)
      elif rarity ==1 or rarity==2:
        couleur = "gold"
        gun = choice(knifeSkins)
      name = str(adjective) + " " + str(gun[0])
      price = str(gun[x + 1][y])
      price = "{:.2f}".format(float(price))
      if caseChoice not in gun:
        continue
      acaisse = acaisse + 1
      if acaisse != 11:
        tanimation.append("[$"+price +"] "+ name)
        tcolor.append(couleur)
    name = str(adjective) + " " + str(gun[0])
    print(caisse2(tanimation,name,price,couleur,tcolor,inventory,paranimation,tempscaisse,nom))
    return name , price
##############
def caisse2(tanimation,name,price,couleur,tcolor,inventory,paranimation,tempscaisse,nom):
    inventory[name] = float(price)
    draw_string("[OK] pour ouvrir",70,100)
    if nom == "Falchion":
        draw_string(nom,115,30)
        fill_rect(130,53,50,40,color(216,177,65))
        fill_rect(130,58,50,5,color(153,121,61))
        fill_rect(135,53,3,40,color(153,121,61))
        fill_rect(140,53,3,40,color(153,121,61))
        fill_rect(165,53,3,40,color(153,121,61))
        fill_rect(170,53,3,40,color(153,121,61))
        fill_rect(149,73,10,7,color(99,1,1))
        fill_rect(149,73,5,7,color(37,24,24))
    if nom == "Bravo":
        draw_string(nom,130,30)
        fill_rect(130,53,50,40,color(62, 64, 65))
        fill_rect(130,58,50,5,color(50, 55, 58))
        fill_rect(135,53,3,40,color(50, 55, 58))
        fill_rect(140,53,3,40,color(50, 55, 58))
        fill_rect(165,53,3,40,color(50, 55, 58))
        fill_rect(170,53,3,40,color(50, 55, 58))
        fill_rect(149,73,10,7,color(241,129,76))
        fill_rect(153,65,2,17,color(184,56,30))
        fill_rect(151,67,6,2,color(184,56,30))
    while True:
        if keydown(KEY_OK)==True:
            if paranimation == "oui":
              print(cinematique(tanimation,couleur,tcolor))
            draw_string("[$"+price +"] "+ name,1,100)
            print(choixcouleur(couleur))
            sleep(tempscaisse)
            print(clear())
            break
##############
def cinematique(tanimation,couleur,tcolor):
    temps = 0.1
    for i in range(len(tanimation)-1):
        draw_string("                         ",10,100)
        draw_string(tanimation[i],1,100)
        sleep(temps)
        print(couleurcinematique(tcolor,i))
    temps = 0
    for i in range(len(tanimation)-1):
        draw_string("                         ",10,100)
        draw_string(tanimation[i],1,100)
        sleep(temps)
        temps = temps + 0.05
        print(couleurcinematique(tcolor,i))
    temps = 0.5
    for i in range(len(tanimation)-5):
        draw_string("                         ",10,100)
        draw_string(tanimation[i],1,100)
        sleep(temps)
        temps = temps + 0.05
        print(couleurcinematique(tcolor,i))
##############
def couleurcinematique(tcolor,i):
        print(i)
        tcouleur = tcolor[i+1]
        print(choixcouleur(tcouleur))
##############
def choixcouleur(tcouleur):
    if tcouleur == "blue":
      fill_rect(1,95,400,1,color(0,0,255))
      fill_rect(1,120,400,1,color(0,0,255))
    elif tcouleur == "purple":
      fill_rect(1,95,400,1,color(138,43,226))
      fill_rect(1,120,400,1,color(138,43,226))
    elif tcouleur == "pink":
      fill_rect(1,95,400,1,color(255,0,255))
      fill_rect(1,120,400,1,color(255,0,255))
    elif tcouleur == "red":
      fill_rect(1,95,400,1,color(245,0,0))
      fill_rect(1,120,400,1,color(245,0,0))
    elif tcouleur == "gold":
      fill_rect(1,95,400,1,color(255,215,0))
      fill_rect(1,120,400,1,color(255,215,0))
##############
def clear():
  h = 0
  boucleclear = 0
  while boucleclear!=100:
    h = h + 4
    draw_string("                                       ",1,h)
    boucleclear = boucleclear+ 1
##############
def vendre(choixvendre,inventory,money):
    sup = []
    for keyname,valeur in inventory.items():
        if inventory[keyname] < int(choixvendre):
            money = money + inventory[keyname]
            sup.append(keyname)
    for i in sup:
        del inventory[i]
    return money , inventory
##############
def pageinventaire(inventory,num):
      finale = []
      tabreturn = []
      tabboucle = []
      inventoryupgrade = []
      for k, v in sorted(inventory.items(), key=lambda x: x[1],reverse=True):
        inventoryupgrade.append([v,k])
        item = "[$" + "{:.2f}".format(float(v)) + "]" + k
        finale.append(item)
      nbpage = len(finale)/10
      if nbpage != trunc(nbpage):
            nbpage = trunc(nbpage) + 1
      if num > nbpage:
          draw_string("Page introuvable",85,100)
      boucleprincipale = 0
      boucle = 1
      while boucleprincipale != 1:
        if len(finale) >= 10:
            tabboucle = []
            for i in range(10):
                finale[0] = str(boucle) + "-" + finale[0]
                tabboucle.append(finale[0])
                finale.remove(finale[0])
                boucle = boucle + 1
            if len(tabreturn) == 0:
                tabreturn = [tabboucle]
            else:
                tabreturn = tabreturn + [tabboucle]
        if len(finale) < 10:
            tabboucle = []
            for i in range(len(finale)):
                finale[0] = str(boucle) + "-" + finale[0]
                tabboucle.append(finale[0])
                finale.remove(finale[0])
                boucle = boucle + 1
            if len(tabreturn) == 0:
                tabreturn = [tabboucle]
            else:
                tabreturn = tabreturn + [tabboucle]
            boucleprincipale = 1
      hauteur = 20
      for i in range(len(tabreturn[num-1])):
          draw_string(tabreturn[num-1][0],1,hauteur)
          hauteur = hauteur + 20
          if hauteur > 200:
            hauteur = 20
          tabreturn[num-1].remove(tabreturn[num-1][0])
      return inventoryupgrade
##############
def parcourir(titem,wears):
    t = []
    n = len(titem)
    for i in range(len(titem[0])):
            x = 0
            y = 1
            z = 0
            while x != n:
                for i in range(len(titem[x][y])):
                    t.append(titem[x][y][z])
                    z = z + 1
                y = y + 1
                z = 0
                for i in range(len(titem[x][y])):
                    t.append(titem[x][y][z])
                    z = z + 1
                x = x + 1
                y = 1
                z = 0
    return t
def upgrade(objetupgrade,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,wears):
    finale = []
    liste = parcourir(blueGuns,wears)
    sleep(0.1)
    finale.append(float("{:.2f}".format(liste[min(range(len(liste)), key = lambda i: abs(liste[i]-objetupgrade))])))
    liste = parcourir(purpleGuns,wears)
    sleep(0.1)
    finale.append(float("{:.2f}".format(liste[min(range(len(liste)), key = lambda i: abs(liste[i]-objetupgrade))])))
    liste = parcourir(pinkSkins,wears)
    sleep(0.1)
    finale.append(float("{:.2f}".format(liste[min(range(len(liste)), key = lambda i: abs(liste[i]-objetupgrade))])))
    liste = parcourir(redSkins,wears)
    sleep(0.1)
    finale.append(float("{:.2f}".format(liste[min(range(len(liste)), key = lambda i: abs(liste[i]-objetupgrade))])))
    liste = parcourir(knifeSkins,wears)
    sleep(0.1)
    finale.append(float("{:.2f}".format(liste[min(range(len(liste)), key = lambda i: abs(liste[i]-objetupgrade))])))
    return "{:.2f}".format(finale[min(range(len(finale)), key = lambda i: abs(finale[i]-objetupgrade))])
##############
def animationupgrade():
    draw_string("Calcul.",20,120)
    sleep(0.3)
    draw_string("Calcul..",20,120)
    sleep(0.3)
    draw_string("Calcul...",20,120)
    sleep(0.3)
    while True:
        draw_string("Appuyez sur [OK] pour le résultat.",1,120)
        if keydown(KEY_OK)==True:
            draw_string("                                          ",1,120)
            break
##############
def pagechoix(num,inventoryupgrade,wears,blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins):
  objetupgrade = inventoryupgrade[num]
  itemwinupgrade = upgrade(objetupgrade[0],blueGuns,purpleGuns,pinkSkins,redSkins,knifeSkins,wears)
  page = "upgrade"
  print(clear())
  sleep(0.1)
  return page , objetupgrade , itemwinupgrade

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.