Example #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
Example #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
Example #3
0
 def construct(self, construction, planet=None):
     planet = planet if planet is not None else self.current_planet
     if not isinstance(construction, Constructions):
         assert hasattr(planet, construction), \
                 '%s has not %r' % (planet, construction)
         construction = getattr(planet, construction)
     if isinstance(construction, tuple(building.__class__
                                       for building in BUILDINGS.values())):
         page = 'resources'
     else:
         page = 'station'
     self.go_to(planet, page, update=False)
     self.click(construction.css_dom)
     self.wait_for_page_to_load(DEFAULT_WAIT_TIME)
     self.update_empire_overall()
     self.update_planet_resources(planet)
Example #4
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)))