예제 #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
예제 #2
0
def validMoveForHarness(destination: tuple, level: Level):
    boardNum = whichBoardInLevel(level, destination)
    if boardNum == -1:
        return False
    if destHasPlayer(destination, level.boards[boardNum]):
        return False
    for tile in level.boards[boardNum].tiles:
        if tile.location == destination:
            return tile.tileType is not TileEnum.WALL
    return False
예제 #3
0
def validMoveForHarness(destination: tuple, level: Level):
    boardNum = whichBoardInLevel(level, destination)
    if boardNum == -1:
        return False
    if destHasPlayer(destination, level.boards[boardNum]):
        return False
    if isTileOnBoard(destination, level.boards[boardNum]):
        tile = level.boards[boardNum].tiles[destination[0]][destination[1]]
        return tile.tileType is not TileEnum.WALL
    return False
예제 #4
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