Example #1
0
    def validate_data(self, data):
        if 'tiles' not in data:
            raise BadFactoryData("tiles not found")
        elif not isinstance(data['tiles'], list):
            raise BadFactoryData("tiles is not a list")

        return True
Example #2
0
 def validate_data(self, data):
     if ('buildable_units' not in data):
         raise BadFactoryData("buildable_units not found")
     elif ('revenue' not in data):
         raise BadFactoryData("revenue not found")
     else:
         return True
Example #3
0
 def validate_data(self, data):
     if('spaces_per_turn' not in data):
         raise BadFactoryData("spaces_per_turn not found")
     elif('cost_table' not in data):
         raise BadFactoryData("cost_table not found")
     else:
         return True
Example #4
0
 def validate_data(self, data):
     if 'uses' not in data:
         raise BadFactoryData("uses not found")
     if 'attack_strength' not in data:
         raise BadFactoryData("attack_strength not found")
     else:
         return True
Example #5
0
 def validate_data(self, data):
     if 'cover' not in data:
         raise BadFactoryData("cover not found")
     elif 'non_passables' not in data:
         raise BadFactoryData("non_passables not found")
     elif 'events' not in data:
         raise BadFactoryData("events not found")
     else:
         return True
     return factory_data
Example #6
0
 def validate_data(self, data):
     if not self.transport_factory.can_make(data['transport']):
         raise BadFactoryData("transport_factory cannot make transport")
     elif not self.weapon_factory.can_make(data['weapon']):
         raise BadFactoryData("weapon_factory cannot make weapon")
     elif not self.armor_factory.can_make(data['armor']):
         raise BadFactoryData("armor_factory cannot make weapon")
     elif 'cost' not in data:
         raise BadFactoryData("cost not found")
     return True
Example #7
0
    def __init__(self, factory_data, creation_class):
        for data in factory_data:
            try:
                self.validate_data(factory_data[data])
            except BadFactoryData as e:
                raise BadFactoryData(
                    "Error creating {0}: {1}".format(data, e.message)
                )

        self.creation_class = creation_class
        self.factory_data = factory_data
        return
Example #8
0
 def validate_data(self, data):
     if ('starting_health' not in data):
         raise BadFactoryData("starting_health not found")
     else:
         return True