small refactoring

This commit is contained in:
Dawid Pylak 2022-06-05 13:45:29 +02:00
parent 921aeec597
commit ffbb2f7187
4 changed files with 36 additions and 17 deletions

View File

@ -5,7 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.9 (Inteligentny_Traktor_Grupa_16)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (ai-project)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (Inteligentny_Traktor_Grupa_16)" project-jdk-type="Python SDK" />
</project>

View File

@ -8,3 +8,20 @@ class Constants:
LEFT = [-1, 0]
ROTATE_RIGHT = "rotate_right"
ROTATE_LEFT = "rotate_left"
# Technical terms
WATER_STATE = 'stan_nawodnienia'
SOIL_TYPE = 'rodzaj_gleby'
FERTILIZATION_STATUS = 'stan_nawiezienia'
GROWTH_LEVEL = 'stopien_rozwoju'
PLANT_TYPE = 'rodzaj_rosliny'
FERTILISER_TYPE = 'rodzaj_nawozu'
TO_WATER = 'to_water'
# Plants
NONE = 'brak'
CACTUS = 'kaktus'
POTATO = 'ziemniak'
WEATH = 'pszenica'

View File

@ -1,4 +1,6 @@
import pygame
from constants import Constants
from src.tile import Tile
@ -39,29 +41,29 @@ class World:
if tile == 1:
type = 'farm' # type farm mówimy nam ogólnie, ze jest to pole uprawne, szczegóły rośliny potem
cost = 100000
stan_nawodnienia = self.model.df.iloc[df_idx]['stan_nawodnienia']
rodzaj_gleby = self.model.df.iloc[df_idx]['rodzaj_gleby']
stan_nawiezienia = self.model.df.iloc[df_idx]['stan_nawiezienia']
stopien_rozwoju = self.model.df.iloc[df_idx]['stopien_rozwoju']
rodzaj_rosliny = self.model.df.iloc[df_idx]['rodzaj_rosliny']
rodzaj_nawozu = self.model.df.iloc[df_idx]['rodzaj_nawozu']
to_water = self.model.df.iloc[df_idx]['to_water']
stan_nawodnienia = self.model.df.iloc[df_idx][Constants.WATER_STATE]
rodzaj_gleby = self.model.df.iloc[df_idx][Constants.SOIL_TYPE]
stan_nawiezienia = self.model.df.iloc[df_idx][Constants.FERTILIZATION_STATUS]
stopien_rozwoju = self.model.df.iloc[df_idx][Constants.GROWTH_LEVEL]
rodzaj_rosliny = self.model.df.iloc[df_idx][Constants.PLANT_TYPE]
rodzaj_nawozu = self.model.df.iloc[df_idx][Constants.FERTILISER_TYPE]
to_water = self.model.df.iloc[df_idx][Constants.TO_WATER]
if to_water == 0 and rodzaj_rosliny == 'brak':
if to_water == 0 and rodzaj_rosliny == Constants.NONE:
img = pygame.transform.scale(self.farmland_empty, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 0 and rodzaj_rosliny == 'kaktus':
elif to_water == 0 and rodzaj_rosliny == Constants.CACTUS:
img = pygame.transform.scale(self.farmland_cactus, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 0 and rodzaj_rosliny == 'pszenica':
elif to_water == 0 and rodzaj_rosliny == Constants.WEATH:
img = pygame.transform.scale(self.farmland_wheat, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 0 and rodzaj_rosliny == 'ziemniak':
elif to_water == 0 and rodzaj_rosliny == Constants.POTATO:
img = pygame.transform.scale(self.farmland_potato, (self.settings.tile_size, self.settings.tile_size))
if to_water == 1 and rodzaj_rosliny == 'brak':
if to_water == 1 and rodzaj_rosliny == Constants.NONE:
img = pygame.transform.scale(self.dirt_empty, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 1 and rodzaj_rosliny == 'kaktus':
elif to_water == 1 and rodzaj_rosliny == Constants.CACTUS:
img = pygame.transform.scale(self.dirt_cactus, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 1 and rodzaj_rosliny == 'pszenica':
elif to_water == 1 and rodzaj_rosliny == Constants.WEATH:
img = pygame.transform.scale(self.dirt_wheat, (self.settings.tile_size, self.settings.tile_size))
elif to_water == 1 and rodzaj_rosliny == 'ziemniak':
elif to_water == 1 and rodzaj_rosliny == Constants.POTATO:
img = pygame.transform.scale(self.dirt_potato, (self.settings.tile_size, self.settings.tile_size))
df_idx += 1