Zaktualizuj 'field.py'
This commit is contained in:
parent
e9c11d37d2
commit
4f5cf361ce
62
field.py
62
field.py
@ -1,9 +1,7 @@
|
||||
import pygame
|
||||
|
||||
from src.colors import *
|
||||
from src.dimensions import *
|
||||
|
||||
|
||||
class Field(pygame.sprite.Sprite):
|
||||
def __init__(self, row, column, field_type):
|
||||
super(Field, self).__init__()
|
||||
@ -26,22 +24,62 @@ class Field(pygame.sprite.Sprite):
|
||||
self.position = [row, column]
|
||||
self.hydration = 0
|
||||
self.planted = 0
|
||||
self.fertility = 1
|
||||
self.fertility = 0
|
||||
self.tractor_there = False
|
||||
|
||||
def hydrate(self):
|
||||
if self.field_type == "soil" and self.hydration <= 5:
|
||||
self.hydration += 1
|
||||
|
||||
# color field to it's hydration value
|
||||
self.surf.fill(eval('BROWN' + str(self.hydration)))
|
||||
self.hydration += 1
|
||||
if self.fertility == 1:
|
||||
if self.hydration == 0:
|
||||
self.surf.fill(REDDISH0)
|
||||
self.fertility = 0
|
||||
if self.hydration == 1:
|
||||
self.surf.fill(REDDISH1)
|
||||
if self.hydration == 2:
|
||||
self.surf.fill(REDDISH2)
|
||||
if self.hydration == 3:
|
||||
self.surf.fill(REDDISH3)
|
||||
if self.hydration == 4 or self.hydration == 5:
|
||||
self.surf.fill(REDDISH4)
|
||||
else:
|
||||
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 or self.hydration == 5:
|
||||
self.surf.fill(BROWN4)
|
||||
|
||||
def dehydrate(self):
|
||||
if self.field_type == "soil" and self.hydration > 0:
|
||||
self.hydration -= 1
|
||||
|
||||
# color field to it's hydration value
|
||||
self.surf.fill(eval('BROWN' + str(self.hydration)))
|
||||
if self.field_type == "soil" and self.hydration > 0:
|
||||
self.hydration -= 1
|
||||
if self.fertility == 1:
|
||||
if self.hydration == 0:
|
||||
self.surf.fill(REDDISH0)
|
||||
self.fertility = 0
|
||||
if self.hydration == 1:
|
||||
self.surf.fill(REDDISH1)
|
||||
if self.hydration == 2:
|
||||
self.surf.fill(REDDISH2)
|
||||
if self.hydration == 3:
|
||||
self.surf.fill(REDDISH3)
|
||||
if self.hydration == 4 or self.hydration == 5:
|
||||
self.surf.fill(REDDISH4)
|
||||
else:
|
||||
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 or self.hydration == 5:
|
||||
self.surf.fill(BROWN4)
|
||||
|
||||
def free(self):
|
||||
self.planted = 0
|
||||
|
Loading…
Reference in New Issue
Block a user