Beispiel #1
0
 def add_construction_plan(self, new_plan, level):
     for planned_construct in self.construction_plans:
         if new_plan == planned_construct.name:
             planned_construct.level = level
             return
     for construction in BUILDINGS.values() + STATIONS.values():
         if new_plan == construction.name \
                 and getattr(self, construction.name).level < level:
             self.construction_plans.append(construction.__class__(level))
             return
Beispiel #2
0
    def dump(self):
        dump = {'name': self.name,
                'coords': self.coords,
                'idle': self.idle,
                'position': self.position,
                'waiting_for': self.waiting_for,
                'capital': self.capital,
                'fleet': self.fleet.dump(),
                'resources': self.resources.dump(),
        }

        for constru in BUILDINGS.values() + STATIONS.values():
            dump[constru.name] = getattr(self, constru.name).level
        return dump
Beispiel #3
0
    def __init__(self, name, coords, position, **kwargs):
        self.name = name
        self.coords = coords
        self.position = position
        self.idle = kwargs.get('idle', False)
        self.capital = kwargs.get('capital', False)
        self.waiting_for = kwargs.get('waiting_for', {})

        self.fleet = kwargs.get('fleet', Fleet())
        self.resources = kwargs.get('resources', Resources())
        self.station_updated = False
        self.building_updated = False
        self.fleet_updated = False

        for construction in BUILDINGS.values() + STATIONS.values():
            setattr(self, construction.name,
                    construction.__class__(kwargs.get(construction.name, 0)))