Exemplo n.º 1
0
def test_add_entities():
    tile_map = mapping.TileMap(width=10, height=10)
    # stick = entities.stick()
    cave_generator.add_entity_at_random_location(tile_map, entities.stick)

    occupied_tile = None
    coords = None
    for point, tile in tile_map.iterate():
        if tile.entities:
            occupied_tile = tile
            coords = point
            break

    for point, tile in tile_map.iterate():
        if point == coords:
            continue
        assert tile.entities == []


    assert occupied_tile

    assert entities.visible_entity(occupied_tile.entities).name == 'stick'

    rock = entities.rock()
    occupied_tile.entities.insert(0, rock)
    assert entities.visible_entity(occupied_tile.entities).name == 'rock'
Exemplo n.º 2
0
def get_tile_display(tile):

    visible_entity = entities.visible_entity(tile.entities)
    if visible_entity:
        # display the uppermost visible entity
        # visible entities MUST have a display in ENTITY_DISPLAYS!
        return ENTITY_DISPLAYS[visible_entity.name]

    if tile.composition in TILE_DISPLAYS:
        return TILE_DISPLAYS[tile.composition]

    # water depends on direction
    if tile.composition == terrain.FloorTypes.Water:
        tile_char = get_pipe_display(tile.props['direction'])

        return(tile_char, BLUE)

    raise ValueError('Tile type not found %s', tile_type)