Esempio n. 1
0
 def serialize_obj(self):
     obj_data = {
         'id': g.to_internal_id('location', self.spec.id),
         'bases': [b.serialize_obj() for b in self.bases],
     }
     if self._modifiers is not None:
         obj_data['_modifiers'] = self._modifiers
     return obj_data
Esempio n. 2
0
 def serialize_obj(self):
     obj_data = {
         # Difficulty and game_time (raw_sec) are stored in the header, so
         # do not include them here.
         'cash':
         self.cash,
         'partial_cash':
         self.partial_cash,
         'locations': [
             loc.serialize_obj() for loc in self.locations.values()
             if loc.available()
         ],
         'cpu_usage': {},
         'last_discovery':
         self.last_discovery.id if self.last_discovery else None,
         'prev_discovery':
         self.prev_discovery.id if self.prev_discovery else None,
         'log': [x.serialize_obj() for x in self.log],
         'used_cpu':
         self.used_cpu,
         'had_grace':
         self.had_grace,
         'groups': [grp.serialize_obj() for grp in self.groups.values()],
         'events': [e.serialize_obj() for e in self.events.values()],
         'techs': [t.serialize_obj() for t in self.techs.values()]
     }
     for task_id, value in self.cpu_usage.items():
         if task_id not in ["cpu_pool", "jobs"]:
             task_id = g.to_internal_id('tech', task_id)
         obj_data["cpu_usage"][task_id] = value
     if self.prev_discovery is not None:
         obj_data['prev_discovery'] = g.to_internal_id(
             'location', self.prev_discovery.id)
     if self.last_discovery is not None:
         obj_data['last_discovery'] = g.to_internal_id(
             'location', self.last_discovery.id)
     return obj_data
Esempio n. 3
0
 def serialize_obj(self):
     return self.serialize_buyable_fields({
         'id':
         g.to_internal_id('base', self.spec.id),
         'name':
         self.name,
         'started_at_min':
         self.started_at,
         'power_state':
         self.power_state,
         'grace_over':
         self.grace_over,
         # Note that we store all items even for "force_cpu"'ed bases.  This enables
         # use to load the base with that CPU item even if the "force_cpu" flag is
         # later removed from the spec.
         'items': [
             it.serialize_obj() for it in self.items.values()
             if it is not None
         ],
     })
Esempio n. 4
0
 def serialize_obj(self):
     return {
         'id': g.to_internal_id('event', self.spec.id),
         'triggered': self.triggered,
         'triggered_at': self.triggered_at
     }
Esempio n. 5
0
def id_converter(id_type):
    return lambda field: g.to_internal_id(id_type, field)
Esempio n. 6
0
 def serialize_obj(self):
     return {
         'id': g.to_internal_id('group', self.spec.id),
         'suspicion': self.suspicion,
         'is_actively_discovering_bases': self.is_actively_discovering_bases,
     }
Esempio n. 7
0
 def serialize_obj(self):
     return self.serialize_buyable_fields({
         'id':
         g.to_internal_id('item', self.spec.id),
     })