def get_resources(self) -> Resources: produced_resources = Resources() produced_resources += Resources.from_dictionary(resources_per_turn[self.terrain.name]) if self.building: produced_resources += self.building.get_resources() try: self.available_resources -= produced_resources except NegativeResourceError: remaining_resources = self.available_resources.get_remaining(required=produced_resources) self.available_resources -= remaining_resources produced_resources = remaining_resources return produced_resources
def __init__( self, position: Tuple[int, int], terrain: Terrain, building: Building = None, owner: Optional[int] = None ): shape = sprites[terrain.name] Actor.__init__(self, position, shape) self.terrain = terrain self.building = building self._owner = owner self.price = Resources.from_dictionary(field_prices["neutral"]) self.available_resources = Resources.from_dictionary(resources_limit[terrain.name]) self.click_callback = None
def __init__(self): self.player_number = Player.current_number Player.current_number += 1 self.resources = Resources.from_dictionary(STARTING_RESOURCES) self.fields: List[Field] = [] self.available_workers = 10 self.total_workers = 10 self.start_field = None self.border = Border(player_colors[self.player_number])
def change_price_when_neighbour_if_defensive_building(self): self.price = Resources.from_dictionary(field_prices["defended"])
def change_price_when_take_over(self): self.price = Resources.from_dictionary(field_prices["take_over"])
from treeline.model.field import Terrain from treeline.model.resource import Resources from treeline.engine.shapes.sprite import Sprite import pygame BUILDING_STATS = { "farm": { "cost": Resources.from_dictionary({ "wood": 10, }), "max_workers": 10, "valid_terrains": [Terrain.grass], }, "sawmill": { "cost": Resources.from_dictionary({ "wood": 10, }), "max_workers": 5, "valid_terrains": [Terrain.forest], }, "iron_mine": { "cost": Resources.from_dictionary({ "wood": 10, }), "max_workers": 8, "valid_terrains": [Terrain.mountain], }, "house": { "cost": Resources.from_dictionary({ "wood": 10, }),
def get_resources(self) -> Resources: food_produced = self.workers * 1 return Resources.from_dictionary({"food": food_produced})
def get_resources(self) -> Resources: return Resources()
def get_resources(self) -> Resources: iron_produced = self.workers * 1 return Resources.from_dictionary({"iron": iron_produced})