def add_base(self, base): self.bases.append(base) base.location = self self.modify_base(base) # Make sure the location's CPU modifier is applied. base.recalc_cpu()
def _convert_base(base, save_version): base = _convert_buyable(base, save_version) if save_version < 99.3: # < 1.0 (dev) # We needs to do it first because of property base.cpus base.items = { "cpu": base.__dict__["cpus"] } del base.__dict__["cpus"] if save_version < 4.91: # < r5_pre for cpu in base.cpus: if cpu: cpu.convert_from(save_version) cpu.base = base for index in range(len(base.extra_items)): if base.extra_items[index]: base.extra_items[index].convert_from(save_version) else: base.extra_items[index] = None base.raw_cpu = 0 if base.cpus[0]: for cpu in base.cpus[1:]: base.cpus[0] += cpu if len(base.cpus) == 1 and base.cpus[0].done: # Force it to report its CPU. base.cpus[0].finish() base.cpus = base.cpus[0] else: base.cpus = None base.recalc_cpu() base.power_state = base.power_state.lower() if save_version < 99.3: # < 1.0 (dev) extra_items = iter(base.__dict__["extra_items"]) base.items["reactor"] = next(extra_items, None) base.items["network"] = next(extra_items, None) base.items["security"] = next(extra_items, None) del base.__dict__["extra_items"] if ("power_state" in base.__dict__): base._power_state = base.__dict__["power_state"] base._name = base.__dict__['name'] return base