simplified mine and tile classes
This commit is contained in:
parent
f73dd1f68f
commit
8a14461983
17
mine.py
17
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)
|
||||
|
42
tile.py
42
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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user