generated from mwc/project_game
38 lines
911 B
Python
38 lines
911 B
Python
# mine.py
|
|
# ------------
|
|
# By Cory
|
|
# This module defines a mine agent class. It ends the game if enter is pressed while the cursor is over it.
|
|
|
|
class Mine:
|
|
character = ''
|
|
revealed = True
|
|
|
|
def __init__(self, position):
|
|
self.position = position
|
|
|
|
def handle_keystroke(self, keystroke, game):
|
|
if keystroke.name in ("KEY_ENTER"):
|
|
if game.get_agent_by_name("cursor").position == self.position:
|
|
game.log("You hit a mine! Game over.")
|
|
game.end()
|
|
|
|
def play_turn(self, game):
|
|
if (not game.is_empty(self.position)):
|
|
self.display = False
|
|
elif game.is_empty(self.position):
|
|
self.display = True
|
|
|
|
def hide(self):
|
|
pass
|
|
|
|
def name_me(self, named):
|
|
self.name = named
|
|
|
|
def check_neighbors(self,game):
|
|
pass
|
|
|
|
def reveal(self):
|
|
pass
|
|
|
|
def show(self):
|
|
pass |