master #1

Merged
s444427 merged 39 commits from s452664/Sztuczna_Inteligencja-projekt:master into master 2021-06-03 16:39:57 +02:00
Showing only changes of commit bc02986bb3 - Show all commits

101
field.py
View File

@ -1,43 +1,58 @@
import pygame import pygame
from colors import * from colors import *
from dimensions import * from dimensions import *
class Field(pygame.sprite.Sprite): class Field(pygame.sprite.Sprite):
def __init__(self, row, column): def __init__(self, row, column, field_type):
super(Field, self).__init__() super(Field, self).__init__()
self.surf = pygame.Surface((WIDTH, HEIGHT)) self.surf = pygame.Surface((WIDTH, HEIGHT))
self.surf.fill(BROWN) self.field_type = field_type
self.rect = self.surf.get_rect( if self.field_type == "soil":
topleft=((MARGIN + WIDTH) * row + MARGIN, (MARGIN + HEIGHT) * column + MARGIN)) self.moveCost = 3
self.position = [row, column] self.surf.fill(BROWN0)
self.hydration = 0 elif self.field_type == "rocks":
self.isRocky = False self.moveCost = 5
self.planted = 0 self.surf.fill(LBROWN)
self.ferility = 1 elif self.field_type == "road":
self.moveCost = 1
def hydrate(self): self.surf.fill(GREY)
if self.hydration <= 3: elif self.field_type == "pond":
self.hydration += 1 self.moveCost = 1000
if self.hydration == 0: self.surf.fill(BLUE)
self.surf.fill(BROWN) self.rect = self.surf.get_rect(
if self.hydration == 1: topleft=((MARGIN + WIDTH) * row + MARGIN, (MARGIN + HEIGHT) * column + MARGIN))
self.surf.fill(YELLOW) self.position = [row, column]
if self.hydration == 2: self.hydration = 0
self.surf.fill(GREEN) self.planted = 0
if self.hydration == 3: self.ferility = 1
self.surf.fill(BLUE)
def hydrate(self):
def dehydrate(self): if self.field_type == "soil" and self.hydration <= 4:
if self.hydration > 0: self.hydration += 1
self.hydration -= 1 if self.hydration == 0:
if self.hydration == 0: self.surf.fill(BROWN0)
self.surf.fill(BROWN) if self.hydration == 1:
if self.hydration == 1: self.surf.fill(BROWN1)
self.surf.fill(YELLOW) if self.hydration == 2:
if self.hydration == 2: self.surf.fill(BROWN2)
self.surf.fill(GREEN) if self.hydration == 3:
if self.hydration == 3: self.surf.fill(BROWN3)
self.surf.fill(BLUE) if self.hydration == 4:
self.surf.fill(BROWN4)
def free(self):
self.planted = 0 def dehydrate(self):
if self.field_type == "soil" and self.hydration > 0:
self.hydration -= 1
if self.hydration == 0:
self.surf.fill(BROWN0)
if self.hydration == 1:
self.surf.fill(BROWN1)
if self.hydration == 2:
self.surf.fill(BROWN2)
if self.hydration == 3:
self.surf.fill(BROWN3)
if self.hydration == 4:
self.surf.fill(BROWN4)
def free(self):
self.planted = 0