# You could sniff the location's messages via a wiretap, but that often requires # nasty string parsing because they are messages meant for humans really. # We use pubsub to notify anyone interested. if npc.name == "rat": topic("shoppe-rat-arrival").send(npc) def notify_player_arrived(self, player: Player, previous_location: Location) -> None: # same as above, but for players entering the scene topic("shoppe-player-arrival").send(player) # create the Olde Shoppe and its owner shopinfo = ShopBehavior() toothpick = Item("toothpick", "pointy wooden toothpick") toothpick.value = 0.12 shopinfo.forsale.add(toothpick) # never run out of toothpicks shopinfo.banks_money = True shopkeeper = ShoppeShopkeeper( "Lucy", "f", short_descr= "Lucy, the shop owner, is looking happily at her newly arrived customer.") shopkeeper.money = 14000 shop = Shoppe("Curiosity Shoppe", "A weird little shop. It sells odd stuff.") shop.insert(shopkeeper, None) shop.get_wiretap().subscribe( shopkeeper ) # the shopkeeper wants to act on certain things happening in her shop. shop.add_exits([ Exit(["door", "out"], "town.lane",
Door.connect(street2, ["north", "gate", "playground"], "To the north there is a small gate that connects to the children's playground.", None, rose_st.playground, ["gate", "south"], "The gate that leads back to Magnolia Street is south.", None) Exit.connect(street2, ["south", "house", "neighbors"], "You can see the house from the neighbors across the street, to the south.", None, houses.neighbors_house, ["street", "north"], "The street is back north.", None) street2.add_exits([ Exit(["east", "crossing"], "rose_st.crossing", "There's a crossing to the east."), ]) street3.add_exits([ Exit(["west", "crossing"], "rose_st.crossing", "There's a crossing to the west.") ]) apothecary = Apothecary("carla", "f", title="apothecary Carla") apothecary.extra_desc["bottle"] = "It is a small bottle of the pills that your friend Peter needs for his illness." apothecary.extra_desc["pills"] = apothecary.extra_desc["bottle"] apothecary.aliases.add("apothecary") # the medicine Peter needs medicine = Item("pills", "bottle of pills", descr="It looks like the medicine your friend Peter needs for his illness.") medicine.value = Apothecary.pills_price medicine.aliases = {"bottle", "medicine"} apothecary.init_inventory([medicine]) pharmacy.insert(apothecary, None)
# creatures (NPCs) arriving in the shop. # You could sniff the location's messages via a wiretap, but that often requires # nasty string parsing because they are messages meant for humans really. # We use pubsub to notify anyone interested. if npc.name == "rat": topic("shoppe-rat-arrival").send(npc) def notify_player_arrived(self, player: Player, previous_location: Location) -> None: # same as above, but for players entering the scene topic("shoppe-player-arrival").send(player) # create the Olde Shoppe and its owner shopinfo = ShopBehavior() toothpick = Item("toothpick", "pointy wooden toothpick") toothpick.value = 0.12 shopinfo.forsale.add(toothpick) # never run out of toothpicks shopinfo.banks_money = True shopkeeper = ShoppeShopkeeper("Lucy", "f", short_descr="Lucy, the shop owner, is looking happily at her newly arrived customer.") shopkeeper.money = 14000 shop = Shoppe("Curiosity Shoppe", "A weird little shop. It sells odd stuff.") shop.insert(shopkeeper, None) shop.get_wiretap().subscribe(shopkeeper) # the shopkeeper wants to act on certain things happening in her shop. shop.add_exits([Exit(["door", "out"], "town.lane", "A fancy door provides access back to the lane outside.")]) # provide some items in the shop clock = gameclock.clone() clock.value = 500 paper = newspaper.clone() gem2 = diamond.clone()
deli = Location( "Deli", "A deli. It is completely empty, all the food and items seem to be gone.") Exit.connect(deli, ["lake drive", "outside", "street", "back"], "Lake drive is the street you came from.", None, street1, ["deli", "east"], "The east end of the street leads to a deli.", None) Exit.connect(lot, ["back"], "Go back home.", None, street1, ["lot", "parking"], "There is a parking lot next to the deli.", None) zombie = w = Zombie("zombie", random.choice("mf"), descr="A bloody zombie lingering around.") street1.insert(zombie, None) trader = Trader("Creepy Trader", "m", title="Creepy Trader") trader.extra_desc[ "bullets"] = "It is a a box of rounds with 5 bullets in it for your gun." trader.extra_desc["ammo"] = trader.extra_desc["bullets"] trader.aliases.add("trader") # ammo ammo = Item("ammo", "5 pistol bullets", descr="It looks like the ammo for your gun.") ammo.value = Trader.ammo_price ammo.aliases = {"bullets", "ammo"} trader.init_inventory([ammo]) deli.insert(trader, None)
"You can see the house from the neighbors across the street, to the south.", None, houses.neighbors_house, ["street", "north"], "The street is back north.", None) street2.add_exits([ Exit(["east", "crossing"], "rose_st.crossing", "There's a crossing to the east."), ]) street3.add_exits([ Exit(["west", "crossing"], "rose_st.crossing", "There's a crossing to the west.") ]) apothecary = Apothecary("carla", "f", title="apothecary Carla") apothecary.extra_desc[ "bottle"] = "It is a small bottle of the pills that your friend Peter needs for his illness." apothecary.extra_desc["pills"] = apothecary.extra_desc["bottle"] apothecary.aliases.add("apothecary") # the medicine Peter needs medicine = Item( "pills", "bottle of pills", descr="It looks like the medicine your friend Peter needs for his illness." ) medicine.value = Apothecary.pills_price medicine.aliases = {"bottle", "medicine"} apothecary.init_inventory([medicine]) pharmacy.insert(apothecary, None)