示例#1
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
示例#2
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