from enum import Enum import pygame import settings import plant class Type(Enum): DEFAULT = 0 PLANT = 1 SPECIAL = 2 @staticmethod def get_string(_type): return { Type.DEFAULT: 'default', Type.PLANT: 'plant', Type.SPECIAL: 'special', }[_type] # Field Types START class FieldType: def __init__(self): self.field = None self.plowed = False def plow(self): self.plowed = True def sow(self, seed: plant.Seeds): if self.plowed: self.field = plant.Seeds.seed_to_plant(seed) class Object: height = width = 0 name = 'default' type = Type.DEFAULT def create(self): field_string = Type.get_string(self.type) img = pygame.image.load("./assets/fields/" + field_string + "/" + self.name + ".jpg") return pygame.transform.scale(img, (self.width, self.height)) class Tile(Object): def __init__(self, name: str, _type: Type): self.name = name self.type = _type self.width = self.height = settings.Field.size() self.object = self.create() class Block(Object): def __init__(self, name: str, _type: Type): self.name = name self.type = _type self.width = settings.Pygame.width() self.height = settings.Pygame.height() self.object = self.create() class Field: type = Type.DEFAULT name = 'default' def __init__(self): self.tile = Tile(self.name, self.type) self.block = Block(self.name + "_block", self.type) self.field_type = FieldType() def can_be_sown(self): return self.type == Type.DEFAULT # Tile Types START class Dirt(Field): type = Type.PLANT name = 'dirt' cost = 5 def __init__(self): super().__init__() class Carrot(Field): type = Type.PLANT cost = 5 def __init__(self, name): self.name = name super().__init__() class Potato(Field): type = Type.PLANT cost = 5 def __init__(self, name): self.name = name super().__init__() class Wheat(Field): type = Type.PLANT cost = 5 def __init__(self, name): self.name = name super().__init__() class Cobble(Field): type = Type.SPECIAL name = 'cobble' cost = 1 def __init__(self): super().__init__() class Grass(Field): type = Type.DEFAULT name = 'grass' cost = 3 def __init__(self): super().__init__() class Sand(Field): type = Type.DEFAULT name = 'sand' cost = 10 def __init__(self): super().__init__() class Station(Field): type = Type.SPECIAL name = 'station' cost = 1 def __init__(self): super().__init__() # Tile Types END