예제 #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
예제 #2
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
예제 #3
0
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
예제 #4
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
예제 #5
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
예제 #6
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
예제 #7
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
예제 #8
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
예제 #9
0
def _room_shop(w, h, shop_type, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[w // 2, h - 1] = C.door_closed()
    M[1, h - 2].put(T.light_lantern_oil())

    shop_counter_h = h // 2 - 1

    for x in range(w - 3):
        cell_x = 2 + x
        M[cell_x, shop_counter_h].put(T.furniture_longtable_showcase())
    M[w - 2, shop_counter_h - 1].put(T.money_pile())

    type_items = {
        'food': [T.food_meat(), T.food_carrot(),
                 T.food_apple()],
        'jewelry': [T.necklace(), T.necklace_star(),
                    T.ring()],
        'clothe': [T.clothes_coat(),
                   T.clothes_hat(),
                   T.clothes_belt()],
        'weapon':
        [T.weapon_sword_rapier(),
         T.weapon_naginata(),
         T.weapon_crossbow()],
        'armor': [T.helmet(), T.armor_mail(),
                  T.clothes_belt()],
        'potion': [T.potion_health(),
                   T.potion_mana_empty(),
                   T.potion_magic()],
        'tool': [T.tool_tongs(),
                 T.tool_pickaxe(),
                 T.tool_broom()],
        'magic': [T.magic_orb(),
                  T.weapon_stave(),
                  T.potion_stamina()]
    }
    M.scatter(2, 1, w - 2, 2, type_items[shop_type])

    type_items = {
        'food': [
            T.furniture_box_filled(),
            T.furniture_box_filled(),
            T.bag(),
            T.food_milk()
        ],
        'jewelry': [T.mineral_crystal(),
                    T.bag(),
                    T.necklace(),
                    T.ring()],
        'clothe': [
            T.clothes_boots_right(),
            T.clothes_shirt(),
            T.clothes_shirt_inverted(),
            T.clothes_sweater()
        ],
        'weapon': [
            T.weapon_sword(),
            T.weapon_sword_saber(),
            T.weapon_spear(),
            T.weapon_dagger()
        ],
        'armor': [
            T.helmet(),
            T.armor_mail(),
            T.furniture_mannequin(),
            T.shield_buckler()
        ],
        'potion': [
            T.potion_magic_empty(),
            T.potion_stamina(),
            T.dining_bottle(),
            T.potion_health_empty()
        ],
        'tool': [
            T.tool_nails(),
            T.tool_scissors(),
            T.tool_fishingrod(),
            T.tool_pitchfork()
        ],
        'magic': [
            T.weapon_stave(),
            T.book_magic(),
            T.scroll_magic(),
            T.scroll_curled()
        ]
    }
    coord_exclude = [(x, y) for x in range(2, w - 2)
                     for y in range(shop_counter_h + 2, shop_counter_h + 4)]
    coord_exclude.append((w // 2, h - 2))

    M.scatter(2,
              shop_counter_h + 1,
              w - 1,
              h - 1,
              type_items[shop_type],
              exclude=coord_exclude)

    cat_place_x = random.randint(1, 2)
    cat_place_y = random.randint(shop_counter_h + 1, h - 3)
    M[cat_place_x, cat_place_y].put(A.animal_cat())

    return M
예제 #10
0
def room_shop(w, h, shop_type, wall_material, floor_material):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    M[w // 2, h - 1] = C.door_closed()
    M[1, h - 2].put(T.light_lantern_oil())

    shop_counter_h = h // 2 - 1

    for x in range(w - 3):
        cell_x = 2 + x
        M[cell_x, shop_counter_h].put(T.furniture_longtable_showcase())
    M[w - 2, shop_counter_h - 1].put(T.money_pile())

    type_items = {
        'food': [T.food_meat, T.food_carrot, T.food_apple],
        'jewelry': [T.necklace, T.necklace_star, T.ring],
        'clothe': [T.clothes_coat, T.clothes_hat, T.clothes_belt],
        'weapon':
        [T.weapon_sword_rapier, T.weapon_naginata, T.weapon_crossbow],
        'armor': [T.helmet, T.armor_mail, T.clothes_belt],
        'potion': [T.potion_health, T.potion_mana_empty, T.potion_magic],
        'tool': [T.tool_tongs, T.tool_pickaxe, T.tool_broom],
        'magic': [T.magic_orb, T.weapon_stave, T.potion_stamina]
    }
    all_coord = []
    for item_class in type_items[shop_type]:
        while True:
            x = random.randint(1, w // 2)
            y = 1
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break

    type_items = {
        'food':
        [T.furniture_box_filled, T.furniture_box_filled, T.bag, T.food_milk],
        'jewelry': [T.mineral_crystal, T.bag, T.necklace, T.ring],
        'clothe': [
            T.clothes_boots_right, T.clothes_shirt, T.clothes_shirt_inverted,
            T.clothes_sweater
        ],
        'weapon': [
            T.weapon_sword, T.weapon_sword_saber, T.weapon_spear,
            T.weapon_dagger
        ],
        'armor':
        [T.helmet, T.armor_mail, T.furniture_mannequin, T.shield_buckler],
        'potion': [
            T.potion_magic_empty, T.potion_stamina, T.dining_bottle,
            T.potion_health_empty
        ],
        'tool':
        [T.tool_nails, T.tool_scissors, T.tool_fishingrod, T.tool_pitchfork],
        'magic':
        [T.weapon_stave, T.book_magic, T.scroll_magic, T.scroll_curled]
    }
    all_coord = []
    for item_class in type_items[shop_type]:
        while True:
            x = random.randint(w // 2 + 1, w - 2)
            y = random.randint(shop_counter_h + 1, h - 2)
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break
    cat_place_x = random.randint(1, 2)
    cat_place_y = random.randint(shop_counter_h + 1, h - 3)
    M[cat_place_x, cat_place_y].put(A.animal_cat())

    return M