예제 #1
0
 def test_clone(self):
     item = Item("thing", "description")
     item.aliases = ["a1", "a2"]
     item2 = util.clone(item)
     self.assertNotEqual(item, item2)
     item2.aliases.append("a3")
     self.assertNotEqual(item.aliases, item2.aliases)
     player = Player("julie", "f")
     player.insert(item, player)
     player2 = util.clone(player)
     player2.insert(item2, player2)
     self.assertNotEqual(player.inventory_size, player2.inventory_size)
     self.assertNotEqual(player.inventory, player2.inventory)
     self.assertTrue(item in player)
     self.assertFalse(item in player2)
예제 #2
0
파일: town.py 프로젝트: jordanaycamara/Tale
square = Location("Essglen Town square",
    """
    The old town square of Essglen. 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."


class CursedGem(Item):
    def move(self, target, actor, silent=False, is_player=False, verb="move"):
        if self.contained_in is actor and not "wizard" in actor.privileges:
            raise ActionRefused("The gem is cursed! It sticks to your hand, you can't get rid of it!")
        super(CursedGem, self).move(target, actor, verb=verb)


class InsertOnlyBox(Container):
    def remove(self, item, actor):
        raise ActionRefused("The box is cursed! You can't take anything out of it!")