1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| # ----------------- Espace Plaine ------------------ #
def modifplaine(ref):
global fenbis
fenbis = Tk()
fenbis.geometry("200x100")
Bou1 = Button(fenbis, text = 'Créer une caserne', command = lambda : modif_plaine(ref,2))
Bou1.pack()
Bou2 = Button(fenbis, text = 'Créer un moulin', command = lambda : modif_plaine(ref,3))
Bou2.pack()
def modif_plaine(ref, refim):
listebutton[ref].config(image = listeimageplaine[refim-1])
fenbis.destroy()
def testpains(qt,ref,nb):
global Nombre_de_ble, var_soldat
if Nombre_de_ble >= qt:
ref.nw()
Nombre_de_ble -= qt
var_ble.set('Quantité de blés : ' + str(Nombre_de_ble))
else :
print('Blés insufisants')
def Nouveau_Soldat(ref,nb):
global var_soldat
fenbis = Tk()
fenbis.geometry("200x100")
var_soldat = StringVar(fenbis, 'Nombre de soldats : ' + str(nb))
Aff_soldat = Label(fenbis, textvariable = var_soldat)
Aff_soldat.grid()
NwSoldat = Button(fenbis, text = " Créer un nouveau Soldat (-5 blés) ", command = lambda : testpains(5,ref,nb))
NwSoldat.grid()
fenbis.mainloop()
class Plaine():
def __init__(self, num):
self.num = num
self.lvl = 1
self.soldats = 1
def central(self, SITUATION):
if SITUATION == 0 :
Nouveau_Soldat(self,self.soldats)
if SITUATION == 1 :
self.upgrade()
def nw(self):
self.soldats += 1
var_soldat.set('Nombre de soldats : ' + str(self.soldats))
def upgrade(self):
if self.lvl == 1:
modifplaine(self.num)
self.lvl += 1
else:
print('Max')
def bou(self):
listebutton[self.num].config(image = imageplaine)
# -------------------------------------------------- #
# ----------------- Espace champs ------------------ #
def modifchamp(ref, lvl):
listebutton[ref].config(image = listeimagechamp[lvl-1])
def recolte(ref, ble):
fenbis = Tk()
fenbis.geometry("200x100")
Texte = '\n'+'Vous avez ' + str(ble) + ' blés à recolter'+'\n'
Affichage = Label(fenbis, text = Texte)
Affichage.pack()
if ref.mure == True :
Recolter = Button(fenbis, text = 'Récolter', command = lambda : ajout_ble(ref, ref.ble) and fenbis.destroy())
Recolter.pack()
def murissage(ref, refnum):
ref.mure = True
ref.ble += 10
listebutton[refnum].config(image = imagechampbis)
class Champs():
def __init__(self, num):
self.num = num
print(self.num)
self.lvl = 1
self.ble = IntVar()
self.ble = 0
self.mure = False
fen.after(5000, lambda : murissage(self,self.num))
def central(self, SITUATION):
if SITUATION == 0 :
recolte(self, self.ble)
if SITUATION == 1 :
self.upgrade()
def upgrade(self):
if self.lvl < 3:
self.lvl += 1
print(self.lvl)
modifchamp(self.num, self.lvl)
else:
print('Max')
def bou(self):
listebutton[self.num].config(image = imagechamp)
def reset(self):
self.ble = 0
self.mure = False
# -------------------------------------------------- # |