Skip to content
Snippets Groups Projects
Commit 3abfc3a5 authored by SINANOVIC EMIR's avatar SINANOVIC EMIR
Browse files

Merge branch 'EMir' into 'main'

Rectification systeme du temps+ saison

See merge request l.duchmann/climate-simulator-global-organization!12
parents cee6ee38 3ef9b85c
No related merge requests found
assets/Interface/money.webp

25.1 KiB

assets/Temps/ensoleillee.png

3.63 KiB

src/Champs.py 100755 → 100644
...@@ -3,15 +3,17 @@ import numpy as np ...@@ -3,15 +3,17 @@ import numpy as np
from Temps import * from Temps import *
from Image import transformImage from Image import transformImage
listeImage = [pygame.transform.scale(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'),(120,120)) for i in range(1,5)] listeImage = [transformImage(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'), 120, 120) for i in range(1,5)]
iconStaticSize = (100,100)
#TODO : mettre une proba que les plantes meurent si il fait trop froid/chaud, et baisser cette proba de mourir avec une serre ou des torche pour l'hiver #TODO : mettre une proba que les plantes meurent si il fait trop froid/chaud, et baisser cette proba de mourir avec une serre ou des torche pour l'hiver
class Champs: class Champs:
iconInsecteStatic = pygame.transform.scale(pygame.image.load("../assets/Plantation/leech.png"),(90,90)) iconInsecteStatic = pygame.transform.scale(pygame.image.load("../assets/Plantation/leech.png"),(90,90))
def __init__ (self, temperature, humidite, tempsAvantMaturation, pos, image): def __init__ (self, temperature, humidite, tempsAvantMaturation, pos, image):
self.PourcentagePlanteFane = 10
self.temperature = temperature self.temperature = temperature
self.humidite = humidite self.humidite = humidite
self.TAM = tempsAvantMaturation self.TAM = tempsAvantMaturation
...@@ -25,40 +27,32 @@ class Champs: ...@@ -25,40 +27,32 @@ class Champs:
self.indiceImage = 0 self.indiceImage = 0
self.champZoom = pygame.rect.Rect(self.pos,self.imgZoom.get_rect().size) self.champZoom = pygame.rect.Rect(self.pos,self.imgZoom.get_rect().size)
self.isInfeste = False self.isInfeste = False
self.descripteurChamps = { self.descripteurChamps = {
"Temperature" : None,
"Humidite" : None,
"Acidite" : None,
"Occupe" : None, "Occupe" : None,
#"Nom" : None
} }
self.imageSurfaceinfo = { self.imageSurfaceinfo = {
"Temperature" : None,
"Humidite" : None,
"Acidite" : None,
"Occupe" : None, "Occupe" : None,
#"Nom" : None
} }
self.setInformation("Temperature",self.temperature)
self.setInformation("Humidite", self.humidite) self.setInformation("Occupe", "Non")
self.setInformation("Acidite",0) #self.setInformation("Nom",self.)
self.setInformation("Occupe", False)
def plantationGrandit(self): def plantationGrandit(self):
self.indiceImage +=1 self.indiceImage += 1
if self.indiceImage <4: if self.indiceImage < 4:
self.imageChamp = listeImage[self.indiceImage] self.imageChamp = listeImage[self.indiceImage]
else: else:
if(self.indiceImage == 4): if(self.indiceImage == 4):
self.imageChamp =pygame.transform.scale(pygame.image.load('../assets/Plantation/damage.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/damage.png'), 120, 120)
elif(self.indiceImage == 5): elif(self.indiceImage == 5):
self.isInfeste = False self.isInfeste = False
self.imageChamp =pygame.transform.scale(pygame.image.load('../assets/Plantation/fanne.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/fanne.png'), 120, 120)
def draw (self, screen, camera): def draw (self, screen, camera):
...@@ -87,7 +81,7 @@ class Champs: ...@@ -87,7 +81,7 @@ class Champs:
(self.rectScale.h-self.rectChampScal.h) (self.rectScale.h-self.rectChampScal.h)
/2) /2)
) )
self.setInformation("Occupe", True) self.setInformation("Occupe", "Oui")
if(self.isInfeste): if(self.isInfeste):
scaleInfecte = camera.scaleImage(Champs.iconInsecteStatic) scaleInfecte = camera.scaleImage(Champs.iconInsecteStatic)
...@@ -112,9 +106,6 @@ class Champs: ...@@ -112,9 +106,6 @@ class Champs:
if scaleText: if scaleText:
self.zoomText = scaleText self.zoomText = scaleText
def setInformation(self,clef,valeur):
self.descr
def setInformation(self,clef,valeur): def setInformation(self,clef,valeur):
self.descripteurChamps[clef] = valeur self.descripteurChamps[clef] = valeur
self.imageSurfaceinfo[clef] = police.render(clef+ " : "+ str(valeur),False,(0,0,0)) self.imageSurfaceinfo[clef] = police.render(clef+ " : "+ str(valeur),False,(0,0,0))
...@@ -152,7 +143,7 @@ class TerrainVide(Champs): ...@@ -152,7 +143,7 @@ class TerrainVide(Champs):
class Houblon (Champs): class Houblon (Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/houblon.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/houblon.png'), *iconStaticSize)
textStatic = police.render('Houblon',False, (0,0,0)) textStatic = police.render('Houblon',False, (0,0,0))
textDescriptionStatic = police.render("Houblon sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Houblon sa marche bien",False,(0,0,0))
montantAchat = 250 montantAchat = 250
...@@ -162,11 +153,11 @@ class Houblon (Champs): ...@@ -162,11 +153,11 @@ class Houblon (Champs):
self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0))
self.zoomText = self.text self.zoomText = self.text
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class Ble (Champs): class Ble (Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/wheat.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/wheat.png'), *iconStaticSize)
textStatic = police.render('Ble',False, (0,0,0)) textStatic = police.render('Ble',False, (0,0,0))
textDescriptionStatic = police.render("Ble sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Ble sa marche bien",False,(0,0,0))
montantAchat = 250 montantAchat = 250
...@@ -174,43 +165,43 @@ class Ble (Champs): ...@@ -174,43 +165,43 @@ class Ble (Champs):
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets/Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class Malt (Champs): class Malt (Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/malt.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/malt.png'), *iconStaticSize)
textStatic = police.render('Malt',False, (0,0,0)) textStatic = police.render('Malt',False, (0,0,0))
textDescriptionStatic = police.render("Malt sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Malt sa marche bien",False,(0,0,0))
montantAchat = 300 montantAchat = 300
montantVente = 800 montantVente = 800
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets/Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class Chanvre(Champs): class Chanvre(Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/weed.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/weed.png'), *iconStaticSize)
textStatic = police.render("Chanvre",False, (0,0,0)) textStatic = police.render("Chanvre",False, (0,0,0))
textDescriptionStatic = police.render("Pour des spaces bières",False,(0,0,0)) textDescriptionStatic = police.render("Pour des spaces bières",False,(0,0,0))
montantAchat = 1000 montantAchat = 1000
montantVente = 5000 montantVente = 5000
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets//Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class OrgeHiver(Champs): class OrgeHiver(Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/orge.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/orge.png'), *iconStaticSize)
textStatic = police.render("Orge hiver",False, (0,0,0)) textStatic = police.render("Orge hiver",False, (0,0,0))
textDescriptionStatic = police.render("Orge hiver sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Orge hiver sa marche bien",False,(0,0,0))
montantAchat = 300 montantAchat = 300
montantVente = 800 montantVente = 800
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets/Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class OrgePrintemps(Champs): class OrgePrintemps(Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/OrgePrintemps.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/OrgePrintemps.png'), *iconStaticSize)
textStatic = police.render("Orge printemps",False, (0,0,0)) textStatic = police.render("Orge printemps",False, (0,0,0))
textDescriptionStatic = police.render("Orge printemps sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Orge printemps sa marche bien",False,(0,0,0))
montantAchat = 500 montantAchat = 500
...@@ -218,22 +209,22 @@ class OrgePrintemps(Champs): ...@@ -218,22 +209,22 @@ class OrgePrintemps(Champs):
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets/Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class Seigle(Champs): class Seigle(Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/seigle.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/seigle.png'), *iconStaticSize)
textStatic = police.render("Seigle",False, (0,0,0)) textStatic = police.render("Seigle",False, (0,0,0))
textDescriptionStatic = police.render("Seigle sa marche bien",False,(0,0,0)) textDescriptionStatic = police.render("Seigle sa marche bien",False,(0,0,0))
montantAchat = 200 montantAchat = 200
montantVente = 600 montantVente = 600
def __init__ (self,pos): def __init__ (self,pos):
super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') super().__init__(0,0,0,pos,'../assets/Plantation/champ.png')
self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120)
class Pesticide(Champs): class Pesticide(Champs):
iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/pesticide.png'),(150,150)) iconStatic = transformImage(pygame.image.load('../assets/Plantation/pesticide.png'), *iconStaticSize)
textStatic = police.render("Pesticide",False, (0,0,0)) textStatic = police.render("Pesticide",False, (0,0,0))
textDescriptionStatic = police.render("Pour tuer les insectes",False,(0,0,0)) textDescriptionStatic = police.render("Pour tuer les insectes",False,(0,0,0))
montantAchat = 200 montantAchat = 200
......
src/Game.py 100755 → 100644
import pygame import pygame
import random import random
from Champs import Champs,Houblon,Buisson,TerrainVide,Pesticide,typePlantation from Champs import *
import numpy as np import numpy as np
from Camera import Camera from Camera import Camera
from Image import transformImage,Image from Image import *
from Temps import Temps from Temps import Temps
from Infrastructure import Infrastructure,typeBatiment,Serre,Torche from Infrastructure import *
RAYON_MUR_INVISIBLE = 2000 RAYON_MUR_INVISIBLE = 2000
SAISONS = ["Printemps", "Été", "Automne", "Hiver"] SAISONS = ["Printemps", "Été", "Automne", "Hiver"]
...@@ -34,7 +34,7 @@ class Game: ...@@ -34,7 +34,7 @@ class Game:
self.clock = pygame.time.Clock() self.clock = pygame.time.Clock()
self.selectedChamp = None self.selectedChamp = None
self.imageMoney = pygame.transform.scale(self.image.moneyImage, np.array(self.image.moneyImage.get_size())/2) self.imageMoney = pygame.transform.scale(self.image.moneyImage, np.array(self.image.moneyImage.get_size())/5)
self.camera = Camera(np.array(self.screen.get_size())/2) self.camera = Camera(np.array(self.screen.get_size())/2)
...@@ -92,9 +92,7 @@ class Game: ...@@ -92,9 +92,7 @@ class Game:
self.screen.blit(self.temps.nexticonSaison,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height() +20)) self.screen.blit(self.temps.nexticonSaison,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height() +20))
self.screen.blit(self.temps.tempsaisonImageDeuxPosiiton,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height())) self.screen.blit(self.temps.tempsaisonImageDeuxPosiiton,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height()))
print(self.rectPlantation.w)
print(self.rectPlantation.h)
#Onglet plantation #Onglet plantation
self.screen.blit(self.rectPlantationimage,(0,0)) self.screen.blit(self.rectPlantationimage,(0,0))
...@@ -105,15 +103,14 @@ class Game: ...@@ -105,15 +103,14 @@ class Game:
for i,c in enumerate(typePlantation): for i,c in enumerate(typePlantation):
x = self.rectPlantation.x + ( 0 if i%2 else 170) x = self.rectPlantation.x + ( 0 if i%2 else 170)
y = self.rectPlantation.y + (i//2) * 200 y = self.rectPlantation.y + (i//2) * 140
r = pygame.rect.Rect(x,y,c.iconStatic.get_width(),c.iconStatic.get_height()+ 30 ) r = pygame.rect.Rect(x,y,c.iconStatic.get_width(),c.iconStatic.get_height()+ 20 )
self.screen.blit(c.textStatic, (x,y)) self.screen.blit(c.textStatic, (x,y))
self.screen.blit(c.iconStatic,(x,y+30 )) self.screen.blit(c.iconStatic,(x,y+20 ))
if ( (r.collidepoint(pygame.mouse.get_pos()))): if ( (r.collidepoint(pygame.mouse.get_pos()))):
pygame.draw.rect(self.screen,(138, 227, 237), r,1) pygame.draw.rect(self.screen,(138, 227, 237), r,1)
self.screen.blit(c.textDescriptionStatic,(self.recInformation.x,self.recInformation.y)) self.screen.blit(c.textDescriptionStatic,(self.recInformation.x,self.recInformation.y))
#self.screen.blit(self.text,(screen.get_width()*0.85,screen.get_height()*0.18)) #self.screen.blit(self.text,(screen.get_width()*0.85,screen.get_height()*0.18))
...@@ -133,8 +130,6 @@ class Game: ...@@ -133,8 +130,6 @@ class Game:
isChamp = False isChamp = False
#
if self.money < self.displayMoney: if self.money < self.displayMoney:
...@@ -179,7 +174,7 @@ class Game: ...@@ -179,7 +174,7 @@ class Game:
for i,c in enumerate(typePlantation): for i,c in enumerate(typePlantation):
x = self.rectPlantation.x + ( 0 if i%2 else 170) x = self.rectPlantation.x + ( 0 if i%2 else 170)
y = self.rectPlantation.y + (i//2) * 200 y = self.rectPlantation.y + (i//2) * 140
r = pygame.rect.Rect(x,y,c.iconStatic.get_width() + 20 ,c.iconStatic.get_height()+ 30 ) r = pygame.rect.Rect(x,y,c.iconStatic.get_width() + 20 ,c.iconStatic.get_height()+ 30 )
if ( (r.collidepoint(event.pos))): if ( (r.collidepoint(event.pos))):
self.dragPlantation = c self.dragPlantation = c
...@@ -288,7 +283,7 @@ class Game: ...@@ -288,7 +283,7 @@ class Game:
if self.frame < self.buyFrame + 20: if self.frame < self.buyFrame + 20:
self.screen.blit(self.moneyChange, (self.screen.get_width() -200, (self.frame-self.buyFrame)*1.5)) self.screen.blit(self.moneyChange, (self.screen.get_width() - self.imageMoney.get_width() - textMoney.get_width(), (self.frame-self.buyFrame)*1.5))
#self.screen.blit(self.moneyChange, (200, self.screen.get_height()-textMoney.get_height()*4+(self.frame-self.buyFrame)*1.5)) #self.screen.blit(self.moneyChange, (200, self.screen.get_height()-textMoney.get_height()*4+(self.frame-self.buyFrame)*1.5))
if self.selectedChamp: if self.selectedChamp:
......
...@@ -6,7 +6,7 @@ class Image: ...@@ -6,7 +6,7 @@ class Image:
self.screen = screen self.screen = screen
# Chargement des images # Chargement des images
self.moneyImage = pygame.image.load("../assets/Interface/money.png") self.moneyImage = pygame.image.load("../assets/Interface/money.webp")
self.backgroundImage = pygame.image.load("../assets/Interface/terre.png") self.backgroundImage = pygame.image.load("../assets/Interface/terre.png")
self.rainImage = pygame.image.load("../assets/Temps/pluie.png") self.rainImage = pygame.image.load("../assets/Temps/pluie.png")
self.arrowNextImage = pygame.image.load("../assets/Interface/suite.png") self.arrowNextImage = pygame.image.load("../assets/Interface/suite.png")
......
...@@ -47,9 +47,6 @@ class Infrastructure: ...@@ -47,9 +47,6 @@ class Infrastructure:
(self.rectScale.h-self.rectbatScal.h) (self.rectScale.h-self.rectbatScal.h)
/2) /2)
) )
def changeText (self, camera): def changeText (self, camera):
scaleText = camera.scaleImage(self.text) scaleText = camera.scaleImage(self.text)
......
class Plantation:
def __init__ (self):
\ No newline at end of file
...@@ -4,16 +4,14 @@ from Image import transformImage ...@@ -4,16 +4,14 @@ from Image import transformImage
from random import triangular from random import triangular
police = pygame.font.SysFont("Alef", 30) police = pygame.font.SysFont("Alef", 30)
police2 = pygame.font.SysFont("Alef", 20) police2 = pygame.font.SysFont("Alef", 20)
class Temps:
""" """
climats = { climats = {
"janvier" : {
"janvier" : { "temp" : [2,7.8],
"temp" : [2,7.8], "humidité" : [78,90]
"humidité" : [78,90] },
}, "février" : {
"février" : {
"temp" : [4.5,11.8], "temp" : [4.5,11.8],
"humidité" : [60,85] "humidité" : [60,85]
}, },
...@@ -59,15 +57,16 @@ class Temps: ...@@ -59,15 +57,16 @@ class Temps:
} }
} }
""" """
class Temps:
climats = { climats = {
"Automne" : { "Automne" : {
"temp" : [4.8,13.3], "temp" : [4.8,13.3],
"humidité" : [70,95] "humidité" : [70,95]
}, },
"Hiver" : { "Hiver" : {
"temp" : [-5,10.3], "temp" : [-5,10.3],
"humidité" : [50,90] "humidité" : [50,90]
}, },
...@@ -82,31 +81,34 @@ class Temps: ...@@ -82,31 +81,34 @@ class Temps:
} }
def __init__(self): def __init__(self):
self.ListTemps = ["neige","orage","pluie","ensoleillee","vent","secheresse","canicule","froid","chaud"]
self.indice = 2 self.indice = 2
self.currentSeason = self.getSaisonName(self.indice) self.currentSeason = self.getSaisonName(self.indice)
self.globaltemp = self.tirageAuSortChiffreIntervalleTemp(self.currentSeason) self.globaltemp = self.tirageTemperature(self.currentSeason)
self.humidite = self.tirageAuSortChiffreIntervallehumidite(self.currentSeason) self.humidite = self.tirageAuSortChiffreIntervallehumidite(self.currentSeason)
self.temps = pygame.image.load(self.tempAAfficher(self.globaltemp,self.humidite)) self.temps = pygame.image.load(self.tempAAfficher(self.currentSeason,self.tirageTemps()))
self.iconSaison = transformImage(self.temps,200,200) self.iconSaison = transformImage(self.temps,200,200)
self.nextSaison = self.getSaisonName(self.indice+1) self.nextSeason = self.getSaisonName(self.indice+1)
self.nextglobalTemps = self.tirageAuSortChiffreIntervalleTemp(self.nextSaison) self.nextglobalTemps = self.tirageTemperature(self.nextSeason)
self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSaison) self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason)
self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextglobalTemps,self.nexthumidite)) self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextSeason,self.tirageTemps()))
self.nexticonSaison = transformImage(self.nextTemps,100,100) self.nexticonSaison = transformImage(self.nextTemps,100,100)
self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0))
self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSaison +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0))
self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0))
for key,value in self.climats.items(): for key,value in self.climats.items():
self.climats.get(key)['image'] = transformImage(pygame.image.load("../assets/Saison/"+key+".png"),400,300) self.climats.get(key)['image'] = transformImage(pygame.image.load("../assets/Saison/"+key+".png"),400,300)
self.ListTemps = []
def NextTurn(self): def NextTurn(self):
#Le next qui devien current #Le next qui devien current
self.indice += 1 self.indice += 1
self.currentSeason = self.nextSaison self.currentSeason = self.nextSeason
self.globaltemp = self.nextglobalTemps self.globaltemp = self.nextglobalTemps
self.humidite = self.nexthumidite self.humidite = self.nexthumidite
self.temps = self.nextTemps self.temps = self.nextTemps
...@@ -114,20 +116,18 @@ class Temps: ...@@ -114,20 +116,18 @@ class Temps:
self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0))
#Nouveau turn #Nouveau turn
self.nextSaison = self.getSaisonName(self.indice+1) self.nextSeason = self.getSaisonName(self.indice+1)
self.nextglobalTemps = self.tirageAuSortChiffreIntervalleTemp(self.nextSaison) self.nextglobalTemps = self.tirageTemperature(self.nextSeason)
self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSaison) self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason)
self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextglobalTemps,self.nexthumidite)) self.nextTemps = pygame.image.load(self.tempAAfficher(self.currentSeason,self.tirageTemps()))
self.nexticonSaison = transformImage(self.nextTemps,100,100) self.nexticonSaison = transformImage(self.nextTemps,100,100)
self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0))
self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSaison +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0))
def getSaisonName(self,indice:int)->str: def getSaisonName(self,indice:int)->str:
return list(self.climats.keys())[indice%4] return list(self.climats.keys())[indice%4]
def tirageAuSortChiffreIntervalleTemp(self,clef): def tirageTemperature(self,clef):
#tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5
intervalle = self.getClimatTemp(clef) intervalle = self.getClimatTemp(clef)
...@@ -144,25 +144,32 @@ class Temps: ...@@ -144,25 +144,32 @@ class Temps:
#randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] #randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0]
return random.triangular(low = intervalle[0],high = intervalle[1]) return random.triangular(low = intervalle[0],high = intervalle[1])
def tempAAfficher(self,temperature:float,humidite)-> str: def tirageTemps(self):
#Determination du temps a afficher nbrandom = random.randint(0,len(self.ListTemps)-1)
if( temperature < 0 and humidite >80): print("nbrandom"+ str(nbrandom))
return "../assets/Temps/neige.png" print(self.ListTemps[nbrandom])
elif (temperature < 10): return self.ListTemps[nbrandom]
return "../assets/Temps/froid.png"
elif (temperature < 35): def tempAAfficher(self, saison,temps:str)-> str:
return "../assets/Temps/chaud.png" #Determination du temps a afficher
elif (temperature > 34):
if(humidite > 85): if saison == "Automne" and temps not in ["secheresse","canicule","chaud"]:
return "../assets/Temps/orage.png" print("Automne")
return str("../assets/Temps/"+temps+".png")
if(humidite < 65): elif saison == "Hiver" and temps not in ["secheresse","canicule","chaud"]:
return "../assets/Temps/secheresse.png" print("rentrer hiver")
else: return str("../assets/Temps/"+temps+".png")
return "../assets/Temps/canicule.png" elif saison == "Printemps" and temps not in ["secheresse","canicule","neige"]:
print("Printemps")
return str("../assets/Temps/"+temps+".png")
elif saison == "été" and temps not in ["froid","neige"]:
print("été")
return str("../assets/Temps/"+temps+".png")
else: else:
pass return self.tempAAfficher(saison,self.tirageTemps())
def getClimatTemp(self,clef): def getClimatTemp(self,clef):
return self.climats[clef]["temp"] return self.climats[clef]["temp"]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment