def finalize(self): # civ or mil? self.define(I('military'), dict_max) if I('military') not in self.caracs: self.caracs[I('civilian')] = 1 tmp = max(1, dict_sum(self.compos, I('cases'))) self.caracs[I('size')] = floor(log(tmp-1, 2))+1 self.caracs[I('poc')] = floor(tmp/2) tmp = 17 - self.caracs[I('size')] + dict_max(self.compos, I('propeller')) if I('military') in self.caracs: tmp = floor(tmp*2/3) self.caracs[I('velocity')] = tmp self.caracs[I('cost_prod')] = dict_sum(self.compos, I('cost_prod')) # wait, wat? self.caracs[I('cost_ore')] = dict_sum(self.compos, I('cost_ore')) self.define(I('cargo'), dict_sum) self.define(I('syst_rad'), dict_max) self.define(I('fleet_rad'), dict_max) self.define(I('SCM'), dict_max) self.define(I('colo'), dict_max) sa, pa = 0, 0 for t in self.compos: if I('weapon') in t.caracs: w = t.caracs[I('weapon')][0] n = t.caracs[I('weapon')][1] sa += (w.ha+w.sa) * n * self.compos[t] pa += (w.pa) * n * self.compos[t] if sa > 0: self.caracs[I('SA')] = sa if pa > 0: self.caracs[I('PA')] = pa for t in self.compos: if I('cost_merch') in t.caracs: merch = t.caracs[I('cost_merch')] if merch[0] not in self.merchs: self.merchs[merch[0]] = 0 self.merchs[merch[0]] += merch[1] * self.compos[t]
def prod_min(self): mine = dict_sum(self.constructions, I('extract')) extra = dict_max(self.constructions, I('advance_ex')) + self.ore[0] prod = (2 * extra - mine + 1) * (mine / 2.0) self.ore[1] += prod return prod