def getObjectsAroundPlayer(possMoves: list, game: Dungeon): acc = [] for loc in possMoves: level: Level = game.levels[game.currLevel] if destHasKey(loc, level): acc.append({"type": "key", "position": loc}) elif destHasExit(loc, level): acc.append({"type": "exit", "position": loc}) return acc
def getMoveStatus(currLevel: Level, playerName: str, move: dict): dest = intifyTuple(move["to"]) if destHasKey(dest, currLevel): return [playerName, move, "Key"] elif destHasExit(dest, currLevel): return [playerName, move, "Exit"] elif destHasEnemy(dest, currLevel.boards[whichBoardInLevel(currLevel, dest)]): return [playerName, move, "Eject"] else: return [playerName, move, "OK"]
def interact(playerName: str, location: tuple, game: Dungeon): """ Updates the game to reflect a player's interaction with a location in the game. :param playerName: str :param location: tuple :param game: Dungeon """ currLevel: Level = game.levels[game.currLevel] currBoard: Board = currLevel.boards[currLevel.currBoard] if destHasEnemy(location, currBoard): return interactWithEnemy(playerName, location, game) elif destHasKey(location, currLevel): return interactWithKey(location, game) elif destHasExit(location, currLevel): return interactWithExit(playerName, location, game) # elif destHasItem(location, currBoard): # TODO implement interactWithItem # return game else: return game