Exemple #1
0
 def test_exits(self):
     hall = Location("hall")
     attic = Location("attic")
     exit1 = Exit("ladder1", attic, "The first ladder leads to the attic.")
     exit2 = Exit("up", attic, "Second ladder to attic.")
     exit3 = Exit("ladder3", attic, "Third ladder to attic.")
     exit4 = Exit("window", attic, "A window.",
                  "A window, maybe if you open it you can get out?")
     hall.add_exits([exit1, exit2, exit3, exit4])
     self.assertTrue(hall.exits["up"] is exit2)
     self.assertTrue(hall.exits["ladder3"] is exit3)
     self.assertTrue(hall.exits["window"] is exit4)
     self.assertEqual([
         '[hall]',
         'The first ladder leads to the attic. Third ladder to attic. Second ladder to attic. A window.'
     ], strip_text_styles(hall.look()))
     self.assertEqual("Third ladder to attic.", exit3.description)
     self.assertEqual("A window, maybe if you open it you can get out?",
                      exit4.description)
     with self.assertRaises(ActionRefused):
         exit1.activate(None)
     with self.assertRaises(ActionRefused):
         exit1.deactivate(None)
     with self.assertRaises(ActionRefused):
         exit1.close(None, None)
     with self.assertRaises(ActionRefused):
         exit1.open(None, None)
     with self.assertRaises(ActionRefused):
         exit1.lock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.unlock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.manipulate("frobnitz", None)
     with self.assertRaises(ActionRefused):
         exit1.read(None)
Exemple #2
0
 def test_aliases(self):
     loc = Location("hall", "empty hall")
     exit = Exit("up", "attic", "ladder to attic")
     door = Door("door", "street", "door to street")
     exit2 = Exit(["down", "hatch", "manhole"], "underground",
                  "hatch to underground")
     door2 = Door(["east", "garden"], "garden", "door east to garden")
     self.assertEqual("up", exit.name)
     self.assertEqual("door", door.name)
     loc.add_exits([exit, door, exit2, door2])
     self.assertEqual(
         {"up", "door", "down", "hatch", "manhole", "east", "garden"},
         set(loc.exits.keys()))
     self.assertEqual(loc.exits["down"], loc.exits["hatch"])
Exemple #3
0
 def test_custom_verbs(self):
     player = Player("julie", "f")
     player.verbs["xywobble"] = "p1"
     monster = NPC("snake", "f")
     monster.verbs["snakeverb"] = "s1"
     room = Location("room")
     chair1 = Item("chair1")
     chair1.verbs["frobnitz"] = "c1"
     chair2 = Item("chair2")
     chair2.verbs["frobnitz"] = "c2"
     chair_in_inventory = Item("chair3")
     chair_in_inventory.verbs["kowabooga"] = "c3"
     box_in_inventory = Item("box")
     box_in_inventory.verbs["boxverb"] = "c4"
     player.init_inventory([box_in_inventory, chair_in_inventory])
     exit = Exit("e", "dummy", None, None)
     exit.verbs["exitverb"] = "c5"
     room.init_inventory([chair1, player, chair2, monster])
     room.add_exits([exit])
     custom_verbs = mud_context.driver.current_custom_verbs(player)
     all_verbs = mud_context.driver.current_verbs(player)
     self.assertEqual(
         {
             "xywobble", "snakeverb", "frobnitz", "kowabooga", "boxverb",
             "exitverb"
         }, set(custom_verbs))
     self.assertEqual(set(), set(custom_verbs) - set(all_verbs))
Exemple #4
0
 def test_socialize(self):
     player = Player("fritz", "m")
     attic = Location("Attic", "A dark attic.")
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     parsed = player.parse("wave all")
     self.assertEqual("wave", parsed.verb)
     self.assertEqual([julie], parsed.who_order)
     who, playermsg, roommsg, targetmsg = player.soul.process_verb_parsed(
         player, parsed)
     self.assertEqual({julie}, who)
     self.assertEqual("You wave happily at julie.", playermsg)
     with self.assertRaises(tale.soul.UnknownVerbException):
         player.parse("befrotzificate all and me")
     with self.assertRaises(NonSoulVerb) as x:
         player.parse("befrotzificate all and me",
                      external_verbs={"befrotzificate"})
     parsed = x.exception.parsed
     self.assertEqual("befrotzificate", parsed.verb)
     self.assertEqual([julie, player], parsed.who_order)
     attic.add_exits([Exit("south", "target", "door")])
     try:
         player.parse("push south")
         self.fail(
             "push south should throw a parse error because of the exit that is used"
         )
     except ParseError:
         pass
     with self.assertRaises(NonSoulVerb):
         player.parse("fart south")
     parsed = player.parse("hug julie")
     player.validate_socialize_targets(parsed)
Exemple #5
0
 def setUp(self):
     mud_context.driver = TestDriver()
     mud_context.config = DemoStory()._get_config()
     self.hall = Location("Main hall", "A very large hall.")
     self.attic = Location("Attic", "A dark attic.")
     self.street = Location("Street", "An endless street.")
     e1 = Exit("up", self.attic, "A ladder leads up.")
     e2 = Exit(
         ["door", "east"], self.street,
         "A heavy wooden door to the east blocks the noises from the street outside."
     )
     self.hall.add_exits([e1, e2])
     self.table = Item(
         "table", "oak table",
         "a large dark table with a lot of cracks in its surface")
     self.key = Item("key",
                     "rusty key",
                     "an old rusty key without a label",
                     short_description="Someone forgot a key.")
     self.magazine = Item("magazine", "university magazine")
     self.magazine2 = Item("magazine", "university magazine")
     self.rat = NPC("rat", "n", race="rodent")
     self.rat2 = NPC("rat", "n", race="rodent")
     self.fly = NPC("fly",
                    "n",
                    race="insect",
                    short_description="A fly buzzes around your head.")
     self.julie = NPC("julie",
                      "f",
                      title="attractive Julie",
                      description="She's quite the looker.")
     self.julie.aliases = {"chick"}
     self.player = Player("player", "m")
     self.pencil = Item("pencil", title="fountain pen")
     self.pencil.aliases = {"pen"}
     self.bag = Container("bag")
     self.notebook_in_bag = Item("notebook")
     self.bag.insert(self.notebook_in_bag, self.player)
     self.player.insert(self.pencil, self.player)
     self.player.insert(self.bag, self.player)
     self.hall.init_inventory([
         self.table, self.key, self.magazine, self.magazine2, self.rat,
         self.rat2, self.julie, self.player, self.fly
     ])
Exemple #6
0
def make_exit(c_exit: SimpleNamespace) -> Exit:
    """Create an instance of a door or exit for the given circle exit"""
    if c_exit.type in ("normal", "pickproof"):  # @todo other door types? reverse doors? locks/keys?
        door = Door(c_exit.direction, make_location(c_exit.roomlink), c_exit.desc)
        door.aliases |= c_exit.keywords
        return door
    else:
        exit = Exit(c_exit.direction, make_location(c_exit.roomlink), c_exit.desc)
        exit.aliases |= c_exit.keywords
        return exit
Exemple #7
0
def make_exit(c_exit):
    """Create an instance of a door or exit for the given circle exit"""
    if c_exit.type in ("normal", "pickproof"):
        xt = Door(c_exit.direction, make_location(c_exit.roomlink),
                  c_exit.desc)
    else:
        xt = Exit(c_exit.direction, make_location(c_exit.roomlink),
                  c_exit.desc)
    xt.aliases |= c_exit.keywords
    return xt
Exemple #8
0
 def test_message_nearby_location(self):
     plaza = Location("plaza")
     road = Location("road")
     house = Location("house")
     attic = Location("attic")
     plaza.add_exits([
         Exit("north", road, "road leads north"),
         Exit("door", house, "door to a house")
     ])
     road.add_exits([Exit("south", plaza, "plaza to the south")])
     house.add_exits([
         Exit("door", plaza, "door to the plaza"),
         Exit("ladder", attic, "dusty attic")
     ])
     attic.add_exits([Exit("ladder", house, "the house")])
     wiretap_plaza = Wiretap(plaza)
     wiretap_road = Wiretap(road)
     wiretap_house = Wiretap(house)
     wiretap_attic = Wiretap(attic)
     plaza.message_nearby_locations("boing")
     pubsub.sync()
     self.assertEqual([], wiretap_plaza.msgs,
                      "the plaza doesnt receive tells")
     self.assertEqual([], wiretap_attic.msgs,
                      "the attic is too far away to receive msgs")
     self.assertTrue(("road", "boing") in wiretap_road.msgs)
     self.assertTrue(("road", "The sound is coming from the south.")
                     in wiretap_road.msgs,
                     "road should give sound direction")
     self.assertTrue(("house", "boing") in wiretap_house.msgs)
     self.assertTrue(
         ("house", "You can't hear where the sound is coming from.")
         in wiretap_house.msgs,
         "in the house you can't locate the sound direction")
Exemple #9
0
    def test_bind_exit(self):
        class ModuleDummy(object):
            pass

        zones = ModuleDummy()
        zones.town = ModuleDummy()
        zones.town.square = Location("square")
        exit = Exit("square", "town.square", "someplace")
        self.assertFalse(exit.bound)
        exit._bind_target(zones)
        self.assertTrue(exit.bound)
        self.assertTrue(zones.town.square is exit.target)
        exit._bind_target(zones)
Exemple #10
0
    def test_title_name(self):
        door = Door("north",
                    "hall",
                    "a locked door",
                    locked=True,
                    opened=False)
        self.assertEqual("north", door.name)
        self.assertEqual("Exit to <unbound:hall>", door.title)
        exit = Exit("outside", "town.square", "someplace")
        self.assertEqual("outside", exit.name)
        self.assertEqual("Exit to <unbound:town.square>", exit.title)

        class ModuleDummy(object):
            pass

        zones = ModuleDummy()
        zones.town = ModuleDummy()
        zones.town.square = Location("square")
        exit._bind_target(zones)
        self.assertEqual("Exit to square", exit.title)
        self.assertEqual("exit to square", exit.name)
Exemple #11
0
 def test_destroy_loc(self):
     ctx = Context(None, None, None, None)
     loc = Location("loc")
     i = Item("item")
     liv = Living("rat", "n", race="rodent")
     loc.add_exits([Exit("north", "somewhere", "exit to somewhere")])
     player = Player("julie", "f")
     player.privileges = {"wizard"}
     player.create_wiretap(loc)
     loc.init_inventory([i, liv, player])
     self.assertTrue(len(loc.exits) > 0)
     self.assertTrue(len(loc.items) > 0)
     self.assertTrue(len(loc.livings) > 0)
     self.assertEqual(loc, player.location)
     self.assertEqual(loc, liv.location)
     loc.destroy(ctx)
     self.assertTrue(len(loc.exits) == 0)
     self.assertTrue(len(loc.items) == 0)
     self.assertTrue(len(loc.livings) == 0)
     self.assertEqual(_limbo, player.location)
     self.assertEqual(_limbo, liv.location)
Exemple #12
0
 def test_nearby(self):
     plaza = Location("plaza")
     road = Location("road")
     house = Location("house")
     alley = Location("alley")  # no exits
     attic = Location("attic")
     plaza.add_exits([
         Exit("north", road, "road leads north"),
         Exit("door", house, "door to a house"),
         Exit("west", alley, "small alleywith no way back")
     ])
     road.add_exits([Exit("south", plaza, "plaza to the south")])
     house.add_exits([
         Exit("door", plaza, "door to the plaza"),
         Exit("ladder", attic, "dusty attic")
     ])
     attic.add_exits([Exit("ladder", house, "the house")])
     adj = set(plaza.nearby())
     self.assertSetEqual({road, house}, adj)
     adj = set(plaza.nearby(no_traps=False))
     self.assertSetEqual({road, house, alley}, adj)
Exemple #13
0
drone.aggressive = True

hall.init_inventory([table, key, drone])

attic = Location("Tower attic",
    """
    The dark and dusty attic of the wizard tower.
    There are piles of old scrolls and assorted stuff here of which you assume
    it once held great magical power. All of it is now covered with a thick
    layer of dust.
    """)
attic.add_extradesc({"dust", "stuff", "scrolls"}, "The scrolls look ancient. One looks like a spell!")
attic.add_extradesc({"spell"}, "The scroll looks like it contains a spell, but on closer inspection, it has become too faded to be understood anymore.")


kitchen = Location("Tower kitchen",
    """
    A cozy little kitchen for hungry wizards.
    Magically conjured food often tastes like cardboard, so even wizards need to
    prepare their meals the old-fashioned way. The kitchen looks small but tidy.
    """)

hall.add_exits([
    Exit(["up", "ladder"], attic, "A small ladder leads up through a hole in the ceiling."),
    Exit(["door", "east"], "town.lane", "A heavy wooden door to the east blocks the noises from the street outside."),
    Exit("north", kitchen, "A door to the north leads to the kitchen.")
])

kitchen.add_exits([Exit("south", hall, "A door to the south leads back to the hall.")])
attic.add_exits([Exit(["down", "ladder"], hall, "A small ladder leads back down to the hall.")])
Exemple #14
0
Their pet cat is also here and you can interact with him a little.

The generated demo code below is provided for you to use or modify as you wish.
(it creates a trivial location similar to the built-in demo story of the Tale library itself)
"""

from tale.base import Location, Exit, Door
from zones.sarah import Sarah
from zones.descriptions import room_descriptions, sarah_text

##### Lobby #####

foyer = Location(name="Foyer", descr=room_descriptions['foyer'])
# Build Exits
foyer_closet = Exit(directions="closet",
                    target_location="inn.foyer_closet",
                    short_descr="There is a small closet in the foyer.",
                    long_descr=None)

foyer_sitting = Exit(directions=["north", "sitting"],
                     target_location="inn.sitting_room",
                     short_descr="There is a sitting room to the north.",
                     long_descr="""Through the archway you can see a cozy
                                   room flickering to the light of a fire.""")

foyer.add_exits([foyer_closet, foyer_sitting])

# Insert items & npcs

##### Foyer Closet #####
foyer_closet = Location("Foyer Closet", "A small closet.")
Exemple #15
0
livingroom_descr = """
    The living room in your home in the outskirts of the city."""
livingroom = Location(name="Living room", descr=livingroom_descr)
# Build Exits
garden_door = Door(
    directions=["garden", "door"],
    target_location="house.outside",
    short_descr="A door leads to the garden.",
    long_descr=
    "There's a heavy door here that leads to the garden outside the house.",
    locked=True,
    opened=False,
    key_code="1")

lr_closet = Exit(directions="closet",
                 target_location="house.closet",
                 short_descr="There is a small closet in your house.",
                 long_descr=None)

livingroom.add_exits([garden_door, lr_closet])

# Insert items & npcs
livingroom.insert(cat, None)
livingroom.insert(elastic_band.clone(), None)

##### Closet #####
closet = Location("Closet", "A small room.")

closet_lr = Exit(
    directions=["living room", "back", "livingroom"],
    target_location="house.livingroom",
    short_descr="You can see the living room where you came from.",
Exemple #16
0
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()
gem2.value = 80000
gem3 = gem.clone()
gem3.value = 9055
stick = woodenYstick.clone()
elastic = elastic_band.clone()
shopkeeper.init_inventory([gem2, gem3, toothpick, stick, elastic])
shopkeeper.set_shop(shopinfo)
Exemple #17
0
    "magnolia_st.street1",
    "Your front door leads outside, to the street.",
    "There's a heavy front door here that leads to the streets outside.",
    opened=False)
house_door = front_door.reverse_door(
    ["house", "north", "inside"],
    livingroom,
    "You can go back inside your house.",
    "It's your house, on the north side of the street.",
    reverse_open_msg="Someone outside opens the door.",
    reverse_close_msg="Someone outside closes the door.",
    this_open_msg="Someone in the house opens the door.",
    this_close_msg="Someone in the house closes the door.")
livingroom.add_exits([
    Exit(
        "kitchen", kitchen, "Your kitchen is adjacent to this room.",
        "You can see your kitchen. The previous house owners had a door there but you removed it."
    ), front_door
])

kitchen.add_exits([
    Exit(["living room", "livingroom", "back"], livingroom,
         "The living room is back the way you entered.")
])

# ----------------- Neighbours House, Bedroom, Garden  -------------------------

neighbors_house = Location("Neighbor's House",
                           "The house of your neighbors across the street.")

bedroom = Location(
    "Bedroom",
Exemple #18
0
        # Normally you would use notify_player_arrived() to trigger an action.
        # but for the game ending, we require an immediate response.
        # So instead we hook into the direct arrival of something in this location.
        super(GameEnd, self).insert(obj, actor)
        try:
            obj.story_completed()   # player arrived! Great Success!
        except AttributeError:
            pass


north_street = Location("Rose Street", "The northern part of Rose Street.")
south_street = Location("Rose Street", "The southern part of Rose Street.")

crossing = Location("Crossing", "Town Crossing.")
crossing.add_exits([
    Exit("west", "magnolia_st.street2", "Westwards lies Magnolia Street."),
    Exit("east", "magnolia_st.street3", "Magnolia Street extends to the east, eventually leading towards the factory."),
    Exit("north", north_street, "A part of Rose Street lies to the north."),
    Exit("south", south_street, "Rose Street continues to the south.")
])

playground = Location("Playground", "Children's playground. You see a rusty merry-go-round, and a little swing. "
                                    "To the west, a house is visible.")
playground.add_extradesc({"west", "house"}, "You can see your house from here!")
playground.add_exits([
    Door("fence", _limbo, "On the north end of the playground is a sturdy looking padlocked fence.", locked=True, opened=False),  # this door is never meant to be opened
    Exit(["east", "street"], north_street, "Rose Street is back east."),
    zones.magnolia_st.street_gate
])

carpark = Location("Car Parking", "There are a few cars still parked over here. Their owners are nowhere to be seen. "
Exemple #19
0

def init(driver):
    # called when zone is first loaded
    pass


street1 = Location("Magnolia Street", "Your house is on Magnolia Street, one of the larger streets in town. "
                                      "The rest of the town lies eastwards.")
street2 = Location("Magnolia Street", "Another part of the street.")
street3 = Location("Magnolia Street (east)", "The eastern part of Magnolia Street.")


pharmacy = Location("Pharmacy", "A pharmacy.")
pharmacy.add_exits([
    Exit(["east", "outside", "street"], street1, "Magnolia street is outside towards the east.")
])

factory = Location("ArtiGrow factory", "This area is the ArtiGrow fertilizer factory.")
factory.add_exits([
    Exit(["west", "street"], street3, "You can leave the factory to the west, back to Magnolia Street.")
])


street1.add_exits([
    houses.house_door,
    Exit(["pharmacy", "west"], pharmacy, "The west end of the street leads to the pharmacy."),
    Exit(["town", "east"], street2, "The street extends eastwards, towards the rest of the town.")
])

playground_gate = Door(["north", "gate", "playground"], "rose_st.playground", "To the north there is a small gate that connects to the children's playground.", opened=False)
Exemple #20
0
    def test_actions(self):
        player = Player("julie", "f")
        hall = Location("hall")
        attic = Location("attic")
        unbound_exit = Exit("random", "foo.bar", "a random exit")
        with self.assertRaises(Exception):
            self.assertFalse(unbound_exit.allow_passage(
                player))  # should fail because not bound
        exit1 = Exit("ladder", attic, "first ladder to attic")
        exit1.allow_passage(player)

        door = Door("north",
                    hall,
                    "open unlocked door",
                    locked=False,
                    opened=True)
        with self.assertRaises(ActionRefused) as x:
            door.open(player)  # fail, it's already open
        self.assertEqual("It's already open.", str(x.exception))
        door.close(player)
        self.assertFalse(door.opened, "must be closed")
        with self.assertRaises(ActionRefused) as x:
            door.lock(player)  # default door can't be locked
        self.assertEqual("You don't seem to have the means to lock it.",
                         str(x.exception))
        with self.assertRaises(ActionRefused) as x:
            door.unlock(player)  # fail, it's not locked
        self.assertEqual("It's not locked.", str(x.exception))

        door = Door("north",
                    hall,
                    "open locked door",
                    locked=False,
                    opened=True)
        with self.assertRaises(ActionRefused) as x:
            door.open(player)  # fail, it's already open
        self.assertEqual("It's already open.", str(x.exception))
        door.close(player)
        door.locked = True
        with self.assertRaises(ActionRefused) as x:
            door.lock(player)  # it's already locked
        self.assertEqual("It's already locked.", str(x.exception))
        self.assertTrue(door.locked)
        with self.assertRaises(ActionRefused) as x:
            door.unlock(player)  # you can't unlock it
        self.assertEqual("You don't seem to have the means to unlock it.",
                         str(x.exception))
        self.assertTrue(door.locked)

        door = Door("north",
                    hall,
                    "closed unlocked door",
                    locked=False,
                    opened=False)
        door.open(player)
        self.assertTrue(door.opened)
        door.close(player)
        self.assertFalse(door.opened)
        with self.assertRaises(ActionRefused) as x:
            door.close(player)  # it's already closed
        self.assertEqual("It's already closed.", str(x.exception))

        door = Door("north",
                    hall,
                    "closed locked door",
                    locked=True,
                    opened=False)
        with self.assertRaises(ActionRefused) as x:
            door.open(player)  # can't open it, it's locked
        self.assertEqual("You try to open it, but it's locked.",
                         str(x.exception))
        with self.assertRaises(ActionRefused) as x:
            door.close(player)  # it's already closed
        self.assertEqual("It's already closed.", str(x.exception))

        door = Door("north", hall, "Some door.")
        self.assertEqual("Some door.", door.short_description)
        self.assertEqual("Some door. It is open and unlocked.",
                         door.description)
        self.assertTrue(door.opened)
        self.assertFalse(door.locked)
        door = Door("north", hall, "Some door.",
                    "This is a peculiar door leading north.")
        self.assertEqual("Some door.", door.short_description)
        self.assertEqual(
            "This is a peculiar door leading north. It is open and unlocked.",
            door.description)
Exemple #21
0
    "and assorted stuff here of which you assume it once held great magical power. "
    "All of it is now covered with a thick layer of dust.")
attic.add_extradesc({"dust", "stuff", "scrolls"},
                    "The scrolls look ancient. One looks like a spell!")
attic.add_extradesc(
    {"spell"},
    "The scroll looks like it contains a spell, but on closer inspection, "
    "it has become too faded to be understood anymore.")

kitchen = Location(
    "Tower kitchen", "A cozy little kitchen for hungry wizards. "
    "Magically conjured food often tastes like cardboard, so even wizards need to prepare "
    "their meals the old-fashioned way. The kitchen looks small but tidy.")

Exit.connect(hall, ["up", "ladder"],
             "A small ladder leads up through a hole in the ceiling.", None,
             attic, ["down", "ladder"],
             "A small ladder leads back down to the hall.", None)

Exit.connect(hall, ["north", "kitchen"],
             "A door to the north leads to the kitchen.", None, kitchen,
             ["south", "hall"], "A door to the south leads back to the hall.",
             None)

hall.add_exits([
    Exit(
        ["door", "east"], "town.lane",
        "A heavy wooden door to the east blocks the noises from the street outside."
    ),
])
Exemple #22
0
    "The living room in your home in the outskirts of the city.")
closet = Location("Closet", "A small room.")
outside = GameEnd("Outside", "It is beautiful weather outside.")

# define the exits that connect the locations

door = Door(
    ["garden", "door"],
    outside,
    "A door leads to the garden.",
    "There's a heavy door here that leads to the garden outside the house.",
    locked=True,
    opened=False)
door.key_code = 1
# use an exit with an unbound target (string), the driver will link this up:
closet_exit = Exit("closet", "house.closet",
                   "There's a small closet in your house.")
livingroom.add_exits([door, closet_exit])
# use another exit with a bound target (object):
closet.add_exits(
    [Exit("living room", livingroom, "You can see the living room.")])

# define items and NPCs


class Cat(NPC):
    def init(self):
        self.aliases = {"cat"}
        mud_context.driver.defer(4, self.do_purr)

    def do_purr(self, ctx):
        if random.random() > 0.5:
Exemple #23
0
    "key",
    "small rusty key",
    descr=
    "This key is small and rusty. It has a label attached, reading \"garden door\"."
)

rooms = {
    'livingroom':  ####### Living Room
    {
        'location': {
            'name': "Living room",
            'descr': "The living room in your home in the new testing story."
        },
        'exits': [
            Exit(directions="closet",
                 target_location="house.closet",
                 short_descr="There's a small closet in your house.",
                 long_descr=None),
        ],
        'doors': [
            Door(directions=["garden", "door"],
                 target_location="house.outside",
                 short_descr="A door leads to the garden.",
                 long_descr="There's a heavy door in this test.",
                 locked=True,
                 opened=False,
                 key_code="1"),
            Door(
                directions=["bathroom"],
                target_location="house.bathroom",
                short_descr="A door leads to the bathroom.",
                long_descr=None,
Exemple #24
0
class RemoveOnlyBox(Container):
    def insert(self, item: Union[Living, Item], actor: Optional[Living]) -> None:
        raise ActionRefused("No matter how hard you try, you can't fit %s in the box." % item.title)


insertonly_box = InsertOnlyBox("box1", "box1 (a black box)")
removeonly_box = RemoveOnlyBox("box2", "box2 (a white box)")
normal_gem = gem.clone()
removeonly_box.init_inventory([normal_gem])

cursed_gem = CursedGem("black gem")
cursed_gem.aliases = {"gem"}
normal_gem = Item("blue gem")
normal_gem.aliases = {"gem"}
lane.add_exits([Exit(["shop", "north east", "northeast", "ne"], "shoppe.shop", "There's a curiosity shop to the north-east.")])


class WizardTowerEntry(Exit):
    def allow_passage(self, actor: Living) -> None:
        if "wizard" in actor.privileges:
            actor.tell("You pass through the force-field.", end=True)
        else:
            raise ActionRefused("You can't go that way, the force-field is impenetrable.")


lane.add_exits([WizardTowerEntry("west", "wizardtower.hall",
                                 "To the west is the wizard's tower. It seems to be protected by a force-field.")])

towncrier = TownCrier("laish", "f", title="Laish the town crier",
                      descr="The town crier is awfully quiet today. She seems rather preoccupied with something.")
Exemple #25
0
        raise ActionRefused(
            "No matter how hard you try, you can't fit %s in the box." %
            item.title)


insertonly_box = InsertOnlyBox("box1", "box1 (a black box)")
removeonly_box = RemoveOnlyBox("box2", "box2 (a white box)")
normal_gem = gem.clone()
removeonly_box.init_inventory([normal_gem])

cursed_gem = CursedGem("black gem")
cursed_gem.aliases = {"gem"}
normal_gem = Item("blue gem")
normal_gem.aliases = {"gem"}
lane.add_exits([
    Exit(["shop", "north east", "northeast", "ne"], "shoppe.shop",
         "There's a curiosity shop to the north-east.")
])


class WizardTowerEntry(Exit):
    def allow_passage(self, actor: Living) -> None:
        if "wizard" in actor.privileges:
            actor.tell("You pass through the force-field.", end=True)
        else:
            raise ActionRefused(
                "You can't go that way, the force-field is impenetrable.")


lane.add_exits([
    WizardTowerEntry(
        "west", "wizardtower.hall",
Exemple #26
0
    "Neighbor's Garden", "The garden of your neighbor across the street. "
    "Behind some trees to the south you see what appears to be a storage building of a shop."
)
garden.add_extradesc({"ladder"}, "It leads up towards a window.")
garden.add_extradesc({
    "trees", "south", "building"
}, "The building behind the trees could very well be the meat storage room of the butcher shop in town."
                     )

Exit.connect(
    garden, ["ladder", "up"],
    "A ladder leads up towards a window in the house.", None, bedroom,
    ["ladder", "down"],
    "The ladder that is placed outside of the window provides access down to the garden below.",
    None)

Exit.connect(garden, ["house", "doors"],
             "The garden doors are open and lead back to the house.", None,
             neighbors_house, ["garden", "doors"],
             "The garden doors are open and lead to... the garden.", None)

Exit.connect(neighbors_house, ["up", "stairs"],
             "Up the stairs is the bedroom.", None, bedroom, "stairs",
             "Stairs lead back to the rest of the house.", None)

# oneway route to get back on the street from the garden:
garden.add_exits([
    Exit(["fence", "street"], "magnolia_st.street2",
         "You can step over a low fence back onto the street if you wish."),
])
Exemple #27
0
import zones.houses
import zones.npcs

from tale.base import Location, Exit, Door, Key, Living, ParseResult, _limbo
from tale.items.basic import Money
from tale.errors import ParseError, ActionRefused, StoryCompleted
from tale.util import call_periodically, Context
from tale import mud_context


north_street = Location("Rose Street", "The northern part of Rose Street.")
south_street = Location("Rose Street", "The southern part of Rose Street.")

crossing = Location("Crossing", "Town Crossing.")
crossing.add_exits([
    Exit("west", "magnolia_st.street2", "Westwards lies Magnolia Street."),
    Exit("east", "magnolia_st.street3", "Magnolia Street extends to the east, eventually leading towards the factory."),
])

Exit.connect(crossing, "north", "A part of Rose Street lies to the north.", None,
             north_street, ["south", "crossing"], "The street goes south towards the crossing.", None)
Exit.connect(crossing, "south", "Rose Street continues to the south.", None,
             south_street, ["north", "crossing"], "The crossing is back towards the north.", None)

playground = Location("Playground", "Children's playground. You see a rusty merry-go-round, and a little swing. "
                                    "To the west, a house is visible.")
playground.add_extradesc({"west", "house"}, "You can see your house from here!")
playground.add_exits([
    Door("fence", _limbo, "On the north end of the playground is a sturdy looking padlocked fence.",
         locked=True, opened=False, key_code="999999999"),  # this door is never meant to be opened
])
Exemple #28
0
             "The street extends to the west, where your house is.", None)

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(