diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2293f7d..2a7a549 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,6 +3,13 @@
+
+
+
+
+
+
+
@@ -98,6 +105,7 @@
+
@@ -105,22 +113,22 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -137,12 +145,12 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/__pycache__/definitions.cpython-37.pyc b/__pycache__/definitions.cpython-37.pyc
index 3a029ae..84429b8 100644
Binary files a/__pycache__/definitions.cpython-37.pyc and b/__pycache__/definitions.cpython-37.pyc differ
diff --git a/__pycache__/field.cpython-37.pyc b/__pycache__/field.cpython-37.pyc
index b6088e3..e303512 100644
Binary files a/__pycache__/field.cpython-37.pyc and b/__pycache__/field.cpython-37.pyc differ
diff --git a/__pycache__/map.cpython-37.pyc b/__pycache__/map.cpython-37.pyc
index c77bf29..7e8fb74 100644
Binary files a/__pycache__/map.cpython-37.pyc and b/__pycache__/map.cpython-37.pyc differ
diff --git a/__pycache__/plant.cpython-37.pyc b/__pycache__/plant.cpython-37.pyc
index 66788e1..cf65735 100644
Binary files a/__pycache__/plant.cpython-37.pyc and b/__pycache__/plant.cpython-37.pyc differ
diff --git a/__pycache__/soil.cpython-37.pyc b/__pycache__/soil.cpython-37.pyc
index 1b7ec5b..d8498da 100644
Binary files a/__pycache__/soil.cpython-37.pyc and b/__pycache__/soil.cpython-37.pyc differ
diff --git a/__pycache__/station.cpython-37.pyc b/__pycache__/station.cpython-37.pyc
index 7a18d03..fc60c1c 100644
Binary files a/__pycache__/station.cpython-37.pyc and b/__pycache__/station.cpython-37.pyc differ
diff --git a/__pycache__/tractor.cpython-37.pyc b/__pycache__/tractor.cpython-37.pyc
index 2c27beb..9000e51 100644
Binary files a/__pycache__/tractor.cpython-37.pyc and b/__pycache__/tractor.cpython-37.pyc differ
diff --git a/definitions.py b/definitions.py
index 0a65f1e..b69daf0 100644
--- a/definitions.py
+++ b/definitions.py
@@ -1,3 +1,4 @@
+#definicje
import os
import pygame
BLOCK_SIZE = 60
diff --git a/field.py b/field.py
index 3638202..24d0447 100644
--- a/field.py
+++ b/field.py
@@ -1,5 +1,5 @@
class Field:
- def __init__(self, plant, rect, soil):
+ def __init__(self, plant, rect, soil): #składa się z rośliny oraz gleby, plus koordynaty danego pola
self.plant = plant
self.rect = rect
self.soil = soil
diff --git a/map.py b/map.py
index 7e51071..e17419a 100644
--- a/map.py
+++ b/map.py
@@ -5,12 +5,12 @@ import pygame
import soil
class Map:
def __init__(self, fields):
- self.fields = fields
+ self.fields = fields #przechowuje wszystkie pola (Field)
def get_fields(self):
return self.fields
def set_fields(self, fields):
self.fields = fields
- def create_base_map(self):
+ def create_base_map(self): #wypełnia mapę polami z bazowymi logicznymi wartościami
for i in range(definitions.WIDTH_AMOUNT):
temp_map_field = []
for j in range(definitions.HEIGHT_AMOUNT):
@@ -23,7 +23,7 @@ class Map:
temp_field = field.Field(temp_plant, temp_rect, temp_soil)
temp_map_field.append(temp_field)
self.fields.append(temp_map_field)
- def fill_map(self):
+ def fill_map(self): #wypełnia mapę teksturami na podstawie logicznego stanu pól
for i in range(definitions.WIDTH_AMOUNT):
for j in range(definitions.HEIGHT_AMOUNT):
field = self.fields[i][j]
@@ -81,7 +81,7 @@ class Map:
elif block != definitions.DIRT or block != definitions.FARMLAND_DRY or block != definitions.FARMLAND_WET:
definitions.WINDOW.blit(definitions.FARMLAND_WET, (rect.x, rect.y))
definitions.WINDOW.blit(block, (rect.x, rect.y))
- def draw_window(self, tractor1_rect):
+ def draw_window(self, tractor1_rect): #rysuje mapę
self.fill_map()
definitions.WINDOW.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y))
pygame.display.update()
\ No newline at end of file
diff --git a/plant.py b/plant.py
index 286ffdd..fcc747a 100644
--- a/plant.py
+++ b/plant.py
@@ -1,8 +1,8 @@
import definitions
class Plant:
def __init__(self, name, state):
- self.name = name
- self.state = state
+ self.name = name #nazwa rośliny np. "wheat"
+ self.state = state #etap rozwoju rośliny
def get_name(self):
return self.name
def set_name(self, name):
@@ -12,7 +12,7 @@ class Plant:
def set_state(self, state):
self.state = state
@staticmethod
- def grow_plants(map1):
+ def grow_plants(map1): #metoda statyczna, która zwiększa pole state (etap rozwoju rośliny) dla danej rośliny na danym polu o 1
for i in range(definitions.WIDTH_AMOUNT):
for j in range(definitions.HEIGHT_AMOUNT):
field = map1.get_fields()[i][j]
diff --git a/py.py b/py.py
index 07e23a6..1dbedba 100644
--- a/py.py
+++ b/py.py
@@ -6,6 +6,7 @@ import station
import tractor
pygame.display.set_caption("Smart Tractor")
def main():
+ #tworzenie podstawowych obiektów
map1 = map.Map([])
map1.create_base_map()
amount_of_seeds_dict = {"beetroot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "carrot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "potato": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "wheat": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE}
@@ -16,7 +17,7 @@ def main():
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
clock = pygame.time.Clock()
run = True
- while run:
+ while run: #pętla główna programu
clock.tick(definitions.FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
diff --git a/soil.py b/soil.py
index 81f5494..863bb4a 100644
--- a/soil.py
+++ b/soil.py
@@ -1,8 +1,8 @@
class Soil:
def __init__(self, is_fertilized, state, water_level):
- self.is_fertilized = is_fertilized
- self.state = state
- self.water_level = water_level
+ self.is_fertilized = is_fertilized #nienawieziona lub nawieziona
+ self.state = state #niezaorana lub zaorana
+ self.water_level = water_level #niepodlana lub podlana
def get_is_fertilized(self):
return self.is_fertilized
def set_is_fertilized(self, is_fertilized):
diff --git a/station.py b/station.py
index 7c6b9df..c87ed4c 100644
--- a/station.py
+++ b/station.py
@@ -1,7 +1,7 @@
class Station:
def __init__(self, collected_plants):
- self.collected_plants = collected_plants
- def get_collected_plants(self, name):
+ self.collected_plants = collected_plants #collected_plants to słownik, przechowuje informacje o oddanych plonach
+ def get_collected_plants(self, name): #zwraca łączną ilość oddanych plonów dla podanej rośliny (name)
return self.collected_plants[name]
- def set_collected_plants(self, name, value):
+ def set_collected_plants(self, name, value): #dla podanej rośliny (name) ustawia łączną ilość oddanych plonów (value)
self.collected_plants[name] = value
\ No newline at end of file
diff --git a/tractor.py b/tractor.py
index f8b5ebd..c8558cd 100644
--- a/tractor.py
+++ b/tractor.py
@@ -2,28 +2,28 @@ import definitions
import random
class Tractor:
def __init__(self, amount_of_seeds, collected_plants, fertilizer, fuel, water_level, x, y):
- self.amount_of_seeds = amount_of_seeds
- self.collected_plants = collected_plants
- self.fertilizer = fertilizer
- self.fuel = fuel
- self.water_level = water_level
+ self.amount_of_seeds = amount_of_seeds #amount_of_seeds to słownik, przechowuje informacje o posiadanej ilości ziaren dla danej rośliny
+ self.collected_plants = collected_plants #collected_plants to słownik, przechowuje informacje o zebranych plonach
+ self.fertilizer = fertilizer #fertilizer to słownik, przechowuje informacje o ilości posiadanego nawozu dla konkretnej rośliny
+ self.fuel = fuel #aktualna ilość paliwa
+ self.water_level = water_level #aktualna ilość wody do podlewania
self.x = x
self.y = y
- def get_all_amount_of_seeds(self):
+ def get_all_amount_of_seeds(self): #zwraca łączną ilość ziaren (suma ziaren dla wszystkich roślin)
return self.amount_of_seeds["beetroot"] + self.amount_of_seeds["carrot"] + self.amount_of_seeds["potato"] + self.amount_of_seeds["wheat"]
- def get_amount_of_seeds(self, name):
+ def get_amount_of_seeds(self, name): #zwraca łączną ilość ziaren dla podanej rośliny (name)
return self.amount_of_seeds[name]
- def set_amount_of_seeds(self, name, value):
+ def set_amount_of_seeds(self, name, value): #dla podanej rośliny (name) ustawia łączną ilość ziaren (value)
self.amount_of_seeds[name] = value
- def get_all_collected_plants(self):
+ def get_all_collected_plants(self): #zwraca łączną ilość zebranych plonów (suma plonów wszystkich roślin)
return self.collected_plants["beetroot"] + self.collected_plants["carrot"] + self.collected_plants["potato"] + self.collected_plants["wheat"]
- def get_collected_plants(self, name):
+ def get_collected_plants(self, name): #zwraca łączną ilość zebranych plonów dla podanej rośliny (name)
return self.collected_plants[name]
- def set_collected_plants(self, name, value):
+ def set_collected_plants(self, name, value): #dla podanej rośliny (name) ustawia łączną ilość zebranych plonów (value)
self.collected_plants[name] = value
- def get_fertilizer(self, name):
+ def get_fertilizer(self, name): #zwraca łączną ilość posiadanego nawozu dla podanej rośliny (name)
return self.fertilizer[name]
- def set_fertilizer(self, name, value):
+ def set_fertilizer(self, name, value): #dla podanej rośliny (name) ustawia ilość posiadanego nawozu (value)
self.fertilizer[name] = value
def get_fuel(self):
return self.fuel
@@ -49,18 +49,14 @@ class Tractor:
self.x = self.x + definitions.BLOCK_SIZE
def move_up(self):
self.y = self.y - definitions.BLOCK_SIZE
- def station_restore(self, station1):
- station1.set_collected_plants("beetroot",
- station1.get_collected_plants("beetroot") + self.get_collected_plants("beetroot"))
+ def station_restore(self, station1): #aktualizuje stan stacji pod względem oddanych plonów oraz uzupełnia zapasy traktora
+ station1.set_collected_plants("beetroot", station1.get_collected_plants("beetroot") + self.get_collected_plants("beetroot"))
self.set_collected_plants("beetroot", 0)
- station1.set_collected_plants("carrot",
- station1.get_collected_plants("carrot") + self.get_collected_plants("carrot"))
+ station1.set_collected_plants("carrot", station1.get_collected_plants("carrot") + self.get_collected_plants("carrot"))
self.set_collected_plants("carrot", 0)
- station1.set_collected_plants("potato",
- station1.get_collected_plants("potato") + self.get_collected_plants("potato"))
+ station1.set_collected_plants("potato", station1.get_collected_plants("potato") + self.get_collected_plants("potato"))
self.set_collected_plants("potato", 0)
- station1.set_collected_plants("wheat",
- station1.get_collected_plants("wheat") + self.get_collected_plants("wheat"))
+ station1.set_collected_plants("wheat", station1.get_collected_plants("wheat") + self.get_collected_plants("wheat"))
self.set_collected_plants("wheat", 0)
self.set_amount_of_seeds("beetroot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("carrot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
@@ -72,7 +68,7 @@ class Tractor:
self.set_fertilizer("wheat", definitions.TRACTOR_FERTILIZER)
self.set_fuel(definitions.TRACTOR_FUEL)
self.set_water_level(definitions.TRACTOR_WATER_LEVEL)
- def do_work(self, map1, station1, tractor1_rect):
+ def do_work(self, map1, station1, tractor1_rect): #jaką pracę traktor ma wykonać na danym polu, na którym aktualnie przebywa (zmienia stan logiczny danego pola)
loop = True
if self.get_all_amount_of_seeds() == 0:
loop = False
@@ -149,7 +145,7 @@ class Tractor:
field.get_soil().set_water_level(False)
field.get_soil().set_state(False)
self.set_collected_plants("wheat", self.get_collected_plants("wheat") + 1)
- def is_move_allowed(self, move, tractor1_rect):
+ def is_move_allowed(self, move, tractor1_rect): #sprawdza czy dany ruch, który chce wykonać traktor jest możliwy, zwraca prawdę lub fałsz
if move == 1 and tractor1_rect.y + definitions.BLOCK_SIZE + definitions.BLOCK_SIZE <= definitions.HEIGHT:
return True
elif move == 2 and tractor1_rect.x - definitions.BLOCK_SIZE >= 0:
@@ -160,7 +156,7 @@ class Tractor:
return True
else:
return False
- def tractor1_handle_movement(self, tractor1_rect):
+ def tractor1_handle_movement(self, tractor1_rect): #odpowiada za poruszanie się traktora po mapie
loop = True
while loop and self.get_fuel() > 0:
random1 = random.randint(1, 4)