2021-05-07 22:26:58 +02:00
|
|
|
from project_constants import Terrain
|
2021-05-07 19:02:09 +02:00
|
|
|
|
2021-05-07 22:26:58 +02:00
|
|
|
|
|
|
|
# Assume_cost function assumes colour as an argument (colour that is already given to a tile) and depending
|
|
|
|
# on what it is returns value of Terrein Enum
|
|
|
|
# It is used in Tile.cost (giving the value to the tile)
|
2021-05-07 19:02:09 +02:00
|
|
|
|
2021-05-20 15:01:09 +02:00
|
|
|
def assume_cost(terrain_type, mine):
|
2021-06-17 20:30:32 +02:00
|
|
|
if mine is not None and mine.active:
|
2021-05-20 15:01:09 +02:00
|
|
|
return Terrain.MINE
|
2021-05-07 22:26:58 +02:00
|
|
|
if terrain_type == "CONCRETE":
|
|
|
|
return Terrain.CONCRETE
|
|
|
|
elif terrain_type == "GRASS":
|
|
|
|
return Terrain.GRASS
|
|
|
|
elif terrain_type == "MUD":
|
|
|
|
return Terrain.MUD
|
2021-05-07 19:02:09 +02:00
|
|
|
|
|
|
|
|
2021-03-12 11:49:19 +01:00
|
|
|
class Tile:
|
2021-05-07 19:02:09 +02:00
|
|
|
def __init__(self, position, terrain_type=None, mine=None):
|
2021-03-12 11:49:19 +01:00
|
|
|
self.position = position
|
2021-05-07 19:02:09 +02:00
|
|
|
self.terrain_type = terrain_type
|
2021-06-17 20:30:32 +02:00
|
|
|
self._cost = assume_cost(terrain_type, mine)
|
2021-03-12 21:24:04 +01:00
|
|
|
# mine is an instance of Mine class
|
2021-05-07 22:26:58 +02:00
|
|
|
self.mine = mine
|
2021-06-17 20:30:32 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def cost(self):
|
|
|
|
self._cost = assume_cost(self.terrain_type, self.mine)
|
|
|
|
return self._cost
|
|
|
|
|
|
|
|
@cost.setter
|
|
|
|
def cost(self, new_value):
|
|
|
|
self._cost = new_value
|
|
|
|
|