Пример #1
0
def _room_kitchen(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    storage = room_default(6, 6, wall_type=wall_material, floor_type=floor_material)
    M.meld(storage, 0, 0)
    M[5, h-3] = C.door_open_empty()
    M[10, h-1] = C.door_open_empty()
    M[7, 0] = C.door_closed_window()
    for x in range(1, 3):
        for y in range(1, 3):
            M[x, y] = C.flora_mushroom_button()
    storage_items = [
        T.furniture_barrel(),
        T.furniture_barrel(),
        T.furniture_barrel(),
        T.furniture_barrel(),
        T.furniture_box_filled(),
        T.furniture_box_filled(),
        T.bag(),
        T.food_leaf()
    ]
    storage_w = 6
    M.scatter(1, 1, 5, h-1, storage_items, exclude=[
        (storage_w-2, h-3),
        (storage_w-3, h-3),
        (storage_w-4, h-3),
        (storage_w-3, h-4),
        (1, 1),
        (1, 2),
        (2, 1),
        (2, 2)
    ])
    for x in range(8, 11):
        M[x, 1].put(T.furniture_hearth())
    for x in range(8, 11):
        M[x, 3].put(T.furniture_table())
    M[13, 1] = C.stairs_down()
    M[11, 1].put(T.bucket())
    for y in range(1, 3):
        M[6, y].put(T.food_meat())
    M[6, 4].put(T.food_egg())
    M[11, 3].put(T.furniture_box_filled())
    M.scatter(6, 1, 14, 5, [A.animal_cat()])
    if w > 15:
        num_of_items = (w - 15) * 2
        food_items = [
            T.furniture_barrel(),
            T.furniture_barrel(),
            T.furniture_barrel(),
            T.furniture_box_filled(),
            T.furniture_box_filled(),
            T.bag()
        ]
        M.scatter(15, 1, w-1, h-1, random.sample(food_items, min(len(food_items), num_of_items)))
    return M
Пример #2
0
def _room_main(w, h, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[1, h - 2].put(T.furniture_closet())
    M[w - 2,
      1].put(random.choice([T.furniture_chimney(),
                            T.furniture_hearth()]))
    M[w - 2, 2].put(random.choice([T.food_meat(), T.food_egg()]))
    for x in (w - 3, w - 4):
        M[x, 1].put(T.furniture_longtable())
    M[w - 5, 1].put(random.choice([T.bucket(), T.bag()]))
    M[w - 2, h - 2].put(T.furniture_chest_profile())
    lantern_w = random.randint(5, w - 4)
    M[lantern_w, h - 2].put(T.light_lantern())
    M[3, h - 1] = C.door_closed()
    if w >= 11:
        table_h = 1 if h <= 7 else h // 2 - 1
        M[4, table_h].put(T.furniture_table())
        M[3, table_h].put(T.furniture_stool())
        M[5, table_h].put(T.furniture_stool())
        M[4, table_h + 1].put(T.furniture_stool())
        if table_h > 1:
            pantry = _interior_pantry(3, h // 3, wall_material, floor_material)
            M.meld(pantry, 1, 1)
    elif w < 11:
        pantry = _interior_pantry(3, h // 3, wall_material, floor_material)
        M.meld(pantry, 1, 1)

    return M
Пример #3
0
def _room_vault(w, h):
    """
    Construct vault with treasures.
    """
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)
    # Place treasures in the vault
    # There are 11 types of items. We fill 60% of vault cells with items in the equal proportion.
    number_of_items = int(((w - 2) * (h - 2) * 0.6) // 11)
    all_coord = [(w // 2, h - 2)]
    for item_class in (
            T.material_ingot,
            T.money_pile,
            T.money_coin,
            T.bag,
            T.mineral_crystal,
            T.mineral_diamond,
            T.necklace,
            T.ring,
            T.scroll_text,
            T.furniture_chest,
            T.furniture_chest_full,
    ):
        for _ in range(number_of_items):
            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
Пример #4
0
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
Пример #5
0
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
Пример #6
0
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
Пример #7
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
Пример #8
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
Пример #9
0
def room_horse_stables(w, h, horse_box_size_w, horse_box_size_h):
    """
    Construct big stable with horse boxes.

    The stable consits of some small horse boxes with animal or without.
    """
    M = room_default(w, h, wall_type=C.wall_plank, floor_type=C.floor_rocks)
    number_of_horse_box = (h - 1) // 3

    # Place left and right rows of horse boxes.
    for y in range(number_of_horse_box):
        cell_y = 1 + (y * 3)
        left_stable = room_horse_box(horse_box_size_w, horse_box_size_h)
        M.meld(left_stable, 1, cell_y)
        right_stable = room_horse_box(horse_box_size_w,
                                      horse_box_size_h,
                                      orientation='right')
        M.meld(right_stable, horse_box_size_w + 2, cell_y)

        # Place fence after every horse box, except the last.
        if y == 0:
            continue
        for x in range(1, horse_box_size_w + 1):
            M[x, cell_y - 1] = C.wall_fence()
        for x in range(horse_box_size_w + 2, w - 1):
            M[x, cell_y - 1] = C.wall_fence()
    M[w // 2, h - 1] = C.door_open_empty()
    return M
Пример #10
0
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
Пример #11
0
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
Пример #12
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
Пример #13
0
def building_roadhouse(w=15, h=15, wall_material=None, floor_material=None):
    """
    Construct roadhouse with living room for poor, kitchen/storage and saloon.

    Constraints:

        - Map width and map height must be >= 15.
        - Map width and map height must be <= 21.

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

    h : int
        Map height
    """
    # Initial checks. Don't accept too small/big inn
    if w < 15 or h < 15:
        raise ValueError('Building is too small: w or h < 15')
    elif w > 21 or h > 21:
        raise ValueError('Building is too big: w or h > 21')
    # Choose materials
    if not wall_material:
        wall_material = random.choice([C.wall_block, C.wall_plank, C.wall_brick, C.wall_stone])
    elif wall_material not in (['block', 'plank', 'brick', 'stone']):
        raise ValueError('Wall material should be "block", "plank", "brick" or "stone"')
    if wall_material == 'block':
        wall_material = C.wall_block
    elif wall_material == 'plank':
        wall_material = C.wall_plank
    elif wall_material == 'brick':
        wall_material = C.wall_brick
    elif wall_material == 'stone':
        wall_material = C.wall_stone

    if not floor_material:
        floor_material = random.choice([C.floor_dirt, C.floor_parquet, C.floor_cobblestone])
    elif floor_material not in (['dirt', 'parquet', 'cobblestone']):
        raise ValueError('Floor material should be "dirt", "parquet" or "cobblestone"')
    if floor_material == 'dirt':
        floor_material = C.floor_dirt
    elif floor_material == 'parquet':
        floor_material = C.floor_parquet
    elif floor_material == 'cobblestone':
        floor_material = C.floor_cobblestone
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[13, h-1] = C.door_closed_window()
    kitchen = _room_kitchen(w, 6, wall_material, floor_material)
    M.meld(kitchen, 0, 0)
    living_room = _room_living(9, h-5, wall_material, floor_material)
    M.meld(living_room, 0, 5)
    vending = _interior_vending(w-10, h-7, wall_material, floor_material)
    M.meld(vending, 9, 6)

    return M
Пример #14
0
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
Пример #15
0
def _room_poor(w, h, wall_material, floor_material, direction='right'):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[w-1, 1] = C.door_closed()
    room_items = {
        'default_room': [T.furniture_bed_single(), T.furniture_chest_profile(), T.furniture_torch()],
        'default_room_2': [T.furniture_bed_single(), T.furniture_cabinet(), T.furniture_torch()],
        'poor_room': [T.furniture_napsack(), T.light_candle(), T.web()],
        'poor_room_2': [T.furniture_napsack(), T.furniture_chair()]
    }
    M.scatter(1, 1, w-1, h-1, random.choice(list(room_items.values())), exclude=[(w-2, 1)])
    if direction == 'left':
        M.hmirror()
    return M
Пример #16
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
Пример #17
0
def building_bank(w=21, h=21, direction='down'):
    """
    Construct bank with big vault, employee office, rich part and poor part.

    Rich part consists of two private rooms and luxury hall. Poor part consists of small office rooms and big hall.

    Constraints:

        - Map width and map height must be >= 19 and <= 31.

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

    h : int
        Map height
    """

    # Initial checks. Don't accept too small/big bank
    if w < 19 or h < 19:
        raise ValueError('Building is too small: w or h < 16')
    elif w > 31 or h > 31:
        raise ValueError('Building is too big: w or h > 25')
    M = room_default(w,
                     h,
                     wall_type=C.wall_dungeon_smooth,
                     floor_type=C.floor_plank)

    # Calculate office and vault heights based upon map height.
    office_h = (h - 11) // 2 + 1
    vault_h = office_h if h % 2 == 1 else office_h + 1

    # Meld rooms and vault.
    M.meld(_room_vault(w, vault_h), 0, 0)
    M.meld(_room_big_office(w, office_h), 0, vault_h - 1)
    M.meld(_room_private(6, 7), 0, vault_h + office_h - 2)
    M.meld(_room_private(6, 7), 5, vault_h + office_h - 2)
    M.meld(_room_rich_hall(11, 5), 0, vault_h + office_h + 4)
    building_poor_w = w - 10
    M.meld(_room_poor_part(building_poor_w, 11), 10, vault_h + office_h - 2)

    if direction == 'up':
        M.vmirror()
    elif direction == 'left':
        M.transpose()
    elif direction == 'right':
        M.transpose()
        M.hmirror()

    return M
Пример #18
0
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
Пример #19
0
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
Пример #20
0
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
Пример #21
0
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
Пример #22
0
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
Пример #23
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
Пример #24
0
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
Пример #25
0
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
Пример #26
0
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
Пример #27
0
def building_inn(w=22, h=22, wall_material=None, floor_material=None, has_exterior=True):
    """
    Construct inn with living room for poor, living room for rich, kitchen/storage, big saloon and outdoor.

    Constraints:

        - Map width and map height must be >= 22
        - Map width and map height must be <= 27.

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

    h : int
        Map height
    """
    # Initial checks. Don't accept too small/big inn
    if w < 22 or h < 22:
        raise ValueError('Building is too small: w or h < 22')
    elif w > 27 or h > 27:
        raise ValueError('Building is too big: w or h > 27')
    # Choose materials
    if not wall_material:
        wall_material = random.choice([C.wall_block, C.wall_plank, C.wall_brick, C.wall_stone])
    elif wall_material not in (['block', 'plank', 'brick', 'stone']):
        raise ValueError('Wall material should be "block", "plank", "brick" or "stone"')
    if wall_material == 'block':
        wall_material = C.wall_block
    elif wall_material == 'plank':
        wall_material = C.wall_plank
    elif wall_material == 'brick':
        wall_material = C.wall_brick
    elif wall_material == 'stone':
        wall_material = C.wall_stone

    if not floor_material:
        floor_material = random.choice([C.floor_dirt, C.floor_parquet, C.floor_cobblestone])
    elif floor_material not in (['dirt', 'parquet', 'cobblestone']):
        raise ValueError('Floor material should be "dirt", "parquet" or "cobblestone"')
    if floor_material == 'dirt':
        floor_material = C.floor_dirt
    elif floor_material == 'parquet':
        floor_material = C.floor_parquet
    elif floor_material == 'cobblestone':
        floor_material = C.floor_cobblestone

    # Calculate main room h. We have three situations: rich room h = 5, 6, 7.
    # If rich room h = 6 or 7, we expand main room h + 1 or + 2.
    main_room_h = 13 + (h - 1) % 3
    kitchen_w = 15
    M = room_default(w, h, wall_type=C.void, floor_type=C.void)
    main_room = room_default(w, main_room_h, wall_type=wall_material, floor_type=floor_material)
    M.meld(main_room, 0, 0)
    M[kitchen_w-2, main_room_h-1] = C.door_closed_window()
    for y in range(5, main_room_h-3):
        M[kitchen_w-1, y] = wall_material()
    kitchen = _room_kitchen(kitchen_w, 6, wall_material, floor_material)
    M.meld(kitchen, 0, 0)
    living_room = _room_living(9, h-5, wall_material, floor_material)
    M.meld(living_room, 0, 5)
    private_room = _room_private(w-kitchen_w+1, 4, wall_material, floor_material)
    M.meld(private_room, kitchen_w-1, 0)
    vending = _interior_vending(5, main_room_h-7, wall_material, floor_material,)
    M.meld(vending, 9, 6)
    bar = _interior_bar(w-kitchen_w-1, main_room_h-5, floor_material,)
    M.meld(bar, kitchen_w, 4)
    if has_exterior:
        outdoor = _room_outdoor(w-9, h - main_room_h)
        M.meld(outdoor, 9, main_room_h)

    return M
Пример #28
0
def building_mansion_symmetric(w=25,
                               h=25,
                               wall_material=None,
                               floor_material=None,
                               direction='down'):
    """
    Construct medieval mansion with living rooms, kitchen, library, treasury, servant's room and outdoor.

    Constraints:

        - Map width and map height must be >= 20
        - Map width and map height must be <= 25
        - Wall material must be 'block', 'plank', 'brick' or 'stone'.
        - Floor material must be 'dirt', 'parquet' or 'cobblestone'.

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

    h : int
        Map height

    wall_material : str
        Wall's material.

    floor_material : str
        Floor's material.

    direction : str
        Direction of the house. Can be 'up', 'down', 'left' or 'right'.
    """
    # Initial checks. Don't accept too small/big house
    if w < 20 or h < 20:
        raise ValueError('Building is too small: w or h < 20')
    elif w > 25 or h > 25:
        raise ValueError('Building is too big: w or h > 25')
    # Choose materials
    if not wall_material:
        wall_material = random.choice(
            [C.wall_block, C.wall_plank, C.wall_brick, C.wall_stone])
    elif wall_material not in (['block', 'plank', 'brick', 'stone']):
        raise ValueError(
            'Wall material should be "block", "plank", "brick" or "stone"')
    if wall_material == 'block':
        wall_material = C.wall_block
    elif wall_material == 'plank':
        wall_material = C.wall_plank
    elif wall_material == 'brick':
        wall_material = C.wall_brick
    elif wall_material == 'stone':
        wall_material = C.wall_stone

    if not floor_material:
        floor_material = random.choice(
            [C.floor_dirt, C.floor_parquet, C.floor_cobblestone])
    elif floor_material not in (['dirt', 'parquet', 'cobblestone']):
        raise ValueError(
            'Floor material should be "dirt", "parquet" or "cobblestone"')
    if floor_material == 'dirt':
        floor_material = C.floor_dirt
    elif floor_material == 'parquet':
        floor_material = C.floor_parquet
    elif floor_material == 'cobblestone':
        floor_material = C.floor_cobblestone

    M = room_default(w, h, wall_type=wall_material, floor_type=C.void)
    default_room_w = w // 4 + 1
    default_room_h = h // 4
    library_h = h // 2 - 1
    second_bedroom_h = h // 4 + 2

    treasury = _room_treasury(default_room_w, default_room_h, wall_material,
                              floor_material)
    M.meld(treasury, 0, 0)
    bedroom = _room_bedroom(default_room_w,
                            h - second_bedroom_h - default_room_h + 2,
                            wall_material, floor_material)
    M.meld(bedroom, 0, default_room_h - 1)
    second_bedroom = _room_second_bedroom(default_room_w, second_bedroom_h,
                                          wall_material, floor_material)
    M.meld(second_bedroom, 0, h - second_bedroom_h)
    sacrifice = _room_of_sacrifice(default_room_w, default_room_h,
                                   wall_material, floor_material)
    M.meld(sacrifice, w - default_room_w, 0)
    kitchen = _room_kitchen(default_room_w, h - default_room_h * 2 + 1,
                            wall_material, floor_material)
    M.meld(kitchen, w - default_room_w, default_room_h - 1)
    servant = _room_servant(default_room_w, default_room_h + 1, wall_material,
                            floor_material)
    M.meld(servant, w - default_room_w, h - default_room_h - 1)
    library = _room_library(w - default_room_w * 2 + 2, library_h,
                            wall_material, floor_material)
    M.meld(library, default_room_w - 1, 0)
    garden = _interior_garden(w - default_room_w * 2, h - library_h - 1,
                              wall_material, floor_material)
    M.meld(garden, default_room_w, library_h)
    for x in range(w // 2 - 1, w // 2 + 1 + w % 2):
        M[x, h - 1] = C.door_closed_wooden()
    if random.choice([True, False]):
        M.hmirror()
    if direction == 'up':
        M.vmirror()
    elif direction == 'left':
        M.transpose()
    elif direction == 'right':
        M.transpose()
        M.hmirror()

    return M
Пример #29
0
def building_ruined_house(w=6, h=6, material=None):
    """
    Construct ruined house.
    It contain chimney, barrel and some animal.

    Constraints:

        - Map width and map height must be >= 6 and <= 10.

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

    h : int
        Map height
    """

    # Initial checks. Don't accept too small/big house.
    if w < 6 or h < 6:
        raise ValueError('Building is too small: w or h < 6')
    elif w > 10 or h > 10:
        raise ValueError('Building is too big: w or h > 10')

    # Choose materials
    wall_material = None
    if not material:
        wall_material = random.choice(
            [C.wall_block, C.wall_plank, C.wall_stone, C.wall_brick])
    elif material not in (['block', 'plank', 'stone', 'brick']):
        raise ValueError(
            'Material should be "block", "plank", "stone" or "brick"')

    if material == 'stone':
        wall_material = C.wall_stone
    elif material == 'block':
        wall_material = C.wall_block
    elif material == 'plank':
        wall_material = C.wall_plank
    elif material == 'brick':
        wall_material = C.wall_brick

    M = room_default(w, h, wall_type=wall_material, floor_type=C.floor_rocks)

    # Calculate % of replaced walls and added grass. 10% for walls and 20% for grass.
    grass_count = int((w - 2) * (h - 2) * 0.2)
    wall_ruined = int(w * h * 0.1)
    M[w // 2, h - 1] = C.door_open_dark()

    # Place some furniture and animals.
    all_coord = [(w // 2, h - 1), (w // 2, h - 2)]
    for item_class in (T.furniture_chimney, A.animal_bat, A.animal_spider,
                       T.web, T.furniture_barrel):
        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

    # Place some grass.
    for _ in range(grass_count):
        while True:
            x = random.randint(0, w - 1)
            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

    # Replace some walls with rocks.
    for _ in range(wall_ruined):
        while True:
            x = random.randint(0, w - 1)
            y = random.choice([0, h - 1])
            if (x, y) not in all_coord:
                M[x, y] = C.floor_rocks()
                all_coord.append((x, y))
                break

    return M
Пример #30
0
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