simplified mine and tile classes

This commit is contained in:
s452645 2021-03-12 21:24:04 +01:00
parent f73dd1f68f
commit 8a14461983
2 changed files with 4 additions and 55 deletions

17
mine.py
View File

@ -1,20 +1,7 @@
import project_constants as consts
class Mine: class Mine:
def __init__(self, position, mine_type, active=True): def __init__(self, position, mine_type, active=True):
self.position = position self.position = position
self.mine_type = mine_type self.mine_type = mine_type
if mine_type == 'a':
self.asset = consts.ASSET_MINE_A
elif mine_type == 'b':
self.asset = consts.ASSET_MINE_B
elif mine_type == 'f':
self.asset = consts.ASSET_MINE_F
elif mine_type == 'k':
self.asset = consts.ASSET_MINE_K
else:
self.asset = None
self.active = active self.active = active
# more to be added later (e.g. disarming)

42
tile.py
View File

@ -1,4 +1,4 @@
import project_constants as consts import mine as mn
class Tile: class Tile:
@ -6,43 +6,5 @@ class Tile:
self.position = position self.position = position
self.color = color self.color = color
if color == "blue": # mine is an instance of Mine class
self.asset = consts.ASSET_TILE_BLUE
elif color == "green":
self.asset = consts.ASSET_TILE_GREEN
elif color == "orange":
self.asset = consts.ASSET_TILE_ORANGE
elif color == "purple":
self.asset = consts.ASSET_TILE_PURPLE
elif color == "red":
self.asset = consts.ASSET_TILE_RED
elif color == "white":
self.asset = consts.ASSET_TILE_WHITE
elif color == "yellow":
self.asset = consts.ASSET_TILE_YELLOW
else:
self.asset = None
self.mine = mine self.mine = mine
def update_color(self, color):
self.color = color
if color == "blue":
self.asset = consts.ASSET_TILE_BLUE
elif color == "green":
self.asset = consts.ASSET_TILE_GREEN
elif color == "orange":
self.asset = consts.ASSET_TILE_ORANGE
elif color == "purple":
self.asset = consts.ASSET_TILE_PURPLE
elif color == "red":
self.asset = consts.ASSET_TILE_RED
elif color == "white":
self.asset = consts.ASSET_TILE_WHITE
elif color == "yellow":
self.asset = consts.ASSET_TILE_YELLOW
else:
self.asset = None