Exemple #1
0
 def testMoveSlots(self):
     from item import Item
     c = SlottedContainer()
     c.id = "container"
     c.slotNames = ['head','hand']
     thing = Item(id='thing')
     thing.fitsInSlots = ['hand','head']
     c.add(thing,'hand')
     self.assertEquals(c.slots['hand'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'hand')
     c.add(thing,'head')
     self.assertEquals(c.slots['head'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'head')
Exemple #2
0
 def testNonSlotted(self):
     from item import Item
     c = SlottedContainer()
     c.id = "container"
     thing = Item(id='thing')
     c.add(thing)
     self.assertEquals(thing.location(),c)
     self.assert_(thing in c.contains)
     c.remove(thing)
     self.assertFalse(thing.location)
     self.assertFalse('thing' in c.contains)
Exemple #3
0
 def testSlotted(self):
     from item import Item
     c = SlottedContainer()
     c.id = "container"
     c.slotNames = ['hand']
     thing = Item(id='thing')
     thing.fitsInSlots = ['hand']
     c.add(thing,'hand')
     self.assertEquals(c.slots['hand'](),thing)
     self.assertEquals(thing.location(),c)
     self.assertEquals(thing.locationSlot,'hand')
     c.remove(thing)
     self.assertFalse(thing.location)
     self.assertFalse(thing.locationSlot)
     self.assertRaises(GameException,c.add,thing,'head')