def speed_potion_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): o = filter(lambda x: x.icon != "w", creatures) for x in o: x.stun_timer = 3 news.append("you drank a speed potion. glug, glug") player.inventory.remove(self)
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) news.append("you threw your sheild... why?") player.inventory.remove(self)
def healing_potion_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): player.hp += 2 if player.hp > player.hp_limit: player.hp = player.hp_limit wlib.news.append("but you couldn't heal much") news.append("you drank a healing potion. glug, glug") player.inventory.remove(self)
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) news.append("you planted a flower") player.inventory.remove(self)
def destroy_wood(player, m): wood = [] p_neighbors = scan_map(player.x - 1, player.y - 1, 3, 3, m) wood = list(filter(lambda t: t[2] in (1, 8), p_neighbors)) if wood != []: wy, wx, tilenum = choice(wood) m[wy][wx] = 2 news.append("chop!") player.inventory.append(make_item("a piece of wood"))
def axe_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): junk = list(filter(lambda x: x.icon == "?", objects)) junk = map(lambda w: (w, wlib.distance(w, player)), junk) junk = list(filter(lambda b: b[1] <= 1, junk)) if junk == []: destroy_wood(player, m) else: b = min(junk, key=lambda t: t[1])[0] objects.remove(b) global_objects.remove(b) news.append("bash!") player.inventory.append(make_item("a piece of wood"))
def make_world(): m = [[2 for x in range(MAP_WIDTH)] for y in range(MAP_HEIGHT)] print("Building world...") objects = [] cs = [] build_world(mapgen.zones, m, objects, cs) #objects += gen_objects(m) coin = Object(randint(1, MAP_WIDTH), randint(1, MAP_HEIGHT), "$", 11, "a coin", "oooh, a coin") player = Creature(mapgen.ZONE_LENGTH, mapgen.ZONE_LENGTH, "w", 14, 3, "werewolf") player.inventory = [make_item("an apple")] cs += [player] atlas = make_atlas(m, 9) news.append("WELCOME TO WEREWOLF") return (m, player, objects, cs, atlas, 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) 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)
def apple_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): news.append("you ate an apple! munch munch") player.fullness += 20.0 player.inventory.remove(self)
def invisibility_potion_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): player.invisibility_timer = 8 news.append("you drank an invisibility potion. glug, glug") player.inventory.remove(self)
def strength_potion_effect(player, creatures, m, objects, global_objects, screen, global_cs, self): player.hp_limit += 1 news.append("you drank a strength potion. glug, glug") player.inventory.remove(self)