From 8a144619834207bb63539d2f4151ad50345402dd Mon Sep 17 00:00:00 2001 From: s452645 Date: Fri, 12 Mar 2021 21:24:04 +0100 Subject: [PATCH] simplified mine and tile classes --- mine.py | 17 ++--------------- tile.py | 42 ++---------------------------------------- 2 files changed, 4 insertions(+), 55 deletions(-) diff --git a/mine.py b/mine.py index 24c1032..69256a4 100644 --- a/mine.py +++ b/mine.py @@ -1,20 +1,7 @@ -import project_constants as consts - - class Mine: def __init__(self, position, mine_type, active=True): self.position = position 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 + + # more to be added later (e.g. disarming) diff --git a/tile.py b/tile.py index 0fd9d80..b51e165 100644 --- a/tile.py +++ b/tile.py @@ -1,4 +1,4 @@ -import project_constants as consts +import mine as mn class Tile: @@ -6,43 +6,5 @@ class Tile: self.position = position 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 - + # mine is an instance of Mine class 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 - -