Esempio n. 1
0
def test_available_actions():
    player.move_east()
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).available_actions() == [
            text_adventure.MoveEast, text_adventure.MoveWest,
            text_adventure.TakeInventory, text_adventure.Equip,
            text_adventure.Observe, text_adventure.Consume,
            text_adventure.LookAround, text_adventure.PickUp,
            text_adventure.Drop
        ]
    player.move_west()
    player.move_west()
    #assert text_adventure.tile_exists(player.location_x, player.location_y).available_actions() == [text_adventure.Attack, text_adventure.Flee, text_adventure.Observe]
    text_adventure.tile_exists(player.location_x,
                               player.location_y).enemy.hp = -200
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).available_actions() == [
            text_adventure.MoveEast, text_adventure.TakeInventory,
            text_adventure.Equip, text_adventure.Observe,
            text_adventure.Consume, text_adventure.LookAround,
            text_adventure.PickUp, text_adventure.Drop
        ]
    text_adventure.tile_exists(player.location_x,
                               player.location_y).enemy.hp = 200
    player.move_east()
    player.move_south()
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).available_actions() == [
            text_adventure.MoveNorth, text_adventure.TakeInventory,
            text_adventure.Equip, text_adventure.Observe,
            text_adventure.Consume, text_adventure.LookAround,
            text_adventure.Buy, text_adventure.Sell
        ]
    player.move_north()
Esempio n. 2
0
def test_victory_room():
    player.move_east()
    player.move_east()
    text_adventure.tile_exists(player.location_x,
                               player.location_y).victory(player)
    assert player.victory
    player.move_west()
    player.move_west()
Esempio n. 3
0
def test_view_tile_inventory():
    player.move_east()
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).view_tile_inventory() == (
            "Gold Necklace\n1000 Gold")
    player.move_west()
    player.move_south()
    assert text_adventure.tile_exists(
        player.location_x, player.location_y
    ).view_tile_inventory() == (
        "Stock:\nSteel Sword\nSteel Armour\nSteel Shield\nThis store has 1000 Gold."
    )
    player.move_north()
Esempio n. 4
0
def test_pick_up_item():
    player.move_east()
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).pick_up_item(
            player, objects.gold) == "You pick up 1000 Gold."
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).pick_up_item(
            player, objects.gold_necklace) == "You pick up Gold Necklace."
    player.currency_amount = 100
    text_adventure.tile_exists(player.location_x, player.location_y).drop_item(
        player, objects.gold_necklace)
    text_adventure.tile_exists(player.location_x,
                               player.location_y).tile_currency_amount = 1000
    player.move_west()
Esempio n. 5
0
def test_adjacent_moves():
    assert text_adventure.tile_exists(player.location_x,
                                      player.location_y).adjacent_moves() == [
                                          text_adventure.MoveEast,
                                          text_adventure.MoveWest,
                                          text_adventure.MoveNorth,
                                          text_adventure.MoveSouth
                                      ]
    player.move_east()
    assert text_adventure.tile_exists(player.location_x,
                                      player.location_y).adjacent_moves() == [
                                          text_adventure.MoveEast,
                                          text_adventure.MoveWest
                                      ]
    player.move_west()
Esempio n. 6
0
def test_enemy_attack():
    player.move_west()
    random.seed(100)
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).enemy_attack(
            player
        ) == "Tough bandit. hits you for 50 damage!\nYou now have 50 HP."
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).enemy_attack(
            player
        ) == "You have fallen as Tough bandit. has hit you for 50 damage!"
    player.hp = 100
    random.seed(-31)
    assert text_adventure.tile_exists(
        player.location_x, player.location_y).enemy_attack(
            player) == "Tough bandit. attacks but misses!"
    player.move_east()
def test_look_around():
    player.move_east()
    assert player.do_action(
        text_adventure.LookAround) == "Gold Necklace\n1000 Gold"
    player.move_west()
Esempio n. 8
0
def test_move():
    assert player.move_east() == "This is a room with loot in it."
    player.move_west()
Esempio n. 9
0
def test_pickup():
    player.move_east()
    assert player.pick_up(objects.gold_necklace) == "You pick up Gold Necklace."
    player.drop(objects.gold_necklace)
    player.move_west()