diff --git a/Linux-Mac/README.md b/Linux-Mac/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5d7be4c0418476ab896f288f94894c38464558bb --- /dev/null +++ b/Linux-Mac/README.md @@ -0,0 +1,17 @@ +# Guide d'installation 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 +``` \ No newline at end of file diff --git a/Linux-Mac/requirements.txt b/Linux-Mac/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f6c8437a8dae9d2e18ce527adaa394f0a6f94ee --- /dev/null +++ b/Linux-Mac/requirements.txt @@ -0,0 +1 @@ +pygame==2.1.2 \ No newline at end of file diff --git a/README.md b/README.md index 0365f26bacf649722fc6c5c851cf395410baf951..d23c3fa752aab9471e76fe5611311717d1805576 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,106 @@ -# Climate Simulator Global Organization +# T3 +Nom du groupe : Climate Simulator Global Organization +Code du groupe : BOG22-D +Participants : +- Léo Duchmann +- Emir Sinanovic +- Damien Kalck -## Getting started +## Méta-Todo -To make it easy for you to get started with GitLab, here's a list of recommended next steps. +- [x] Mettre en place son GIT et préparer les milestones +- [x] Acquérir le sujet et définir un objectif pédagogique +- [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 +- [x] Développer ces fonctionnalités +- [x] Evaluation à mi-parcours (Octobre) +- [x] Tester et équilibrer +- [x] Choisir la Licence (Novembre) +- [x] Finaliser le git et produire la documentation +- [x] Présenter son jeu et le faire évaluer (Décembre) -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +## Objectif pédagogique -## Add your files +L'objectif pédagogique de ce jeu sérieux est d'apprendre à gérer une culture agricole en fonction du climat, afin de s'adapter au changement climatique que subit notre planète. -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: +## Type de jeu et mécanismes d'apprentissage -``` -cd existing_repo -git remote add origin https://git.unistra.fr/l.duchmann/climate-simulator-global-organization.git -git branch -M main -git push -uf origin main -``` +Type : Jeu de gestion d'exploitation agricole en Point & Click + +Mécanismes d'apprentissage : +- Gestion de budget d'exploitation +- Choix de graines à planter +- Achat d'infrastructure agricole (ex: Serre, Puit) +- Défense contre les organismes indésirables +- Protection et exploitation du climat -## Integrate with your tools +## Liste des principales fonctionnalités -- [ ] [Set up project integrations](https://git.unistra.fr/l.duchmann/climate-simulator-global-organization/-/settings/integrations) +Créer une issue par fonctionnalités. -## Collaborate with your team +- [x] Gestion de l'argent +- [x] Conséquences météorologiques +- [x] Gestion du bien-être des plantes +- [x] Cycle des saisons -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +## Justification du choix de la Licence -## Test and Deploy +Contrat De Licence D’utilisateur Final -Use the built-in continuous integration in GitLab. -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +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. -# Editing this README +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 : -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. +I – Ne pas copier, décompiler, vendre ou reproduire le jeu ou son code source -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +II – Ne pas utiliser notre jeu dans un domaine autre qu’éducatif -## Name -Choose a self-explaining name for your project. +III – Interdiction d’utiliser les licences concédées à des fins commerciales -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. +Nous pouvons suspendre ou résilier votre licence d'utilisation pour non-conformité aux clauses ci-dessus. -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +## Lien de téléchargement -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +## Captures d'écran -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +Écran de départ + +Écran de jeu + +Plante infécté + +Plante morte + -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +## Procédures d'installation et d'exécution -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +Pour Linux et Mac : -## Contributing -State if you are open to contributions and what your requirements are for accepting them. +Pré-requis : -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. +- 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` -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +Jouer au jeu + +```sh +cd ../src/ +py T3.py +``` -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +## Pour les développeurs -## License -For open source projects, say how it is licensed. +Le projet a été créé avec Python 3.9 (fonctionne avec 3.10) -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +La seule librairie nécessaire est pygame diff --git a/WIKI.md b/WIKI.md new file mode 100644 index 0000000000000000000000000000000000000000..49262492757712e123eadd99c56084d20b420bc6 --- /dev/null +++ b/WIKI.md @@ -0,0 +1,23 @@ +## Sous-ensembles pédagogiques + +Malgré que le jeu se base sur le climat affectant l'agriculture, il y a de nombreux sous-ensembles pédagogiques proposés au sein du jeu : +- Gérer l'argent disponible afin de ne pas être en déficit +- Optimiser les plantations avec les infrastructures afin que celles-ci ne fanent pas à cause des changements climatiques + +## Description du jeu + +Vous êtes dans la peau d'un agriculteur. Vous allez découvrir au sein de ce jeu les différents problèmes auxquels font face les agriculteurs dû aux changements climatiques. +Type de jeu simple, avec une interface 2D, dont tous les éléments du jeu seront visibles en permanence à l'écran. + +## Actions du joueur + +Toutes les actions possibles sont evidemment liées à celles que ferait un agriculteur. +Le joueur pourra acheter des champs, planter différents types de culture avec un drag and drop, de même que pour acheter des infrastructures permettant de faire face aux problèmes. + +## Informations en jeu + +La partie droite de l'écran donnera des informations concernant le champ, la plante, ou l'infrasctructure sur laquelle vous placez le pointeur de la souris. + +L'argent est placée en-haut à droite, vous verrez en temps réel combien vous gagnez ou combien vous perdez. +Concernant l'argent, pour perderez une somme à chaque fin de saison correspondant à l'entretien des champs (en fonction du nombre de champs actuellement achetés) et l'entretien des bâtiments (en fonction du nombre de bâtiments actuellement achetés). +De plus, vous reçeverez 5000€ chaque Hiver correspondant aux aides de l'Etat. 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/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') + +