Exemple #1
0
def _room_living(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    if h < 17:
        num_rooms = (h - 3) // 3
        for i in range(num_rooms):
            room_y = i * 3
            poor_room = _room_poor(4, 4, wall_material, floor_material, direction='right')
            M.meld(poor_room, 0, room_y)
            poor_room = _room_poor(4, 4, wall_material, floor_material, direction='left')
            M.meld(poor_room, 5, room_y)
        M[w-1, h-2] = C.door_open_empty()
        M[1, h-2].put(A.animal_spider())
        corridor_h = h - num_rooms * 3 - 1
        if corridor_h > 2:
            M[1, h-corridor_h].put(T.washtub())
            M[2, h-corridor_h].put(T.washtub())
            M[w-2, h-corridor_h].put(T.furniture_stool())
        M.scatter(1, h-corridor_h, w-2, h-1, [(A.animal_cat())])
    elif h >= 17:
        rich_room_h = 5 + (h - 2) % 3
        rich_1 = _room_rich(5, rich_room_h, wall_material, floor_material)
        M.meld(rich_1, 0, 0)
        rich_2 = _room_rich(5, rich_room_h, wall_material, floor_material)
        M.meld(rich_2, 4, 0)
        M[w-1, rich_room_h+1] = C.door_open_empty()
        M[1, rich_room_h+1].put(A.animal_spider())
        M.scatter(1, rich_room_h, w-1, rich_room_h+2, [(A.animal_cat())])
        num_rooms = (h - rich_room_h - 3) // 3
        for i in range(num_rooms):
            room_y = i * 3
            poor_room = _room_poor(4, 4, wall_material, floor_material, direction='right')
            M.meld(poor_room, 0, rich_room_h+2+room_y)
            poor_room = _room_poor(4, 4, wall_material, floor_material, direction='left')
            M.meld(poor_room, 5, rich_room_h+2+room_y)
    return M
def _interior_garden(w, h, wall_material, floor_material):
    M = Map(w, h, fill_cell=C.floor_flagged)
    garden_part = Map(w // 2, h, fill_cell=C.flora_grass)
    for y in range(0, h):
        garden_part[w // 2 - 1, y] = C.floor_flagged()
    for x in range(1, w // 2 - 1):
        for y in range(1, 4):
            garden_part[x, y] = C.floor_flagged()
    for x in range(2, w // 2):
        garden_part[x, 2].put(T.water_trough())
    for y in range(h - 3, h):
        garden_part[0, y] = C.flora_tree()
        garden_part[1, y].put(T.water_trough())
        garden_part[2, y] = C.flora_flower()
    garden_part[w // 2 - 2, 0] = C.flora_flower()
    garden_part[0, h - 5].put(T.furniture_sofa())
    garden_part[1, h - 5].put(T.furniture_table_round())
    garden_part[2, h - 6].put(T.urn())
    M.meld(garden_part, 0, 0)
    garden_part2 = deepcopy(garden_part)
    garden_part2.hmirror()
    M.meld(garden_part2, w // 2 + w % 2, 0)
    for x in range(0, w // 2 - 1):
        M[x, h - 4] = C.floor_flagged()
    M.scatter(0, 0, w - 1, h - 1, [A.animal_cat()])

    return M
def _room_cattle_pens(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=C.wall_fence, floor_type=floor_material)
    M[w - 7, 0] = C.door_close_fence()
    for i in range(w * h // 3):
        grass_x = random.randint(1, w - 2)
        grass_y = random.randint(1, h - 2)
        M[grass_x, grass_y] = random.choice(
            [C.flora_grass, C.flora_cane, C.floor_grass])()
    num_cattles = h // 4 + 1
    cowshed = Map(4, 3, fill_cell=floor_material)
    for y in (1, 2):
        cowshed[0, y] = C.wall_fence()
    for y in range(0, 3):
        cowshed[3, y].put(T.water_trough())
    for x in (1, 2):
        cowshed[x, 2] = wall_material()
    cowshed[1, 1].put(T.bucket())
    cowshed_y = 1
    for x in range(num_cattles):
        copied_cowshed = deepcopy(cowshed)
        M.meld(copied_cowshed, w - 5, cowshed_y)
        cowshed_y += 3
    cows = [A.animal_cow() for _ in range(num_cattles)]
    M.scatter(1, 1, w - 5, h - 1, cows)

    return M
Exemple #4
0
def room_storage(w, h):
    """
    Construct small storage with horse food and some stuff for stableman.
    """

    M = room_default(w, h, wall_type=C.wall_plank, floor_type=C.floor_dirt)
    number_of_items = (w - 1) * (h - 1) // 10

    # Place horse food.
    all_coord = []
    for item_class in (T.farm_mangler, T.furniture_barrel,
                       T.furniture_box_filled):
        for _ in range(number_of_items):
            while True:
                x = random.randint(1, w - 2)
                y = random.randint(1, h * 2 // 3 - 1)
                if (x, y) not in all_coord:
                    M[x, y].put(item_class())
                    all_coord.append((x, y))
                    break

    # Place horseman stuff.
    M[w // 2 - 1, h - 1] = C.door_closed()
    M[1, h - 2].put(T.light_torch())
    M[1, h - 4].put(T.furniture_napsack())
    M[w - 2, h - 2].put(T.furniture_table())
    M[w - 2, h - 3].put(T.furniture_chair())

    return M
Exemple #5
0
def _room_private(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    for x in (1, 4):
        M[x, 1].put(T.furniture_chair())
    for x in (2, 3):
        M[x, 1].put(T.furniture_longtable())
    M[5, 1].put(T.light_lantern_oil())
    M[w-2, h-1] = C.door_closed()
    return M
Exemple #6
0
def _interior_pantry(w, h, wall_material, floor_material):
    M = Map(w, h, fill_cell=floor_material)
    if random.random() < 0.5:
        for y in range(h):
            M[2, y] = wall_material()
        items = [T.tool_wateringcan(), T.tool_pitchfork(), T.tool_fishingrod()]
        M.scatter(0, 0, w - 1, h, items)
    else:
        M[0, 0] = C.stairs_down()
        M[0, 1].put(T.furniture_box_filled())

    return M
Exemple #7
0
def _room_torture(w=5, h=5):
    M = Map(w, h, fill_cell=C.floor_flagged)

    # Create walls
    for x in range(0, w):
        M[x, 0] = C.wall_stone()
        M[x, h - 1] = C.wall_stone()
    for y in range(0, h):
        M[0, y] = C.wall_stone()
        M[w - 1, y] = C.wall_stone()
    M[w // 2, h - 1] = C.door_closed()
    M[w // 2 + 1, h - 2] = C.stairs_up()

    # Place furniture and items in the room
    M[w // 2, h // 2].put(T.furniture_torture())
    all_coord = [(w // 2, h - 2), (w // 2, h // 2), (w // 2 + 1, h - 2)]
    for item_class in (T.bones, T.bones_skull, T.tool_tongs):
        while True:
            x = random.randint(1, w - 2)
            y = random.randint(1, h - 2)
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break
    return M
def _room_storage(w, h, wall_material, floor_material, garden_beds_w):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[w - 1, h // 2] = C.door_closed_window()
    M[w - 2, h - 1] = C.door_closed_window()
    M[garden_beds_w - 3, h - 1] = C.door_open()
    M[w - 2, 1].put(T.light_torch())
    M[w - 4, 1].put(T.dining_bottle())
    M[w - 3, h - 2].put(T.furniture_napsack())
    for x in range(1, w // 2):
        for y in range(1, h - 1):
            items = random.choice([
                T.farm_mangler, T.furniture_box_filled, T.furniture_barrel,
                T.food_milk
            ])()
            M[x, y].put(items)

    return M
def _room_small_office(w, h):
    """
    Construct small office for employees in poor part.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Place things and actor - employee.
    work_chance = random.choice([True, False])
    M[w // 2, 0] = C.door_open_empty()
    M[1, h - 1] = C.wall_bars()
    M[w - 2, h - 1] = C.wall_bars()
    M[2, h - 1].put(T.furniture_longtable())
    if w > 5:
        for x in range(2, w - 2):
            M[x, h - 1].put(T.furniture_longtable())
    M[w // 2, h - 2].put(T.furniture_chair())
    M[w - 2, 1].put(T.furniture_bookcase())
    M[1, 1].put(T.money_pile())
    if work_chance:
        M[1, h - 2].put(A.player_female())
        M[w - 2, h - 2].put(T.book())
    else:
        M[w - 2, h - 2].put(T.book_clear())

    return M
Exemple #10
0
def room_horse_box(w, h, orientation='left'):
    """
    Construct small horse box.
    """
    M = Map(w, h, fill_cell=C.floor_rocks)

    # Place watertrough and horse food.
    M[0, 0].put(T.water_trough())
    M[w - 1, 0] = C.door_closed()
    M[0, h - 1].put(T.water_trough())
    M[w - 1, h - 1] = C.wall_fence()
    if h > 2:
        for y in range(1, h - 1):
            M[0, y].put(T.water_trough())
            M[w - 1, y] = C.wall_fence()

    # Create horse box with animal or without.
    stable_with_horse_chance = random.random()
    all_coord = []
    while True:
        x = random.randint(1, w - 2)
        y = random.randint(0, h - 1)
        if (x, y) not in all_coord:
            M[x, y] = C.flora_grass()
            all_coord.append((x, y))
            break
    if stable_with_horse_chance > 0.3:
        while True:
            x = random.randint(1, w - 2)
            y = random.randint(0, h - 1)
            if (x, y) not in all_coord:
                M[x, y].put(T.farm_mangler())
                all_coord.append((x, y))
                break
        while True:
            x = random.randint(1, w - 2)
            y = random.randint(0, h - 1)
            if (x, y) not in all_coord:
                M[x, y].put(A.animal_horse())
                all_coord.append((x, y))
                break
    if orientation == 'right':
        M.hmirror()

    return M
def _room_private(w, h, orientation='left'):
    """
    Construct private room.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Place some things.
    M[1, 1].put(T.book())
    M[1, h // 2].put(T.furniture_longtable())
    for x in range(1, w - 2):
        M[x, h // 2 + 1].put(T.furniture_chair())
    M[w // 2 - 1, h // 2 - 1].put(T.furniture_chair())
    if w > 5:
        for x in range(2, w - 3):
            M[x, h // 2].put(T.furniture_longtable())
    M[w - 3, h // 2].put(T.furniture_longtable())
    M[w - 2, 0] = C.door_closed()
    M[w - 2, h // 2].put(T.furniture_chandelier())

    if orientation == 'right':
        M.hmirror()

    return M
def _room_treasury(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    items = [
        T.money_pile(),
        T.money_pile(),
        T.necklace(),
        T.mineral_geode(),
        T.mineral_diamond(),
        T.magic_orb(),
        T.scroll_text(),
        T.ring(),
        T.bag(),
    ]
    M.scatter(1, 1, w - 1, h - 1, items, exclude=[(w - 2, h - 3)])

    return M
Exemple #13
0
def _interior_bar(w, h, floor_material):
    M = Map(w, h, fill_cell=floor_material)
    M[0, 0].put(T.furniture_table())
    M[1, 0].put(T.furniture_stool())
    for x in range(w//3, w):
        for y in (h//3, h//3*2+1):
            M[x, y].put(T.furniture_longtable())
    M.scatter(w//3, h//3-1, w, h//3+2, [T.furniture_stool() for _ in range(w-w//3)], exclude=[(w//3, h//3-1)])
    M.scatter(w//3, h//3*2, w, h//3*2+3, [T.furniture_stool() for _ in range(w-w//3)], exclude=[(w//3, h//3*2+2)])
    M[0, h-1].put(T.furniture_table())
    M[1, h-1].put(T.furniture_stool())
    M[w-1, h-1].put(T.light_lantern_oil())
    return M
def _room_rich_hall(w, h):
    """
    Construct luxury hall.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Place sofa, flowers, etc.
    M[1, 1] = C.flora_flower()
    M[w // 2, 1] = C.column_antique()
    M[w - 2, 1] = C.flora_flower()
    M[1, 2].put(T.furniture_sofa())
    M[w - 2, 2].put(T.furniture_sofa())
    M[w // 2 - 1, h - 2].put(T.furniture_chandelier())
    M[w // 2 + 1, h - 2].put(T.furniture_chandelier())
    M[2, 0] = C.door_closed()
    M[7, 0] = C.door_closed()
    M[w // 2, h - 1] = C.door_closed_wooden()
    return M
Exemple #15
0
def building_stables(w=16, h=16):
    """
    Construct stables with storage and two rows of horse boxes.

    Constraints:

        - Map width and map height must be >= 16 and <=23.

    Parameters
    ----------
    w : int
        Map width

    h : int
        Map height
    """

    # Initial checks. Don't accept too small/big stables
    if w < 16 or h < 16:
        raise ValueError('Building is too small: w or h < 16')
    elif w > 23 or h > 23:
        raise ValueError('Building is too big: w or h > 25')

    M = Map(w, h, fill_cell=C.floor_rocks)
    for x in range(w):
        for y in range(h):
            if random.random() > 0.75:
                M[x, y] = C.flora_grass()

    # Calculate w and h for storage, horse boxes and stables.
    horse_box_size_w = w // 2 - 4
    horse_box_size_h = 2
    stables_size_w = horse_box_size_w * 2 + 3
    stables_shift_h = (h - 1) % 3
    stables_size_h = h - stables_shift_h
    storage_size_w = w - stables_size_w + 1
    storage_size_h = h * 2 // 3
    storage_start_w = w - storage_size_w

    # Meld stables, storage, add dog.
    main_stables = room_horse_stables(stables_size_w, stables_size_h,
                                      horse_box_size_w, horse_box_size_h)
    M.meld(main_stables, 0, 0)
    main_storage = room_storage(storage_size_w, storage_size_h)
    M.meld(main_storage, storage_start_w, 0)
    M[w - (w - stables_size_w) // 2, storage_size_h].put(T.well())
    dog_place_x = random.randint(stables_size_w, w - 1)
    dog_place_y = random.randint(storage_size_h + 1, h - 1)
    M[dog_place_x, dog_place_y].put(A.animal_dog())
    if random.choice([True, False]):
        M.hmirror()

    return M
def _room_garden_beds(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=C.wall_fence, floor_type=floor_material)
    M[w - 2, 1].put(T.well())
    M[w - 2, h - 2].put(T.tool_wheelbarrow())
    for y in range(h // 2 - 2, h // 2):
        M[w - 2, y].put(T.farm_mangler())
    for y in range(h // 2 + 1, h - 5):
        M[w - 2, y].put(T.furniture_box_filled())
    seed_plot_h = h // 3
    agricultures = [
        random.choice([C.farm_corn, C.farm_wheat]),
        random.choice([C.farm_vegetables_leafs, C.farm_vegetables_cabbage]),
        random.choice([C.farm_vegetables, C.farm_vegetables_cabbage])
    ]
    for x in range(1, w - 3):
        for y in range(1, seed_plot_h):
            M[x, y] = agricultures[0]()
        for y in range(seed_plot_h + 1, seed_plot_h * 2):
            M[x, y] = agricultures[1]()
        for y in range(seed_plot_h * 2 + 1, h - 1):
            M[x, y] = agricultures[2]()
    M[w - 4, seed_plot_h].put(T.washtub())

    return M
Exemple #17
0
def _room_outdoor(w, h):
    M = Map(w, h, fill_cell=C.floor_rocks)
    for i in range(w*h//3):
        grass_x = random.randint(0, w-1)
        grass_y = random.randint(0, h-1)
        M[grass_x, grass_y] = random.choice([C.flora_grass, C.flora_tree, C.floor_grass])()
    for x in (1, 8):
        M[x, 0].put(T.furniture_table())
    for x in (0, 2, 7, 9):
        M[x, 0].put(T.furniture_stool())
    if w > 13:
        M[11, 0].put(T.furniture_table())
        M[10, 0].put(T.furniture_stool())
        M[12, 0].put(T.furniture_stool())
    for y in range(0, h):
        M[4, y] = C.floor_cobblestone()

    num_stables = (h - 5) // 2
    stables = Map(3, 2, fill_cell=C.void)
    for x in range(3):
        stables[x, 0] = C.wall_fence_thin()
    stables[2, 1] = C.wall_fence_thin()
    stables[0, 1] = C.door_close_fence()
    stables[1, 1].put(A.animal_horse())
    last_stable_y = h - 1
    for i in range(num_stables):
        stable_x = w - 3
        stable_y = 4 + (i * 2)
        M.meld(stables, stable_x, stable_y)
        last_stable_y = stable_y
    for x in range(w-3, w):
        M[x, last_stable_y + 2] = C.wall_fence_thin()
    M[2, h-1].put(T.sign_pointer())
    M[3, 0].put(T.light_torch())
    for y in (h//2-1, h//2):
        M[0, y].put(T.washtub())
    if w > 9:
        M[0, h//2+1].put(T.washtub())
    M[5, 0] = C.flora_flower()

    return M
def _room_big_office(w, h):
    """
    Construct big office only for employees.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Place lanterns and bookcases from the center to the right end of the room.
    M[w // 2, 0] = C.door_closed_bars()
    for y in range(1, h - 3, 2):
        M[w - 2, y].put(T.light_lantern_oil())
        for x in range(w // 2 + 1, w - 1):
            M[x, y + 1].put(T.furniture_bookcase())

    # Place tables, chairs, etc.
    for y in range(3, h - 1, 2):
        M[1, y].put(T.furniture_table())
        M[2, y].put(T.furniture_chair())
        M[3, y].put(T.light_lantern_oil())
        M[6, y].put(T.furniture_table())
        M[7, y].put(T.furniture_chair())
        if w > 26:
            M[10, y].put(T.furniture_table())
            M[11, y].put(T.furniture_chair())
    all_coord = []
    for item_class in (T.furniture_bookcase, T.book_clear, T.book,
                       T.furniture_bookcase, T.furniture_bookcase,
                       T.scroll_text):
        while True:
            x = random.randint(1, w // 2 - 2)
            y = 1
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break

    return M
Exemple #19
0
def _room_outdoor(w, h):
    M = Map(w, h, fill_cell=C.floor_rocks)
    for i in range(w * h // 3):
        grass_x = random.randint(1, w - 1)
        grass_y = random.randint(0, h - 2)
        M[grass_x, grass_y] = random.choice(
            [C.flora_grass, C.flora_tree, C.floor_grass])()
    M[w - 1, 0].put(T.washtub())
    for x in range(w):
        M[x, h - 1] = C.wall_fence_thin()
    for y in range(h - 1):
        M[0, y] = C.wall_fence_thin()
    for y in range(h - 1):
        M[3, y] = C.floor_rocks()
    M[3, h - 1] = C.door_close_fence()

    return M
Exemple #20
0
def _room_rich(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[random.randint(1, w-2), 1].put(T.furniture_bed_double())
    items = [
        T.furniture_chest_profile(),
        T.furniture_bookcase(),
        T.light_lantern_oil(),
        T.furniture_cabinet(),
        T.furniture_closet()
    ]
    M.scatter(1, 1, w-1, h-1, items, exclude=[(2, h-2), (2, h-3), (2, h-4), (1, h-3), (3, h-3)])
    M[2, h-1] = C.door_closed()
    return M
def _room_of_sacrifice(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=C.floor_flagged)
    M[w - 2, h // 2].put(T.magic_portal())
    items = [
        T.effect_blood(),
        T.effect_blood(),
        T.book_magic(),
        T.weapon_dagger(),
        T.bones_remains()
    ]
    M.scatter(1, 1, w - 2, h - 1, items, exclude=[(1, 2), (w - 2, h // 2)])

    return M
def _room_servant(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    for y in range(2, h - 1, 2):
        M[1, y].put(T.furniture_bed_single())
    num_table = 1 if h < 8 else h - 3
    for y in (1, num_table):
        M[w - 2, y].put(T.furniture_table_round())
        M[w - 3, y].put(T.furniture_stool())
        M[w - 2, y + 1].put(T.furniture_stool())
    items = [
        T.light_torch(),
        T.furniture_cabinet(),
        T.furniture_chest_profile()
    ]
    M.scatter(1, h - 3, w - 1, h - 1, items)
    M[2, 0] = C.door_closed_window()

    return M
def _room_second_bedroom(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[1, 1] = C.flora_flower()
    M[w - 3, 1].put(T.furniture_table())
    M[w - 2, 1].put(T.furniture_chair())
    M[1, h // 2].put(T.furniture_closet())
    items = [
        T.furniture_cabinet(),
        T.furniture_bed_single(),
        T.furniture_chandelier()
    ]
    M.scatter(1, h - 2, w - 1, h - 1, items)
    M[w - 1, h - 5] = C.door_closed()

    return M
Exemple #24
0
def _room_living(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[w - 2, h - 2].put(T.furniture_bed_double())
    M[1, h - 2].put(T.furniture_bed_single())
    M[1, h - 3].put(T.furniture_bed_single())
    num_of_items = (w - 2) * (h - 2) // 3
    items = [
        T.furniture_chest_profile(),
        T.furniture_torch(),
        T.furniture_cabinet(),
        T.furniture_basket()
    ]
    M.scatter(1,
              1,
              w - 1,
              h - 1,
              random.sample(items, min(len(items), num_of_items)),
              exclude=[(w - 3, 1), (w - 4, 1)])
    M[w - 3, 0] = C.door_open_empty()

    return M
def _room_bedroom(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    for x in range(1, w - 2):
        M[x, 1].put(T.furniture_longtable())
    M[2, 2].put(T.furniture_chair())
    M[w - 2, 1].put(T.furniture_bookcase())
    M[w - 2, h - 5].put(T.furniture_closet())
    M[1, h - 5].put(T.furniture_chandelier())
    M[2, h - 5].put(T.furniture_bed_double())
    M[w - 2, h // 3].put(T.urn())
    for x in range(1, w - 2):
        M[x, h - 4] = wall_material()
    M[w - 2, h - 4] = C.door_open_stairs()
    items = [
        T.light_lantern_oil(),
        T.magic_alchemisttable(),
        T.book_magic(),
        T.furniture_chair()
    ]
    M.scatter(1,
              h - 3,
              w - 1,
              h - 1,
              items,
              exclude=[(2, h - 3), (3, h - 3), (4, h - 3)])
    return M
def _room_poor_part(w, h):
    """
    Construct poor part of the bank.

    It consists small office rooms for employees and hall for poors.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Every small office has width=5 (with walls), except the last, so each small office will occupy 4 cells in width.
    num_of_small_office = w // 4

    # Calculate w-size of the last small office.
    shift_w = w % 4
    if shift_w == 1:
        small_room_w = 5
    elif shift_w == 2:
        small_room_w = 6
    elif shift_w == 3:
        small_room_w = 7
    elif shift_w == 0:
        small_room_w = 6

    # Place small office rooms.
    if shift_w == 1:
        # All small offices has an equal width and fill all width of the room.
        for cell_index in range(num_of_small_office):
            cell_x = cell_index * 4
            M_cell = _room_small_office(w=small_room_w, h=5)
            M.meld(M_cell, cell_x, 0)
    elif shift_w == 0:
        # The last small office is wider and there is the corridor to the main office in the end of the room.
        for cell_index in range(num_of_small_office - 1):
            cell_x = cell_index * 4
            M_cell = _room_small_office(w=5, h=5)
            M.meld(M_cell, cell_x, 0)
        M_room = _room_small_office(w=small_room_w, h=5)
        M.meld(M_room, (num_of_small_office - 2) * 4, 0)
        M[w - 2, 0] = C.floor_plank()
        M[w - 2, 4] = C.door_closed()
    else:
        # The last small office is wider and small offices fill all width of the room.
        for cell_index in range(num_of_small_office - 1):
            cell_x = cell_index * 4
            M_cell = _room_small_office(w=5, h=5)
            M.meld(M_cell, cell_x, 0)
        M_room = _room_small_office(w=small_room_w, h=5)
        M.meld(M_room, (num_of_small_office - 1) * 4, 0)

    # Place two longtables in right and left part of hall and some chairs.
    table_length = w // 3
    for x in range(1, table_length):
        M[x, h - 4].put(T.furniture_longtable())
    for x in range(1, table_length, 2):
        M[x, h - 3].put(T.furniture_stool())
    for x in range(w - table_length, w - 1):
        M[x, h - 4].put(T.furniture_longtable())
    for x in range(w - table_length, w - 1, 2):
        M[x, h - 3].put(T.furniture_stool())

    M[w // 2, h - 1] = C.door_closed()

    return M
Exemple #27
0
def _interior_vending(w, h, wall_material, floor_material):
    M = Map(w, h, fill_cell=floor_material)
    for x in range(w):
        M[x, 2].put(T.furniture_longtable_showcase())
    M[0, 1].put(T.money_pile())
    M[w//2, 1].put(T.dining_mug())
    for x in range(1, w, 2):
        M[x, 3].put(T.furniture_stool())
    M[1, h-1].put(T.furniture_barrel())
    M[2, h-1].put(T.furniture_barrel())
    if w > 7:
        M[w-2, h-1].put(T.furniture_table())
        M[w-1, h-1].put(T.furniture_stool())
        M[w-3, h-1].put(T.furniture_stool())
    if h > 6:
        for x in range(1, w-2, 3):
            for y in range(5, h-2, 3):
                M[x, y].put(T.furniture_table())
                M[x+1, y].put(T.furniture_stool())
    return M
Exemple #28
0
def building_hunter_robber_house(size=10, material=None, house_type=None):
    """
    Construct the hunter or robber house.

    Parameters
    ----------
    size : int
        Square map size. This attribute will be applied for both `w` and `h`.
    
    material : string
        Wall material. Can be "wooden", "stone" or None. If None, a random
        material will be chosen.

    house_type : string
        Type of the house. Can be "hunter" or "robber". If None, a random 
        type will be chosen.
    """

    # Initial check. Don't accept too small/big building
    if size < 8 or size > 17:
        raise ValueError(
            'Building is too small or too big: size < 8 or size > 17')

    # Choose materials
    if not material:
        material = random.choice(['wooden', 'stone'])
    if material not in ('wooden', 'stone'):
        raise ValueError('Material should be "stone" or "wooden"')
    wall_cell_type = C.wall_stone if material == 'stone' else C.wall_plank
    floor_cell_type = C.floor_flagged if material == 'stone' else C.floor_plank

    # Choose between robber house and hunter house
    if not house_type:
        house_type = random.choice(['robber', 'hunter'])
    if house_type not in ('robber', 'hunter'):
        raise ValueError('Type should be "robber" or "hunter"')

    M = Map(size, size, fill_cell=floor_cell_type)

    # Create outward walls
    for x in range(size):
        M[x, 0] = wall_cell_type()
        M[x, size - 1] = wall_cell_type()
    for y in range(size):
        M[0, y] = wall_cell_type()
        M[size - 1, y] = wall_cell_type()

    # Create door
    door_random = random.choice([True, False])
    door_param = size // 3 * 2
    if door_random:
        M[door_param, size - 1] = C.door_closed()
    else:
        M[0, door_param] = C.door_closed()

    # Place bonfire or hearth in the middle of the room. Place chairs
    M[size // 2 - 1, size // 2].put(T.furniture_chair())
    M[size // 2 + 1, size // 2].put(T.furniture_chair())
    if house_type == 'hunter':
        M[size // 2, size // 2].put(T.furniture_hearth())
    else:
        M[size // 2, size // 2].put(T.bonfire())

    # Randomly choose where escape is. Place stairs and wardrobes.
    escape = random.choice([True, False])
    if escape:
        M[size - 2, 1] = C.stairs_down()
        if house_type == 'robber':
            M[size - 3, 1].put(T.furniture_closet())
            M[size - 3, 2].put(T.furniture_closet())
            M[size - 2, 2].put(T.furniture_closet())
        elif house_type == 'hunter':
            M[size - 2, size - 2].put(T.furniture_closet())
    else:
        M[1, 1] = C.stairs_down()
        if house_type == 'robber':
            M[2, 1].put(T.furniture_closet())
            M[2, 2].put(T.furniture_closet())
            M[1, 2].put(T.furniture_closet())
        elif house_type == 'hunter':
            M[size - 2, size - 2].put(T.furniture_closet())

    # Place beds near walls
    beds_start = 1 if escape else size // 3 + 1
    beds_end = size // 2 if escape else size - 1
    if escape:
        for x in range(beds_start, beds_end + 1, 2):
            M[x, 1].put(T.furniture_bed_single())
    else:
        for x in range(beds_start + 1, beds_end, 2):
            M[x, 1].put(T.furniture_bed_single())

    # Place chests
    M[size - 2, size // 2 - 1].put(T.furniture_chest())
    M[size - 2, size // 2].put(T.furniture_chest())

    # Place table with chairs
    for x in range(size // 5, size // 2):
        M[x, size - 2].put(T.furniture_longtable())
    for x in range(size // 5 + 1, size // 2, 2):
        M[x, size - 3].put(T.furniture_chair())

    return M
def _room_library(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    for x in range(1, w // 2 - 1):
        M[x, 1].put(T.furniture_bookcase())
    for x in range(w // 2 + 1 + w % 2, w - 1):
        M[x, 1].put(T.furniture_bookcase())
    for x in (1, w - 2):
        M[x, 2].put(T.furniture_bookcase())
        M[x, h - 2] = C.column_antique()
    for x in (0, w - 1):
        M[x, 2] = C.door_open_stairs()
        M[x, h - 3] = C.door_closed()
    for x in range(w // 2 - 1, w // 2 + 1 + w % 2):
        M[x, 1].put(T.furniture_hearth())
        M[x, 3].put(T.furniture_sofa())
        M[x, h - 3].put(T.furniture_chair())
        M[x, h - 1] = C.door_open_empty()
    items = [T.book(), T.book()]
    M.scatter(2, 2, w - 2, 3, items)
    for x in range(3, w - 3):
        M[x, h - 4].put(T.furniture_longtable())
    for x in (2, w - 3):
        M[x, h - 4].put(T.furniture_chair())
    for x in (3, w - 4):
        M[x, h - 5].put(T.furniture_chandelier())

    return M
def _room_kitchen(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    for x in range(2, w - 1):
        M[x, h - 4].put(T.furniture_longtable())
    for x in range(3, w - 1):
        M[x, h - 2].put(T.furniture_box_filled())
    M[w - 2, h - 3].put(T.furniture_stool())
    for y in range(4, h - 5):
        M[1, y].put(T.furniture_barrel())
    M[w - 2, 5].put(T.furniture_hearth())
    M[1, h - 2].put(T.bucket())
    M[w - 2, 3] = C.stairs_down()
    M[1, 1].put(T.farm_mangler())
    items = [T.food_apple(), T.food_cheese(), T.food_chicken(), T.food_egg()]
    M.scatter(w - 2, 1, w - 1, h - 6, items, exclude=[(w - 2, 3)])

    return M