Esempio n. 1
0
def enemyInteract(enemyName: str, destination: tuple, game: Dungeon):
    currLevel: Level = game.levels[game.currLevel]
    currBoardNum = whichBoardInLevel(currLevel, destination)
    currBoard: Board = currLevel.boards[currBoardNum]
    if destHasPlayer(destination, currBoard):
        return interactWithPlayer(destination, game)
    elif destHasWall(destination, currLevel):
        return interactWithWall(enemyName, destination, game)
    else:
        return game
Esempio n. 2
0
def interactWithWall(enemyName: str, destination: tuple, game: Dungeon):
    """
    Only for ghosts, teleports the enemy to a random location in the level,
    or doesn't do anything if that's not possible. Returns an updated (or not)
    game.
    """
    currLevel = game.levels[game.currLevel]
    randBoardNum, randBoard = getRandomRoomInLevel(currLevel)
    enemy = getEnemy(currLevel, enemyName)
    while True:
        loc = genXRandCoords(1, [enemy.location], randBoard.origin,
                             randBoard.dimensions).pop()
        if not destHasWall(loc, currLevel) and not destHasPlayer(
                loc, randBoard):
            newDestForGhost = loc
            break
    # Move ghost to newDest, and delete from currBoard
    game = move(enemyName, newDestForGhost, game, isPlayer=False)
    return game