Ejemplo n.º 1
0
 def test_clone(self):
     item = Item("thing", "description")
     item.aliases = ["a1", "a2"]
     item2 = clone(item)
     self.assertNotEqual(item, item2)
     item2.aliases.append("a3")
     self.assertNotEqual(item.aliases, item2.aliases)
     player = Player("julie", "f")
     player.insert(item, player)
     with self.assertRaises(ValueError):
         clone(player)  # can't clone something with stuff in it
     player.remove(item, player)
     player2 = clone(player)
     player2.insert(item2, player2)
     self.assertNotEqual(player.inventory_size, player2.inventory_size)
     self.assertNotEqual(player.inventory, player2.inventory)
     self.assertFalse(item in player)
     self.assertFalse(item in player2)
Ejemplo n.º 2
0
 def test_clone(self):
     item = Item("thing", "description")
     item.aliases = ["a1", "a2"]
     item2 = clone(item)
     self.assertNotEqual(item, item2)
     item2.aliases.append("a3")
     self.assertNotEqual(item.aliases, item2.aliases)
     player = Player("julie", "f")
     player.insert(item, player)
     with self.assertRaises(ValueError):
         clone(player)   # can't clone something with stuff in it
     player.remove(item, player)
     player2 = clone(player)
     player2.insert(item2, player2)
     self.assertNotEqual(player.inventory_size, player2.inventory_size)
     self.assertNotEqual(player.inventory, player2.inventory)
     self.assertFalse(item in player)
     self.assertFalse(item in player2)
Ejemplo n.º 3
0
square = Location("Town square",
    """
    The old town square of the village. It is not much really, and narrow
    streets quickly lead away from the small fountain in the center.
    """)

lane = Location("Lane of Magicks",
    """
    A long straight road leading to the horizon. Apart from a nearby small tower,
    you can't see any houses or other landmarks. The road seems to go on forever though.
    """)

square.add_exits([Exit(["north", "lane"], lane, "A long straight lane leads north towards the horizon.")])

paper = clone(newspaper)
paper.aliases = {"paper"}
paper.short_description = "Last day's newspaper lies on the floor."

# add a bulletin board to the town
board = clone(bulletinboard)
board.posts = [
    {
        "author": "irmen",
        "date": "2015-05-23",
        "subject": "hello and welcome to this world",
        "text": "Hello all who read this! Welcome to this world."
    },
    {
        "author": "irmen",
        "date": "2015-05-23",
Ejemplo n.º 4
0
shopinfo.banks_money = True
shopkeeper = Shopkeeper(
    "Lucy",
    "f",
    short_description=
    "Lucy, the shop owner, is looking happily at her newly arrived customer.")
shopkeeper.money = 14000
shop = Location("Curiosity Shoppe", "A weird little shop. It sells odd stuff.")
shop.insert(shopkeeper, 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 = clone(gameclock)
clock.value = 500
paper = clone(newspaper)
gem2 = clone(diamond)
gem2.value = 80000
gem3 = clone(gem)
gem3.value = 9055
shopkeeper.init_inventory([gem2, gem3, toothpick])
shopkeeper.set_shop(shopinfo)
shop.insert(clock, shop)
shop.insert(paper, shop)
lamp = Item("lamp", "rather small lamp")
lamp.value = 600


class James(NPC, Listener):
Ejemplo n.º 5
0
# create the Olde Shoppe and its owner
shopinfo = ShopBehavior()
toothpick = Item("toothpick", "pointy wooden toothpick")
toothpick.value = 0.12
shopinfo.forsale.add(toothpick)
shopinfo.banks_money = True
shopkeeper = Shopkeeper("Lucy", "f", short_description="Lucy, the shop owner, is looking happily at her newly arrived customer.")
shopkeeper.money = 14000
shop = Location("Curiosity Shoppe", "A weird little shop. It sells odd stuff.")
shop.insert(shopkeeper, 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 = clone(gameclock)
clock.value = 500
paper = clone(newspaper)
gem2 = clone(diamond)
gem2.value = 80000
gem3 = clone(gem)
gem3.value = 9055
shopkeeper.init_inventory([gem2, gem3, toothpick])
shopkeeper.set_shop(shopinfo)
shop.insert(clock, shop)
shop.insert(paper, shop)
lamp = Item("lamp", "rather small lamp")
lamp.value = 600


class James(NPC, Listener):