diff --git a/README.md b/README.md index 0d7c0138c77f36e7e4768477deba589f7fab04d3..d23c3fa752aab9471e76fe5611311717d1805576 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ Participants : - [x] Concevoir un poster qui décrit cet objectif pédagogique - [x] Définir le type de jeu et les mécanismes d'apprentissage (Septembre) - [x] Définir la liste des principales fonctionnalités -- [ ] Développer ces fonctionnalités +- [x] Développer ces fonctionnalités - [x] Evaluation à mi-parcours (Octobre) -- [ ] Tester et équilibrer +- [x] Tester et équilibrer - [x] Choisir la Licence (Novembre) -- [ ] Finaliser le git et produire la documentation -- [ ] Présenter son jeu et le faire évaluer (Décembre) +- [x] Finaliser le git et produire la documentation +- [x] Présenter son jeu et le faire évaluer (Décembre) ## Objectif pédagogique @@ -41,17 +41,66 @@ Mécanismes d'apprentissage : Créer une issue par fonctionnalités. -- [ ] Gestion de l'argent -- [ ] Conséquences météorologiques -- [ ] Gestion du bien-être des plantes -- [ ] Cycle des saisons +- [x] Gestion de l'argent +- [x] Conséquences météorologiques +- [x] Gestion du bien-être des plantes +- [x] Cycle des saisons ## Justification du choix de la Licence +Contrat De Licence D’utilisateur Final + + +VOUS DEVEZ LIRE ATTENTIVEMENT LE PRÉSENT ACCORD (L'« ACCORD ») AVANT DE JOUER + +Nous avons consacré énormément de temps sur notre projet sachant que python est un langage open source sans aucune contrainte de licence. De ce fait, pour jouer à notre jeu vous devez accepter les clauses. + +Si vous acceptez et respectez les conditions du contrat, vous recevrez, une licence limitée non-cessible et non-exclusive pour utiliser notre jeu ou le code source sous réserve des clause ci-dessous : + +I – Ne pas copier, décompiler, vendre ou reproduire le jeu ou son code source + +II – Ne pas utiliser notre jeu dans un domaine autre qu’éducatif + +III – Interdiction d’utiliser les licences concédées à des fins commerciales + + +Nous pouvons suspendre ou résilier votre licence d'utilisation pour non-conformité aux clauses ci-dessus. + ## Lien de téléchargement ## Captures d'écran +Écran de départ + +Écran de jeu + +Plante infécté + +Plante morte + + ## Procédures d'installation et d'exécution +Pour Linux et Mac : + +Pré-requis : + +- Avoir Python d'installé (testé sur les versions `3.9.1` et `3.9.2`) +[Installer Python](https://www.python.org/downloads/) +- Avoir pip d'installé +[Installer pip](https://pypi.org/project/pip/) +- Installer les dépendances +`pip install -r requirements.txt` + +Jouer au jeu + +```sh +cd ../src/ +py T3.py +``` + +## Pour les développeurs + +Le projet a été créé avec Python 3.9 (fonctionne avec 3.10) +La seule librairie nécessaire est pygame diff --git a/assets/Interface/button.png b/assets/Interface/button.png old mode 100755 new mode 100644 diff --git a/assets/Interface/money.png b/assets/Interface/money.png old mode 100755 new mode 100644 diff --git a/assets/Interface/terre.png b/assets/Interface/terre.png old mode 100755 new mode 100644 diff --git a/assets/Plantation/champ.png b/assets/Plantation/champ.png old mode 100755 new mode 100644 diff --git a/assets/Temps/nice_weather.png b/assets/Temps/nice_weather.png new file mode 100644 index 0000000000000000000000000000000000000000..75e3024948bf6bed7af9f10eefdae966cdcbbbc4 Binary files /dev/null and b/assets/Temps/nice_weather.png differ diff --git "a/img/ecran_de_d\303\251part.png" "b/img/ecran_de_d\303\251part.png" new file mode 100644 index 0000000000000000000000000000000000000000..8be0670ffdfc15018c23cb57d4066fb8ffbab1a5 Binary files /dev/null and "b/img/ecran_de_d\303\251part.png" differ diff --git a/img/ecran_de_jeu.png b/img/ecran_de_jeu.png new file mode 100644 index 0000000000000000000000000000000000000000..00dc381c3d57221f92fd09c1d12493bd676b3daa Binary files /dev/null and b/img/ecran_de_jeu.png differ diff --git a/img/plante_infecte.png b/img/plante_infecte.png new file mode 100644 index 0000000000000000000000000000000000000000..cd69f3c5def1058c7c387441186e46b87aac40ba Binary files /dev/null and b/img/plante_infecte.png differ diff --git a/img/plante_morte.png b/img/plante_morte.png new file mode 100644 index 0000000000000000000000000000000000000000..46a3dfffbbc8e6531b3ae50c9dba8dddb56826a2 Binary files /dev/null and b/img/plante_morte.png differ diff --git a/src/Champs.py b/src/Champs.py index 96c43036f1bf04a051c064c95dbd45c4890bc538..0f343a410ee3fdbe75065e34bfc2255c14a95614 100644 --- a/src/Champs.py +++ b/src/Champs.py @@ -1,241 +1,241 @@ -import pygame -import numpy as np -from Temps import * -from Image import transformImage -#from Infrastructure import Infrastructure -listeImage = [transformImage(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'), 120, 120) for i in range(1,5)] -iconStaticSize = (100,100) - -class Champs: - iconInsecteStatic = pygame.transform.scale(pygame.image.load("../assets/Plantation/leech.png"),(90,90)) - - def __init__ (self, temperature, humidite, tempsAvantMaturation, pos, image): - self.pourcentagePlanteFane = 10 - - self.temperature = temperature - self.humidite = humidite - self.TAM = tempsAvantMaturation - self.pos = np.array(pos) - self.image = pygame.image.load(image) - self.imageSize = np.array(self.image.get_size()) - self.rect = pygame.rect.Rect(self.pos, self.image.get_rect().size) - self.rectScale = self.rect - self.police = pygame.font.SysFont("Alef", 22) #pygame.font.get_fonts() -> liste des fonts - self.imgZoom = pygame.transform.scale(self.image, self.imageSize) - self.indiceImage = 0 - self.champZoom = pygame.rect.Rect(self.pos,self.imgZoom.get_rect().size) - self.isInfeste = False - self.bat = None - #self.infra = self.setInfrastrcture(self.pos,self.image) - - - - self.descripteurChamps = { - - } - - self.imageSurfaceinfo = { - - } - self.setInformation("Occupe" , "Champ non occupé") - self.setInformation("Nom","Champ Vide ") - self.setInformation("coutEntretien","90€ coût d'entretien mensuel") - self.setInformation("fane", "Pourcentage que la plante fanne : ") - self.setInformation(hash('fane'), str(self.pourcentagePlanteFane)+' %') - self.setInformation("status", self.image,True) - - - - def plantationGrandit(self): - self.indiceImage += 1 - if self.indiceImage < 4: - self.imageChamp = listeImage[self.indiceImage] - else: - if(self.indiceImage == 4): - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/damage.png'), 120, 120) - elif(self.indiceImage == 5): - self.isInfeste = False - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/fanne.png'), 120, 120) - """ - def setInfrastrcture(self,pos,image): - return Infrastructure(pos,image) - """ - def draw (self, screen, camera): - scaleImage = camera.scaleImage(self.image) - - if scaleImage: # != None - self.imgZoom = scaleImage - self.rectScale = pygame.rect.Rect(camera.convertLocation(self.pos), self.imgZoom.get_size()) - - - - screen.blit(self.imgZoom, camera.convertLocation(self.pos)) - if hasattr(self,'imageChamp'): - scaleChamp = camera.scaleImage(self.imageChamp) - if scaleChamp: - self.champZoom = scaleChamp - varlongueur = camera.convertLocation(self.pos) - self.rectChampScal = pygame.rect.Rect(varlongueur, self.champZoom.get_size()) - screen.blit( - self.champZoom, - ( - varlongueur[0] + - (self.rectScale.w-self.rectChampScal.w) - /2, - varlongueur[1] + - (self.rectScale.h-self.rectChampScal.h) - /2) - ) - - if(self.isInfeste): - scaleInfecte = camera.scaleImage(Champs.iconInsecteStatic) - if scaleInfecte: - self.infecteZoom = scaleInfecte - varlongueur = camera.convertLocation(self.pos) - self.rectScalInfecte = pygame.rect.Rect(varlongueur, self.infecteZoom.get_size()) - screen.blit( - self.infecteZoom, - ( - varlongueur[0] + - (self.rectScale.w-self.rectScalInfecte.w) - /2, - varlongueur[1] + - (self.rectScale.h-self.rectScalInfecte.h) - /2) - ) - - def changeText (self, camera): - scaleText = camera.scaleImage(self.text) - if scaleText: - self.zoomText = scaleText - - def setInformation(self,clef,valeur,isImage = False): - self.descripteurChamps[clef] = valeur - if isImage : - self.imageSurfaceinfo[clef] = valeur - else : - self.imageSurfaceinfo[clef] = police.render(str(valeur),True,(0,0,0)) - - def showInfo(self,screen,rectangle,bat = {}): - i = 0 - for k,v in self.descripteurChamps.items(): - screen.blit(self.imageSurfaceinfo[k],(rectangle.x,rectangle.y + i)) - i += 30 - - -class Buisson (Champs): - def __init__ (self, pos, prix = 10000): - super().__init__(0, 0, 0, pos, '../assets/Interface/buissonCadenas.png') - self.prix = prix - self.text = self.police.render("Champ disponible à l'achat : " + str(self.prix), False, (0,0,0)) - self.zoomText = self.text - - def showInfo (self, screen,rectangle): - screen.blit(self.text,(rectangle.x,rectangle.y)) - - def buyField (self): - return TerrainVide(self.pos) - - -class TerrainVide(Champs): - def __init__ (self, pos): - super().__init__(0, 0, 0, pos,'../assets/Plantation/champ.png') - self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) - self.zoomText = self.text - - - -class Houblon (Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/houblon.png'), *iconStaticSize) - textStatic = police.render('Houblon',False, (0,0,0)) - textDescriptionStatic = police.render("Houblon sa marche bien",False,(0,0,0)) - montantAchat = 250 - montantVente = 600 - def __init__ (self, pos): - super().__init__(0, 0, 0, pos,'../assets/Plantation/champ.png') - self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) - self.zoomText = self.text - - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class Ble (Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/wheat.png'), *iconStaticSize) - textStatic = police.render('Ble',False, (0,0,0)) - textDescriptionStatic = police.render("Ble sa marche bien",False,(0,0,0)) - montantAchat = 250 - montantVente = 800 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - -class Malt (Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/malt.png'), *iconStaticSize) - textStatic = police.render('Malt',False, (0,0,0)) - textDescriptionStatic = police.render("Malt sa marche bien",False,(0,0,0)) - montantAchat = 300 - montantVente = 800 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class Chanvre(Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/weed.png'), *iconStaticSize) - textStatic = police.render("Chanvre",False, (0,0,0)) - textDescriptionStatic = police.render("Pour des spaces bières",False,(0,0,0)) - montantAchat = 1000 - montantVente = 5000 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets//Plantation/champ.png') - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class OrgeHiver(Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/orge.png'), *iconStaticSize) - textStatic = police.render("Orge hiver",False, (0,0,0)) - textDescriptionStatic = police.render("Orge hiver sa marche bien",False,(0,0,0)) - montantAchat = 300 - montantVente = 800 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class OrgePrintemps(Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/OrgePrintemps.png'), *iconStaticSize) - textStatic = police.render("Orge printemps",False, (0,0,0)) - textDescriptionStatic = police.render("Orge printemps sa marche bien",False,(0,0,0)) - montantAchat = 500 - montantVente = 1000 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class Seigle(Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/seigle.png'), *iconStaticSize) - textStatic = police.render("Seigle",False, (0,0,0)) - textDescriptionStatic = police.render("Seigle sa marche bien",False,(0,0,0)) - montantAchat = 200 - montantVente = 600 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) - - -class Pesticide(Champs): - iconStatic = transformImage(pygame.image.load('../assets/Plantation/pesticide.png'), *iconStaticSize) - textStatic = police.render("Pesticide",False, (0,0,0)) - textDescriptionStatic = police.render("Pour tuer les insectes",False,(0,0,0)) - montantAchat = 200 - def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/pesticide.png') - -#TODO : class Bussion, - -typePlantation = [Houblon,Ble,Malt,Chanvre,OrgePrintemps,OrgeHiver,Seigle,Pesticide] - +import pygame +import numpy as np +from Temps import * +from Image import transformImage +#from Infrastructure import Infrastructure +listeImage = [transformImage(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'), 120, 120) for i in range(1,5)] +iconStaticSize = (100,100) + +class Champs: + iconInsecteStatic = pygame.transform.scale(pygame.image.load("../assets/Plantation/leech.png"),(90,90)) + + def __init__ (self, temperature, humidite, tempsAvantMaturation, pos, image): + self.pourcentagePlanteFane = 10 + + self.temperature = temperature + self.humidite = humidite + self.TAM = tempsAvantMaturation + self.pos = np.array(pos) + self.image = pygame.image.load(image) + self.imageSize = np.array(self.image.get_size()) + self.rect = pygame.rect.Rect(self.pos, self.image.get_rect().size) + self.rectScale = self.rect + self.police = pygame.font.SysFont("Alef", 22) #pygame.font.get_fonts() -> liste des fonts + self.imgZoom = pygame.transform.scale(self.image, self.imageSize) + self.indiceImage = 0 + self.champZoom = pygame.rect.Rect(self.pos,self.imgZoom.get_rect().size) + self.isInfeste = False + self.bat = None + #self.infra = self.setInfrastrcture(self.pos,self.image) + + + + self.descripteurChamps = { + + } + + self.imageSurfaceinfo = { + + } + self.setInformation("Occupe" , "Champ non occupé") + self.setInformation("Nom","Champ Vide ") + self.setInformation("coutEntretien","15€ coût d'entretien mensuel") + self.setInformation("fane", "Pourcentage que la plante fanne : ") + self.setInformation(hash('fane'), str(self.pourcentagePlanteFane)+' %') + self.setInformation("status", self.image,True) + + + + def plantationGrandit(self): + self.indiceImage += 1 + if self.indiceImage < 4: + self.imageChamp = listeImage[self.indiceImage] + else: + if(self.indiceImage == 4): + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/damage.png'), 120, 120) + elif(self.indiceImage == 5): + self.isInfeste = False + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/fanne.png'), 120, 120) + """ + def setInfrastrcture(self,pos,image): + return Infrastructure(pos,image) + """ + def draw (self, screen, camera): + scaleImage = camera.scaleImage(self.image) + + if scaleImage: # != None + self.imgZoom = scaleImage + self.rectScale = pygame.rect.Rect(camera.convertLocation(self.pos), self.imgZoom.get_size()) + + + + screen.blit(self.imgZoom, camera.convertLocation(self.pos)) + if hasattr(self,'imageChamp'): + scaleChamp = camera.scaleImage(self.imageChamp) + if scaleChamp: + self.champZoom = scaleChamp + varlongueur = camera.convertLocation(self.pos) + self.rectChampScal = pygame.rect.Rect(varlongueur, self.champZoom.get_size()) + screen.blit( + self.champZoom, + ( + varlongueur[0] + + (self.rectScale.w-self.rectChampScal.w) + /2, + varlongueur[1] + + (self.rectScale.h-self.rectChampScal.h) + /2) + ) + + if(self.isInfeste): + scaleInfecte = camera.scaleImage(Champs.iconInsecteStatic) + if scaleInfecte: + self.infecteZoom = scaleInfecte + varlongueur = camera.convertLocation(self.pos) + self.rectScalInfecte = pygame.rect.Rect(varlongueur, self.infecteZoom.get_size()) + screen.blit( + self.infecteZoom, + ( + varlongueur[0] + + (self.rectScale.w-self.rectScalInfecte.w) + /2, + varlongueur[1] + + (self.rectScale.h-self.rectScalInfecte.h) + /2) + ) + + def changeText (self, camera): + scaleText = camera.scaleImage(self.text) + if scaleText: + self.zoomText = scaleText + + def setInformation(self,clef,valeur,isImage = False): + self.descripteurChamps[clef] = valeur + if isImage : + self.imageSurfaceinfo[clef] = valeur + else : + self.imageSurfaceinfo[clef] = police.render(str(valeur),True,(0,0,0)) + + def showInfo(self,screen,rectangle,bat = {}): + i = 0 + for k,v in self.descripteurChamps.items(): + screen.blit(self.imageSurfaceinfo[k],(rectangle.x,rectangle.y + i)) + i += 30 + + +class Buisson (Champs): + def __init__ (self, pos, prix = 9000): + super().__init__(0, 0, 0, pos, '../assets/Interface/buissonCadenas.png') + self.prix = prix + self.text = self.police.render("Champ disponible à l'achat : " + str(self.prix), False, (0,0,0)) + self.zoomText = self.text + + def showInfo (self, screen,rectangle): + screen.blit(self.text,(rectangle.x,rectangle.y)) + + def buyField (self): + return TerrainVide(self.pos) + + +class TerrainVide(Champs): + def __init__ (self, pos): + super().__init__(0, 0, 0, pos,'../assets/Plantation/champ.png') + self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) + self.zoomText = self.text + + + +class Houblon (Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/houblon.png'), *iconStaticSize) + textStatic = police.render('Houblon',False, (255,255,255)) + textDescriptionStatic = police.render("Houblon ça marche bien",False,(0,0,0)) + montantAchat = 300 + montantVente = 1200 + def __init__ (self, pos): + super().__init__(0, 0, 0, pos,'../assets/Plantation/champ.png') + self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) + self.zoomText = self.text + + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class Ble (Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/wheat.png'), *iconStaticSize) + textStatic = police.render('Ble',False, (255,255,255)) + textDescriptionStatic = police.render("Ble ça marche bien",False,(0,0,0)) + montantAchat = 300 + montantVente = 1200 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') + + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + +class Malt (Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/malt.png'), *iconStaticSize) + textStatic = police.render('Malt',False, (255,255,255)) + textDescriptionStatic = police.render("Malt ça marche bien",False,(0,0,0)) + montantAchat = 400 + montantVente = 1600 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class Chanvre(Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/weed.png'), *iconStaticSize) + textStatic = police.render("Chanvre",False, (255,255,255)) + textDescriptionStatic = police.render("Pour des spaces bières",False,(0,0,0)) + montantAchat = 1000 + montantVente = 4000 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets//Plantation/champ.png') + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class OrgeHiver(Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/orge.png'), *iconStaticSize) + textStatic = police.render("Orge hiver",False, (255,255,255)) + textDescriptionStatic = police.render("Orge hiver ça marche bien",False,(0,0,0)) + montantAchat = 400 + montantVente = 1600 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class OrgePrintemps(Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/OrgePrintemps.png'), *iconStaticSize) + textStatic = police.render("Orge printemps",False, (255,255,255)) + textDescriptionStatic = police.render("Orge printemps ça marche bien",False,(0,0,0)) + montantAchat = 500 + montantVente = 2000 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') + + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class Seigle(Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/seigle.png'), *iconStaticSize) + textStatic = police.render("Seigle",False, (255,255,255)) + textDescriptionStatic = police.render("Seigle ça marche bien",False,(0,0,0)) + montantAchat = 200 + montantVente = 800 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) + + +class Pesticide(Champs): + iconStatic = transformImage(pygame.image.load('../assets/Plantation/pesticide.png'), *iconStaticSize) + textStatic = police.render("Pesticide",False, (255,255,255)) + textDescriptionStatic = police.render("Pour tuer les insectes",False,(0,0,0)) + montantAchat = 200 + def __init__ (self,pos): + super().__init__(0,0,0,pos,'../assets/Plantation/pesticide.png') + +#TODO : class Bussion, + +typePlantation = [Houblon,Ble,Malt,Chanvre,OrgePrintemps,OrgeHiver,Seigle,Pesticide] + \ No newline at end of file diff --git a/src/Game.py b/src/Game.py index aeb67043aec0c1e3b89f86e50004a499845b0c3a..f2e591c46057af3ada51f84fc21893e993215759 100644 --- a/src/Game.py +++ b/src/Game.py @@ -439,10 +439,10 @@ class Game: cout = 0 # Entretien des batiments pendant 3 mois if self.nombreBatiments > 0: - cout += (-117 * self.nombreBatiments) * 3 + cout += (-30 * self.nombreBatiments) * 3 # Entretien des champs pendant 3 mois if self.nombreChamps > 0: - cout += (-90 * self.nombreChamps) * 3 + cout += (-15 * self.nombreChamps) * 3 self.moneyDefile(cout) diff --git a/src/Infrastructure.py b/src/Infrastructure.py index a7e27a55f43c6385db97a7009875f9df32ad8a92..4ab3f19bbd7518fd6f4bd3f6fba7170c5ecf9de9 100644 --- a/src/Infrastructure.py +++ b/src/Infrastructure.py @@ -20,7 +20,7 @@ class Infrastructure: } self.setInformation("Occupe", "Espace non occupé") self.setInformation("Nom","Emplacement vide") - self.setInformation("coutEntretien","117€ d'entretien mensuel") + self.setInformation("coutEntretien","30€ d'entretien mensuel") self.setInformation("status", self.iconStatic,True) @@ -64,7 +64,7 @@ class Infrastructure: def verifDureeVie(self): self.indiceDureeVie +=1 - if(self.indiceDureeVie == 8): + if(self.indiceDureeVie == 20): return True else: return False @@ -79,9 +79,9 @@ class Infrastructure: class Puit (Infrastructure): NameObjet = " puit" iconStatic = pygame.transform.scale(pygame.image.load('../assets/Batiment/puit.png'),(150,150)) - textStatic = police.render('Puits',False, (0,0,0)) + textStatic = police.render('Puits',False, (255,255,255)) textDescriptionStatic = police.render("Moins efficace qu'un reservoir d'eau",False,(0,0,0)) - montantAchat = 2000 + montantAchat = 1000 def __init__ (self,pos): super().__init__(pos,'../assets/Plantation/champ.png') self.imagebat = pygame.transform.scale(pygame.image.load('../assets/Batiment/puit.png'),(120,120)) @@ -89,9 +89,9 @@ class Puit (Infrastructure): class ReservoirEau (Infrastructure): NameObjet = " réservoir à eau" iconStatic = pygame.transform.scale(pygame.image.load('../assets/Batiment/storagetank.png'),(150,150)) - textStatic = police.render('Capteur eau de pluie',False, (0,0,0)) + textStatic = police.render('Capteur eau de pluie',False, (255,255,255)) textDescriptionStatic = police.render("Permet de capturer l'eau de pluit",False,(0,0,0)) - montantAchat = 3000 + montantAchat = 2000 def __init__ (self,pos): super().__init__(pos,'../assets/Plantation/champ.png') self.imagebat = pygame.transform.scale(pygame.image.load('../assets/Batiment/storagetank.png'),(120,120)) @@ -99,9 +99,9 @@ class ReservoirEau (Infrastructure): class Irrigation (Infrastructure): NameObjet = " irrigation" iconStatic = pygame.transform.scale(pygame.image.load('../assets/Batiment/irrigation.png'),(150,150)) - textStatic = police.render('Arrosoir automatique ',False, (0,0,0)) + textStatic = police.render('Arrosoir automatique ',False, (255,255,255)) textDescriptionStatic = police.render("Permet d'arroser les plantes",False,(0,0,0)) - montantAchat = 5000 + montantAchat = 3000 def __init__ (self,pos): super().__init__(pos,'../assets/Plantation/champ.png') self.imagebat = pygame.transform.scale(pygame.image.load('../assets/Batiment/irrigation.png'),(90,90)) @@ -140,9 +140,9 @@ class Irrigation (Infrastructure): class IrrigationGoutte (Infrastructure): NameObjet = " irrigation goutte à goutte" iconStatic = pygame.transform.scale(pygame.image.load('../assets/Batiment/irrigationGoutte.png'),(150,150)) - textStatic = police.render('Système goutte à goutte',False, (0,0,0)) + textStatic = police.render('Système goutte à goutte',False, (255,255,255)) textDescriptionStatic = police.render("Permet d'arroser les plantes en économisant l'eau",False,(0,0,0)) - montantAchat = 10000 + montantAchat = 6000 def __init__ (self,pos): super().__init__(pos,'../assets/Plantation/champ.png') self.imagebat = pygame.transform.scale(pygame.image.load('../assets/Batiment/irrigationGoutte.png'),(90,90)) @@ -175,9 +175,9 @@ class Serre (Infrastructure): NameObjet = " serre" iconoriginal = pygame.image.load('../assets/Batiment/serre.png') iconStatic = pygame.transform.scale(iconoriginal,(150,150)) - textStatic = police.render('Serre',False, (0,0,0)) + textStatic = police.render('Serre',False, (255,255,255)) textDescriptionStatic = police.render("Permet de proteger les cultures du froid et de la chaleur",False,(0,0,0)) - montantAchat = 1500 + montantAchat = 1000 iconStaticCopie = pygame.transform.scale(iconoriginal.copy(), (250,200)) @@ -207,14 +207,14 @@ class Torche (Infrastructure): NameObjet = " torche" iconoriginal = pygame.image.load('../assets/Batiment/torche.png') iconStatic = pygame.transform.scale(pygame.image.load('../assets/Batiment/torche.png'),(150,150)) - textStatic = police.render('Torche',False, (0,0,0)) + textStatic = police.render('Torche',False, (255,255,255)) textDescriptionStatic = police.render("Permet de proteger les cultures du froid ",False,(0,0,0)) iconStaticCopie = pygame.transform.scale(iconoriginal.copy(), (250,200)) iconStaticCopie.fill((255, 255, 255, 70), None, pygame.BLEND_RGBA_MULT) - montantAchat = 1000 + montantAchat = 750 def __init__ (self,pos): super().__init__(pos,'../assets/Plantation/champ.png') self.zoneafecte = None diff --git a/src/T3.py b/src/T3.py old mode 100755 new mode 100644 index e01783088b332b05c52bfd24ee0f5ff190eaea6c..f9137f112dcb6998cd0ce44bc0085ed0e53f1c9a --- a/src/T3.py +++ b/src/T3.py @@ -1,52 +1,52 @@ -import pygame -pygame.init() - -from datetime import date -import Game - - -pygame.display.set_caption("Climate Simulator : Global Organization") -screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN) - -#on récupère le mois actuelle pour le faire commencer à ce moment -class month: - def __init__ (self, str): - self.month = str - -current_month = month(date.today().strftime("%b")) - -#background (2è scène) -background = pygame.image.load('../assets/Interface/intro.webp') -background = pygame.transform.scale(background, (screen.get_width(), screen.get_height())) - -#bouton -play_button = pygame.image.load('../assets/Interface/button.png') -play_button = pygame.transform.scale(play_button,(400,150)) -play_button_rect = play_button.get_rect() -play_button_rect.x = screen.get_width() / 2 - play_button.get_width()/2 -play_button_rect.y = screen.get_height() / 2 - play_button.get_height()/2 - -#buisson -#bush = pygame.image.load('../assets/buisson.png') - -#cadenas -#lock = pygame.image.load('../assets/cadenas.png') - -screen.blit(background, (0,0)) -screen.blit(play_button, play_button_rect) - -#screen.blit(bush, (100,100)) -#screen.blit(lock, (bush.get_width()/2,bush.get_height()/2+40)) - -pygame.display.update() - -inMenu = True -while inMenu: - for event in pygame.event.get(): - if event.type == pygame.MOUSEBUTTONDOWN and play_button_rect.contains(*event.pos,0,0): - inMenu = False - elif event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: - exit(0) - -# à l'appui du bouton start +import pygame +pygame.init() + +from datetime import date +import Game + + +pygame.display.set_caption("Climate Simulator : Global Organization") +screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN) + +#on récupère le mois actuelle pour le faire commencer à ce moment +class month: + def __init__ (self, str): + self.month = str + +current_month = month(date.today().strftime("%b")) + +#background (2è scène) +background = pygame.image.load('../assets/Interface/intro.webp') +background = pygame.transform.scale(background, (screen.get_width(), screen.get_height())) + +#bouton +play_button = pygame.image.load('../assets/Interface/button.png') +play_button = pygame.transform.scale(play_button,(400,150)) +play_button_rect = play_button.get_rect() +play_button_rect.x = screen.get_width() / 2 - play_button.get_width()/2 +play_button_rect.y = screen.get_height() / 2 - play_button.get_height()/2 + +#buisson +#bush = pygame.image.load('../assets/buisson.png') + +#cadenas +#lock = pygame.image.load('../assets/cadenas.png') + +screen.blit(background, (0,0)) +screen.blit(play_button, play_button_rect) + +#screen.blit(bush, (100,100)) +#screen.blit(lock, (bush.get_width()/2,bush.get_height()/2+40)) + +pygame.display.update() + +inMenu = True +while inMenu: + for event in pygame.event.get(): + if event.type == pygame.MOUSEBUTTONDOWN and play_button_rect.contains(*event.pos,0,0): + inMenu = False + elif event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: + exit(0) + +# à l'appui du bouton start Game.Game().gameLoop() \ No newline at end of file diff --git a/src/Temps.py b/src/Temps.py old mode 100755 new mode 100644 index 7147f542e151afb1110b94237d7c391fa98d7b43..b26546433b983aaefcb23093dcb87e6dcbdb0191 --- a/src/Temps.py +++ b/src/Temps.py @@ -1,190 +1,189 @@ -import random -import pygame -from Image import transformImage -from random import triangular -police = pygame.font.SysFont("Alef", 30) -police2 = pygame.font.SysFont("Alef", 20) - -""" -climats = { - "janvier" : { - "temp" : [2,7.8], - "humidité" : [78,90] - }, - "février" : { - "temp" : [4.5,11.8], - "humidité" : [60,85] - }, - "mars" : { - "temp" : [3.7,13.7], - "humidité" : [45,90] - }, - "avril" : { - "temp" : [15.4,4.7], - "humidité" : [42,76] - }, - "mai" : { - "temp" : [18.1,8.7], - "humidité" : [43,80] - }, - "juin" : { - "temp" : [24.5,14.6], - "humidité" : [60,84] - }, - "juillet" : { - "temp" : [24.9,15.5], - "humidité" : [45,84] - }, - "août" : { - "temp" : [24.6,14.8], - "humidité" : [64,81] - }, - "septembre" : { - "temp" : [24,14], - "humidité" : [58,90] - }, - "octobre" : { - "temp" : [18.3,8.6], - "humidité" : [70, 89] - }, - "novembre" : { - "temp" : [11.3,4.9], - "humidité" : [75,99] - }, - "décembre" : { - "temp" : [10.3,3.8], - "humidité" : [77,99] - } - - } -""" - -class Temps: - climats = { - "Automne" : { - "temp" : [4.8,13.3], - "humidité" : [70,95] - - }, - "Hiver" : { - "temp" : [-5,10.3], - "humidité" : [50,90] - }, - "Printemps" : { - "temp" : [13,27], - "humidité" : [40,90] - }, - "été" : { - "temp" : [25,40], - "humidité" : [40,96] - } - } - - def __init__(self): - self.ListTemps = ["neige","orage","pluie","ensoleillee","vent","secheresse","canicule","froid","chaud"] - - self.indice = 2 - self.currentSeason = self.getSaisonName(self.indice) - self.globaltemp = self.tirageTemperature(self.currentSeason) - self.humidite = self.tirageAuSortChiffreIntervallehumidite(self.currentSeason) - self.currentTemps = self.tempAAfficher(self.currentSeason,self.tirageTemps()) - self.currentTempsName = self.decoupage(self.currentTemps) - self.temps = pygame.image.load(self.currentTemps) - self.iconSaison = transformImage(self.temps,200,200) - self.nextSeason = self.getSaisonName(self.indice+1) - - self.nextglobalTemps = self.tirageTemperature(self.nextSeason) - self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) - self.nextTemps = self.tempAAfficher(self.nextSeason,self.tirageTemps()) - self.nextTempsName = self.decoupage(self.nextTemps) - self.nextTempsImage = pygame.image.load(self.nextTemps) - self.nexticonSaison = transformImage(self.nextTempsImage,100,100) - - self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,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(): - self.climats.get(key)['image'] = transformImage(pygame.image.load("../assets/Saison/"+key+".png"),400,300) - - - - def NextTurn(self): - #Le next qui devien current - self.indice += 1 - self.currentSeason = self.nextSeason - self.globaltemp = self.nextglobalTemps - self.humidite = self.nexthumidite - self.temps = self.nextTempsImage - self.currentTemps = self.nextTemps - self.currentTempsName = self.nextTempsName - self.iconSaison = self.nexticonSaison - self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) - - #Nouveau turn - - self.nextSeason = self.getSaisonName(self.indice+1) - self.nextglobalTemps = self.tirageTemperature(self.nextSeason) - self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) - self.nextTemps = self.tempAAfficher(self.nextSeason,self.tirageTemps()) - self.nextTempsName = self.decoupage(self.nextTemps) - self.nextTempsImage = pygame.image.load(self.nextTemps) - self.nexticonSaison = transformImage(self.nextTempsImage,100,100) - - self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) - - def getSaisonName(self,indice:int)->str: - return list(self.climats.keys())[indice%4] - - def tirageTemperature(self,clef): - #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 - - intervalle = self.getClimatTemp(clef) - """ - randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] - return randomNombre - """ - return random.triangular(low = intervalle[0],high = intervalle[1]) - - def tirageAuSortChiffreIntervallehumidite(self,clef): - #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 - intervalle = self.getClimatHumidite(clef) - - #randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] - return random.triangular(low = intervalle[0],high = intervalle[1]) - - def tirageTemps(self): - nbrandom = random.randint(0,len(self.ListTemps)-1) - return self.ListTemps[nbrandom] - - def tempAAfficher(self, saison,temps:str)-> str: - #Determination du temps a afficher - if saison == "Automne" and temps not in ["secheresse","canicule","chaud"]: - return str("../assets/Temps/"+temps+".png") - elif saison == "Hiver" and temps not in ["secheresse","canicule","chaud"]: - return str("../assets/Temps/"+temps+".png") - elif saison == "Printemps" and temps not in ["secheresse","canicule","neige","froid"]: - return str("../assets/Temps/"+temps+".png") - elif saison == "été" and temps not in ["froid","neige"]: - return str("../assets/Temps/"+temps+".png") - else: - return self.tempAAfficher(saison,self.tirageTemps()) - - - def decoupage(self,chaine): - return chaine.split('/')[3][:-4] - - def getClimatTemp(self,clef): - return self.climats[clef]["temp"] - - def getClimatHumidite(self,clef): - return self.climats[clef]["humidité"] - - def getcurrentSeason(self): - return self.currentSeason - - def getImageSaison(self): - return self.climats.get(self.currentSeason).get('image') - - - \ No newline at end of file +import random +import pygame +from Image import transformImage +from random import triangular +police = pygame.font.SysFont("Alef", 30) +police2 = pygame.font.SysFont("Alef", 20) + +""" +climats = { + "janvier" : { + "temp" : [2,7.8], + "humidité" : [78,90] + }, + "février" : { + "temp" : [4.5,11.8], + "humidité" : [60,85] + }, + "mars" : { + "temp" : [3.7,13.7], + "humidité" : [45,90] + }, + "avril" : { + "temp" : [15.4,4.7], + "humidité" : [42,76] + }, + "mai" : { + "temp" : [18.1,8.7], + "humidité" : [43,80] + }, + "juin" : { + "temp" : [24.5,14.6], + "humidité" : [60,84] + }, + "juillet" : { + "temp" : [24.9,15.5], + "humidité" : [45,84] + }, + "août" : { + "temp" : [24.6,14.8], + "humidité" : [64,81] + }, + "septembre" : { + "temp" : [24,14], + "humidité" : [58,90] + }, + "octobre" : { + "temp" : [18.3,8.6], + "humidité" : [70, 89] + }, + "novembre" : { + "temp" : [11.3,4.9], + "humidité" : [75,99] + }, + "décembre" : { + "temp" : [10.3,3.8], + "humidité" : [77,99] + } + + } +""" + +class Temps: + climats = { + "Automne" : { + "temp" : [4.8,13.3], + "humidité" : [70,95] + + }, + "Hiver" : { + "temp" : [-5,10.3], + "humidité" : [50,90] + }, + "Printemps" : { + "temp" : [13,27], + "humidité" : [40,90] + }, + "été" : { + "temp" : [25,40], + "humidité" : [40,96] + } + } + + def __init__(self): + self.ListTemps = ["neige","orage","pluie","ensoleillee","vent","secheresse","canicule","froid","chaud"] + + self.indice = 2 + self.currentSeason = self.getSaisonName(self.indice) + self.globaltemp = self.tirageTemperature(self.currentSeason) + self.humidite = self.tirageAuSortChiffreIntervallehumidite(self.currentSeason) + self.currentTemps = self.tempAAfficher(self.currentSeason,self.tirageTemps()) + self.currentTempsName = self.decoupage(self.currentTemps) + self.temps = pygame.image.load(self.currentTemps) + self.iconSaison = transformImage(self.temps,200,200) + self.nextSeason = self.getSaisonName(self.indice+1) + + self.nextglobalTemps = self.tirageTemperature(self.nextSeason) + self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) + self.nextTemps = self.tempAAfficher(self.nextSeason,self.tirageTemps()) + self.nextTempsName = self.decoupage(self.nextTemps) + self.nextTempsImage = pygame.image.load(self.nextTemps) + self.nexticonSaison = transformImage(self.nextTempsImage,100,100) + + self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,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(): + self.climats.get(key)['image'] = transformImage(pygame.image.load("../assets/Saison/"+key+".png"),400,300) + + + + def NextTurn(self): + #Le next qui devien current + self.indice += 1 + self.currentSeason = self.nextSeason + self.globaltemp = self.nextglobalTemps + self.humidite = self.nexthumidite + self.temps = self.nextTempsImage + self.currentTemps = self.nextTemps + self.currentTempsName = self.nextTempsName + self.iconSaison = self.nexticonSaison + self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) + + #Nouveau turn + + self.nextSeason = self.getSaisonName(self.indice+1) + self.nextglobalTemps = self.tirageTemperature(self.nextSeason) + self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) + self.nextTemps = self.tempAAfficher(self.nextSeason,self.tirageTemps()) + self.nextTempsName = self.decoupage(self.nextTemps) + self.nextTempsImage = pygame.image.load(self.nextTemps) + self.nexticonSaison = transformImage(self.nextTempsImage,100,100) + + self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) + + def getSaisonName(self,indice:int)->str: + return list(self.climats.keys())[indice%4] + + def tirageTemperature(self,clef): + #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 + + intervalle = self.getClimatTemp(clef) + """ + randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] + return randomNombre + """ + return random.triangular(low = intervalle[0],high = intervalle[1]) + + def tirageAuSortChiffreIntervallehumidite(self,clef): + #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 + intervalle = self.getClimatHumidite(clef) + + #randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] + return random.triangular(low = intervalle[0],high = intervalle[1]) + + def tirageTemps(self): + nbrandom = random.randint(0,len(self.ListTemps)-1) + return self.ListTemps[nbrandom] + + def tempAAfficher(self, saison,temps:str)-> str: + #Determination du temps a afficher + if saison == "Automne" and temps not in ["secheresse","canicule","chaud"]: + return str("../assets/Temps/"+temps+".png") + elif saison == "Hiver" and temps not in ["secheresse","canicule","chaud"]: + return str("../assets/Temps/"+temps+".png") + elif saison == "Printemps" and temps not in ["secheresse","canicule","neige","froid"]: + return str("../assets/Temps/"+temps+".png") + elif saison == "été" and temps not in ["froid","neige"]: + return str("../assets/Temps/"+temps+".png") + else: + return self.tempAAfficher(saison,self.tirageTemps()) + + + def decoupage(self,chaine): + return chaine.split('/')[3][:-4] + + def getClimatTemp(self,clef): + return self.climats[clef]["temp"] + + def getClimatHumidite(self,clef): + return self.climats[clef]["humidité"] + + def getcurrentSeason(self): + return self.currentSeason + + def getImageSaison(self): + return self.climats.get(self.currentSeason).get('image') + +