diff --git a/.idea/misc.xml b/.idea/misc.xml index 8d93904..6c75bb3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/source/area/constants.py b/source/area/constants.py index 99a9fcd..1aff5be 100644 --- a/source/area/constants.py +++ b/source/area/constants.py @@ -3,7 +3,7 @@ import pygame WIDTH, HEIGHT = 1000, 1000 FIELD_WIDTH, FIELD_HEIGHT = 660, 330 -ROWS, COLS = 10, 5 +ROWS, COLS = 20, 20 # number of tiles in a row and column TILE_SIZE = FIELD_WIDTH//ROWS PLANT = "" diff --git a/source/area/field.py b/source/area/field.py index a17e679..99f57bd 100644 --- a/source/area/field.py +++ b/source/area/field.py @@ -21,10 +21,9 @@ def positionFieldElements(): tractor.y += fieldY def createTiles(): - for y in range (0,COLS): - for x in range (0,ROWS): + for y in range(0, COLS): + for x in range(0, ROWS): tile = Tile(x*TILE_SIZE, y*TILE_SIZE) - tile.randomize_photo() tile.randomizeContent() tiles.append(tile) positionFieldElements() diff --git a/source/area/tractor.py b/source/area/tractor.py index 5e1c355..71b0380 100644 --- a/source/area/tractor.py +++ b/source/area/tractor.py @@ -2,8 +2,23 @@ class Tractor: x = None y = None image = None + # etc - def __init__(self,x,y): + def __init__(self, x, y): self.x = x self.y = y self.image = 'resources/images/tractor.png' + + def work_on_field(self, ground, plant): + if plant is None: + pass # zasadz cos + if ground.pest == True: + # traktor pozbywa sie szkodnikow + ground.pest = False + if ground.weed == True: + # traktor pozbywa się chwastow + ground.weed = False + if ground.water < plant.water_requirements: + ground.water += 20 + if ground.nutrients < plant.nutrients_requirements: + ground.nutrients += 20 diff --git a/source/crop_protection_product.py b/source/crop_protection_product.py new file mode 100644 index 0000000..941d36e --- /dev/null +++ b/source/crop_protection_product.py @@ -0,0 +1,3 @@ +class CropProtectionProduct: + def __init__(self, strong_against): + self.strong_against = strong_against # pestycyd, herbicyd diff --git a/source/ground.py b/source/ground.py index a564c4c..ccd1292 100644 --- a/source/ground.py +++ b/source/ground.py @@ -1,6 +1,26 @@ +import random + + class Dirt: - state = None + def __init__(self, water_level, nutrients_level): + self.water_level = water_level + self.nutrients_level = nutrients_level + self.pest = False + self.weed = False + self.obstacle = False + self.pests_and_weeds() # add a couple new properties -# add init, getters,setters + def pests_and_weeds(self): + i = random.randint(1, 20) # 5% szans na szkodniki, 10% na chwasty, 5 na obydwa 15 na kamien + if i == 1: + self.pest = True + elif i == 2 or i == 3: + self.weed = True + elif i == 4: + self.weed = True + self.pest = True + elif i == 5 or i == 6 or i == 7: + self.obstacle = True +# add init, getters,setters diff --git a/source/plant.py b/source/plant.py index 39f1a6c..1488bd0 100644 --- a/source/plant.py +++ b/source/plant.py @@ -1,8 +1,22 @@ +import random + class Plant: - name = None + def __init__(self, name, plant_type, water_requirements, nutrients_requirements, growth_level): + self.name = name + self.plant_type = plant_type + self.water_requirements = water_requirements + self.nutrients_requirements = nutrients_requirements + self.growth_level = growth_level + + def try_to_grow(self, water, nutrients): + if (water >= self.water_requirements) and (nutrients >= self.nutrients_requirements): + i = random.randint(5, 12) + if self.growth_level+i > 100: + i = self.growth_level - 100 + self.growth_level += i + # more properties # add init, getters,setters - diff --git a/source/tile.py b/source/tile.py index 1971f7f..fb813ea 100644 --- a/source/tile.py +++ b/source/tile.py @@ -1,7 +1,7 @@ import random import os -#path to plant images folder (used in randomize_photo function) +# path to plant images folder (used in randomize_photo function) folder_path = "resources\images\plant_photos" @@ -26,7 +26,7 @@ class Tile: # called on a created tile - #choose random photo from the folder: + # choose random photo from the folder: def randomize_photo(self): random_photo = random.choice(os.listdir(folder_path)) @@ -39,7 +39,7 @@ class Tile: if i == 1: self.image = "resources/images/sampling.png" self.photo = photo_path - #self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu + # self.photo losuje dodatkowo zdjecie jakies rosliny do danego rzędu else: self.image = "resources/images/dirt.png" self.photo = "resources/images/background.jpg"