コード例 #1
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
コード例 #2
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
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #6
0
def _room_storage(w, h, shop_type, wall_material, floor_material, shop_left):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    storage_part_h = h // 2
    for x in range(w):
        M[x, storage_part_h] = wall_material()
    M[w // 2, storage_part_h] = C.door_closed_window()
    M[0, 1] = C.door_open_empty()
    bed_items = [
        T.furniture_bed_single(),
        T.furniture_torch(),
        T.furniture_chest_profile()
    ]
    M.scatter(1,
              storage_part_h + 1,
              w - 1,
              h - 1,
              bed_items,
              exclude=[(w // 2, storage_part_h + 1),
                       (w // 2, storage_part_h + 2)])

    type_items = {
        'food': [
            T.furniture_barrel(),
            T.furniture_barrel(),
            T.food_cheese(),
            T.food_egg(),
            T.food_pumpkin()
        ],
        'jewelry': [
            T.necklace(),
            T.mineral_diamond(),
            T.necklace_cross(),
            T.material_ingot(),
            T.ring()
        ],
        'clothe': [
            T.clothes_gloves_left(),
            T.clothes_downjacket(),
            T.clothes_hat(),
            T.clothes_belt(),
            T.clothes_overalls()
        ],
        'weapon': [
            T.weapon_sword(),
            T.weapon_halberd(),
            T.weapon_maul(),
            T.weapon_sling(),
            T.weapon_club()
        ],
        'armor': [
            T.clothes_shirt(),
            T.armor_mail(),
            T.helmet(),
            T.shield(),
            T.shield_tower()
        ],
        'potion': [
            T.dining_bottle(),
            T.potion_health(),
            T.potion_mana(),
            T.potion_stamina(),
            T.furniture_flowers_pot()
        ],
        'tool': [
            T.tool_wateringcan(),
            T.tool_rake(),
            T.tool_hoe(),
            T.tool_saw(),
            T.tool_fishingrod()
        ],
        'magic': [
            T.book_magic(),
            T.weapon_stave(),
            T.scroll_curled(),
            T.scroll_magic(),
            T.magic_orb()
        ]
    }
    coord_exclude = [(w // 2, storage_part_h - 1), (2, storage_part_h - 2),
                     (2, storage_part_h - 3), (2, storage_part_h - 4), (1, 1)]
    M.scatter(1,
              1,
              w - 1,
              storage_part_h,
              type_items[shop_type],
              exclude=coord_exclude)
    return M
コード例 #7
0
ファイル: building_shop.py プロジェクト: igroglaz/urizen
def room_storage(w, h, shop_type, wall_material, floor_material, shop_left):
    M = room_default(w, h, wall_type=wall_material, floor_type=floor_material)
    storage_part_h = h // 2
    for x in range(w):
        M[x, storage_part_h] = wall_material()
    M[w // 2, storage_part_h] = C.door_closed_window()
    M[0, 1] = C.door_open_empty()

    all_coord = [(w // 2, storage_part_h + 1)]
    for item_class in (T.furniture_bed_single, T.furniture_torch,
                       T.furniture_chest_profile):
        while True:
            x = random.randint(1, w - 2)
            y = random.randint(storage_part_h + 1, h - 2)
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break

    type_items = {
        'food': [
            T.furniture_barrel, T.furniture_barrel, T.food_cheese, T.food_egg,
            T.food_pumpkin
        ],
        'jewelry': [
            T.necklace, T.mineral_diamond, T.necklace_cross, T.material_ingot,
            T.ring
        ],
        'clothe': [
            T.clothes_gloves_left, T.clothes_downjacket, T.clothes_hat,
            T.clothes_belt, T.clothes_overalls
        ],
        'weapon': [
            T.weapon_sword, T.weapon_halberd, T.weapon_maul, T.weapon_sling,
            T.weapon_club
        ],
        'armor':
        [T.clothes_shirt, T.armor_mail, T.helmet, T.shield, T.shield_tower],
        'potion': [
            T.dining_bottle, T.potion_health, T.potion_mana, T.potion_stamina,
            T.furniture_flowers_pot
        ],
        'tool': [
            T.tool_wateringcan, T.tool_rake, T.tool_hoe, T.tool_saw,
            T.tool_fishingrod
        ],
        'magic': [
            T.book_magic, T.weapon_stave, T.scroll_curled, T.scroll_magic,
            T.magic_orb
        ]
    }
    all_coord = [(w // 2, storage_part_h - 1), (1, 1)]
    for item_class in type_items[shop_type]:
        while True:
            x = random.randint(1, w - 2)
            y = random.randint(1, storage_part_h - 1)
            if (x, y) not in all_coord:
                M[x, y].put(item_class())
                all_coord.append((x, y))
                break
    return M