Example #1
0
def test_coin_tile_is_correctly_replaced():
    den = Den()
    cutthroat = Cutthroat()
    dungeon = ConstructedRoom(den, cutthroat)
    tile_of_interest = den.get_tiles()[1]

    assert tile_of_interest.character_number == NumberedRoomTileValues.TWO

    output_tile = dungeon.replace_generic_number_with_concrete_monster_value(
        tile_of_interest)

    two = NumberedRoomTileValues.TWO
    assert output_tile.character_number == cutthroat.get_designation_by_number(
        two)
Example #2
0
 def serialize(self, serializable_object: ConstructedRoom):
     tiles = serializable_object.get_tiles()
     tile_dict = {
         idx: self.tile_serializer.serialize(tiles[idx])
         for idx in range(len(tiles))
     }
     indicators = [
         self.enum_serializer.serialize(indicator)
         for indicator in serializable_object.get_trap_indicators()
     ]
     return {
         'name': serializable_object.get_name(),
         'tiles': tile_dict,
         'monsterCardName': serializable_object.get_monster_card_name(),
         'indicators': indicators
     }
Example #3
0
def test_serialize_room_with_trap_indicators(tile_serializer, enum_serializer,
                                             test_room):
    serializer = RoomSerializer(tile_serializer, enum_serializer)
    mocked_enum_value = enum_serializer.serialize.return_value
    test_constructed_room = ConstructedRoom(test_room, Frigid())

    actual = serializer.serialize(test_constructed_room)

    expected = {
        'name': 'foo',
        'indicators': [mocked_enum_value],
        'monsterCardName': 'Frigid',
        'tiles': {}
    }

    assert actual == expected
Example #4
0
def create_test_constructed_room():
    return ConstructedRoom(AbstractRoomCard("foo"), Frigid())
Example #5
0
    def construct_room(self, room, monster):
        self.pop_room_card(room)
        self.pop_monster_card(monster)

        return ConstructedRoom(room, monster)
Example #6
0
def test_numbered_tile_is_numbered_tile():
    numbered_five_tile = Tile(0, 0, NumberedRoomTileValues.FIVE)
    assert ConstructedRoom.is_tile_numbered_tile(numbered_five_tile) is True
Example #7
0
def test_constructed_room_only_accepts_monster_card_objects_for_second_argument(
):
    with pytest.raises(ValueError,
                       match='Bad Monster Card input to ConstructedRoom'):
        ConstructedRoom(Den(), None)
Example #8
0
def test_constructed_room_only_accepts_room_card_objects_for_first_argument():
    with pytest.raises(ValueError,
                       match='Bad Room Card input to ConstructedRoom'):
        ConstructedRoom(None, None)
Example #9
0
def test_get_tiles_returns_no_instances_of_numbered_tiles():
    dungeon = ConstructedRoom(Den(), Cutthroat())
    tiles = dungeon.get_tiles()

    for tile in tiles:
        assert not isinstance(tile.character_number, NumberedRoomTileValues)
Example #10
0
def test_obstacle_tile_is_not_numbered_tile():
    obstacle_tile = Tile(0, 0, DungeonCardValues.OBSTACLE)
    assert ConstructedRoom.is_tile_numbered_tile(obstacle_tile) is False