Exemple #1
0
def gen_objects(m, z, startx, endx, starty, endy):
    print("    * generating objects...")
    objectz = []
    print("    *    items...")
    for x in range(int(ZONE_LENGTH * ZONE_LENGTH * z.perc_p)):
        f = filter(lambda n: n != "a flower", list(items.keys()))
        i = choice(list(f))
        effect, icon, color, cost = items[i]
        potion = wlib.Object(0, 0, icon, color, i, i,
                             randint(cost - 1, cost + 1))
        #potion.effect = effect
        if potion.name == "a chest":
            for x in range(3):
                potion.inventory.append(make_item(choice(list(items.keys()))))
        potion = wlib.spawn_thing(potion, m)

        objectz.append(potion)
    print("    *    junks...")
    for x in range(NUM_JUNKS):
        junk = wlib.Object(0, 0, "?", 10, " ", " ")
        junk = wlib.spawn_thing(junk, m)

        tile_num = m[junk.y][junk.x]
        tile = display.tiles[tile_num]
        tile_icon = tile[0]

        if if_outdoors(tile_icon):
            junklist = o_junks
        else:
            junklist = i_junks

        junk.description = choice(junklist)

        objectz.append(junk)
    return objectz
Exemple #2
0
def gen_objects(m):
    objectz = []
    for x in range(NUM_POTIONS):
        px = randint(1, MAP_WIDTH - 1)
        py = randint(1, MAP_HEIGHT - 1)
        p, effect = choice(potions)
        potion = wlib.Object(px, py, "8", 13, p, p)
        potion.effect = effect

        objectz.append(potion)
    for x in range(NUM_JUNKS):
        r1 = randint(1, MAP_WIDTH - 1)
        r2 = randint(1, MAP_HEIGHT - 1)
        tile_num = m[r2][r1]

        tile = display.tiles[tile_num]
        tile_icon = tile[0]

        if if_outdoors(tile_icon):
            junklist = o_junks
        else:
            junklist = i_junks
        junk = wlib.Object(r1, r2, "?", 10, choice(junklist), choice(junklist))
        objectz.append(junk)
    return objectz
Exemple #3
0
def sheild_effect(player, creatures, m, objects, global_objects, screen,
                  global_cs, self):
    sheild = wlib.Object(player.x, player.y, "]", 7, "a sheild", "a sheild")
    objects.append(sheild)
    global_objects.append(sheild)
    globals.news.append("you threw your sheild... why?")
    player.inventory.remove(self)
Exemple #4
0
def forest(m, startx, starty, endx, endy, objects):
    print("    * Constructing forest...")
    for x in range(30000):
        m[randint(starty, endy)][randint(startx, endx)] = 8
    objects.extend(
        gen_items(m, startx, starty, 5000,
                  wlib.Object(0, 0, "6", 14, "an apple", "an apple", 5)))
Exemple #5
0
def flower_effect(player, creatures, m, objects, global_objects, screen,
                  global_cs, self):
    flower = wlib.Object(player.x, player.y, "*", 14, "a flower",
                         "that flower smells good")
    objects.append(flower)
    global_objects.append(flower)
    globals.news.append("you planted a flower")
    player.inventory.remove(self)
Exemple #6
0
def plains(m, startx, starty, endx, endy, objects):
    print("    * Constructing plains...")
    building_zone(m, startx, starty, endx, endy, 400, 10, 10, 15, 15)
    objects.extend(
        gen_items(
            m, startx, starty, 1000,
            wlib.Object(0, 0, "*", 14, "a flower", "that flower smells good",
                        1)))
Exemple #7
0
def shoot(player, objects, global_objects, xv, yv, m, creatures, global_cs):
    a = wlib.Object(player.x, player.y, "/", 1, "an arrow", "an arrow")
    for x in range(5):
        a.y += yv
        a.x += xv
        cl = list(filter(lambda x: misc.collide(x, a), creatures))
        if cl != []:
            c = cl[0]
            if c.icon == "v":
                wlib.kill_v(c, player, objects, global_objects, m, creatures,
                            global_cs)
            else:
                creatures.remove(c)
                globals.news.append("you killed a guard")
                body = wlib.Object(c.x, c.y, "%", 1, "",
                                   "A dead villager. Eeeewwww.")
                objects.append(body)
        elif m[a.y][a.x] not in wlib.walkable() or list(
                filter(lambda x: misc.collide(x, a), objects)) != []:
            a.y -= yv
            a.x -= xv
            break
    objects.append(a)
    global_objects.append(a)
Exemple #8
0
def spawn_villagers(m, cs, z, startx, endx, starty, endy):
    print("    * spawning villagers")
    for x in range(int(ZONE_LENGTH * ZONE_LENGTH * z.perc_v)):  #10, 0.005
        villager = wlib.Creature(0, 0, "v", 5, mode="wander")
        wlib.spawn_thing(villager, m, startx, endx, starty, endy)
        r_i = []
        for x in range(3):
            i = choice(list(items.keys()))
            effect, icon, color, cost = items[i]
            item = wlib.Object(0, 0, icon, color, i, i,
                               randint(cost - 1, cost + 1))
            #item.effect = effect
            r_i.append(item)
        villager.name = choice(["Gerald", "Sathy", "Randy", "Joshua"])
        villager.inventory = r_i
        cs.append(villager)
Exemple #9
0
def make_item(name, x=0, y=0):
    i = items[name]
    new_obj = wlib.Object(x, y, i[1], i[2], name, name)
    new_obj.cost = randint(i[3] - 1, i[3] + 1)
    #new_obj.effect = i[1]
    return new_obj