예제 #1
0
 def test_get(self):
     obj1 = Object('Test1')
     add_object(obj1)
     obj2 = Object('Test2')
     add_object(obj2)
     
     self.assertEqual(obj1, get_object('Test1'))
     self.assertEqual(obj2, get_object('Test2'))
     self.assertEqual(None, get_object('Test3'))
     
     
예제 #2
0
파일: Template.py 프로젝트: Orchaldir/Pyro
 def create_object(self):
     obj = Object(self.name + '_' + str(self.count))
 
     for type, data in self.components.iteritems():
         if type == 'Ai':
             obj.add_component(Ai(data['behavior']))
         elif type == 'Armor':
             obj.add_component(Armor(data))
         elif type == 'Body':
             if data['type'] == 'Big':
                 obj.add_component(Big(int(data['size']), data['tile']))
             elif data['type'] == 'Simple':
                 obj.add_component(Simple(data['tile']))
             elif data['type'] == 'Snake':
                 obj.add_component(Snake(int(data['length']), data['head_tile'], data['tail_tile']))
         elif type == 'Character':
             obj.add_component(Character(data))
         elif type == 'Consumable':
             obj.add_component(Consumable(data))
         elif type == 'Description':
             obj.add_component(Description(data))
         elif type == 'Equipment':
             obj.add_component(Equipment(data))
         elif type == 'EquipmentSlots':
             obj.add_component(EquipmentSlots(data))
         elif type == 'Health':
             obj.add_component(Health(data))
         elif type == 'Perception':
             obj.add_component(Perception(data))
         elif type == 'Weapon':
             obj.add_component(Weapon(data))
         elif type == 'Inventory':
             obj.add_component(Inventory())
         else:
             return  
 
     self.count = self.count + 1
     add_object(obj)
     return obj