def get_production_powers(self): powers = [ (u'экономика', f.place_goods_production(self.expected_size)), (u'потребление', -f.place_goods_consumption(self.size)), (u'стабильность', (1.0-self.stability) * c.PLACE_STABILITY_MAX_PRODUCTION_PENALTY)] if self.get_next_keepers_goods_spend_amount(): powers.append((u'дары Хранителей', self.get_next_keepers_goods_spend_amount())) self._update_powers(powers, CITY_PARAMETERS.PRODUCTION) if self.modifier and self.modifier.PRODUCTION_MODIFIER: powers.append((self.modifier.NAME, self.modifier.PRODUCTION_MODIFIER)) persons_powers = [(person.full_name, person.production) for person in self.persons] powers.extend(sorted(persons_powers, key=lambda p: -p[1])) return powers
def get_production_powers(self): powers = [ (u'экономика', f.place_goods_production(self.expected_size)), (u'потребление', -f.place_goods_consumption(self.size)), (u'стабильность', (1.0 - self.stability) * c.PLACE_STABILITY_MAX_PRODUCTION_PENALTY) ] if self.get_next_keepers_goods_spend_amount(): powers.append((u'дары Хранителей', self.get_next_keepers_goods_spend_amount())) self._update_powers(powers, CITY_PARAMETERS.PRODUCTION) if self.modifier and self.modifier.PRODUCTION_MODIFIER: powers.append( (self.modifier.NAME, self.modifier.PRODUCTION_MODIFIER)) persons_powers = [(person.full_name, person.production) for person in self.persons] powers.extend(sorted(persons_powers, key=lambda p: -p[1])) return powers
def _effects_generator(self): from . import storage yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.TAX, value=0.0) yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.STABILITY, value=1.0) yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.STABILITY_RENEWING_SPEED, value=c.PLACE_STABILITY_RECOVER_SPEED) yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.POLITIC_RADIUS, value=self.attrs.size*1.25) yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.TERRAIN_RADIUS, value=self.attrs.size) for effect in self.effects.effects: yield effect if self.is_modifier_active(): for effect in self._modifier.effects: yield effect elif not self.modifier.is_NONE: yield effects.Effect(name=u'Несоответствие специализации', attribute=relations.ATTRIBUTE.STABILITY, value=-c.PLACE_STABILITY_UNIT) for exchange in storage.resource_exchanges.get_exchanges_for_place(self): resource_1, resource_2, place_2 = exchange.get_resources_for_place(self) if resource_1.parameter is not None: yield effects.Effect(name=place_2.name if place_2 is not None else resource_2.text, attribute=resource_1.parameter, value=-resource_1.amount * resource_1.direction) if resource_2.parameter is not None: yield effects.Effect(name=place_2.name if place_2 is not None else resource_1.text, attribute=resource_2.parameter, value=resource_2.amount * resource_2.direction) # economic yield effects.Effect(name=u'экономика', attribute=relations.ATTRIBUTE.PRODUCTION, value=f.place_goods_production(self.attrs.power_economic)) yield effects.Effect(name=u'потребление', attribute=relations.ATTRIBUTE.PRODUCTION, value=-f.place_goods_consumption(self.attrs.size)) yield effects.Effect(name=u'стабильность', attribute=relations.ATTRIBUTE.PRODUCTION, value=(1.0-self.attrs.stability) * c.PLACE_STABILITY_MAX_PRODUCTION_PENALTY) if self.attrs.get_next_keepers_goods_spend_amount(): yield effects.Effect(name=u'дары Хранителей', attribute=relations.ATTRIBUTE.PRODUCTION, value=self.attrs.get_next_keepers_goods_spend_amount()) # safety yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.SAFETY, value=1.0) yield effects.Effect(name=u'монстры', attribute=relations.ATTRIBUTE.SAFETY, value=-c.BATTLES_PER_TURN) yield effects.Effect(name=u'стабильность', attribute=relations.ATTRIBUTE.SAFETY, value=(1.0-self.attrs.stability) * c.PLACE_STABILITY_MAX_SAFETY_PENALTY) if self.is_frontier: yield effects.Effect(name=u'дикие земли', attribute=relations.ATTRIBUTE.SAFETY, value=-c.WHILD_BATTLES_PER_TURN_BONUS) # transport yield effects.Effect(name=u'дороги', attribute=relations.ATTRIBUTE.TRANSPORT, value=1.0) yield effects.Effect(name=u'трафик', attribute=relations.ATTRIBUTE.TRANSPORT, value=-c.TRANSPORT_FROM_PLACE_SIZE_PENALTY * self.attrs.size) if self.is_frontier: yield effects.Effect(name=u'бездорожье', attribute=relations.ATTRIBUTE.TRANSPORT, value=-c.WHILD_TRANSPORT_PENALTY) yield effects.Effect(name=u'стабильность', attribute=relations.ATTRIBUTE.TRANSPORT, value=(1.0-self.attrs.stability) * c.PLACE_STABILITY_MAX_TRANSPORT_PENALTY) # freedom yield effects.Effect(name=u'город', attribute=relations.ATTRIBUTE.FREEDOM, value=1.0) yield effects.Effect(name=u'стабильность', attribute=relations.ATTRIBUTE.FREEDOM, value=(1.0-self.attrs.stability) * c.PLACE_STABILITY_MAX_FREEDOM_PENALTY) for person in self.persons: for effect in person.place_effects(): yield effect
def _effects_generator(self): from . import storage yield effects.Effect(name='город', attribute=relations.ATTRIBUTE.TAX, value=0.0) yield effects.Effect(name='город', attribute=relations.ATTRIBUTE.STABILITY, value=1.0) if len(self.persons) > c.PLACE_MAX_PERSONS: yield effects.Effect(name='избыток Мастеров', attribute=relations.ATTRIBUTE.STABILITY, value=c.PLACE_STABILITY_PENALTY_FOR_MASTER * (len(self.persons) - c.PLACE_MAX_PERSONS)) if self.is_wrong_race(): dominant_race_power = self.races.get_race_percents( self.races.dominant_race) current_race_power = self.races.get_race_percents(self.race) yield effects.Effect(name='расовая дискриминация', attribute=relations.ATTRIBUTE.STABILITY, value=c.PLACE_STABILITY_PENALTY_FOR_RACES * (dominant_race_power - current_race_power)) yield effects.Effect( name='город', attribute=relations.ATTRIBUTE.STABILITY_RENEWING_SPEED, value=c.PLACE_STABILITY_RECOVER_SPEED) # politic radius yield effects.Effect(name='размер города', attribute=relations.ATTRIBUTE.POLITIC_RADIUS, value=self.attrs.size * 0.625) yield effects.Effect(name='культура', attribute=relations.ATTRIBUTE.POLITIC_RADIUS, value=self.attrs.size * self.attrs.culture * 0.625) # terrain radius yield effects.Effect(name='размер города', attribute=relations.ATTRIBUTE.TERRAIN_RADIUS, value=self.attrs.size * 0.5) yield effects.Effect(name='культура', attribute=relations.ATTRIBUTE.TERRAIN_RADIUS, value=self.attrs.size * self.attrs.culture * 0.5) for effect in self.effects.effects: yield effect if self.is_modifier_active(): for effect in self._modifier.effects: yield effect elif not self.modifier.is_NONE: modifier_points = getattr( self.attrs, 'MODIFIER_{}'.format(self.modifier.name).lower(), 0) yield effects.Effect( name='Несоответствие специализации', attribute=relations.ATTRIBUTE.STABILITY, value=c.PLACE_STABILITY_PENALTY_FOR_SPECIALIZATION * (c.PLACE_TYPE_ENOUGH_BORDER - modifier_points) / c.PLACE_TYPE_ENOUGH_BORDER) for exchange in storage.resource_exchanges.get_exchanges_for_place( self): resource_1, resource_2, place_2 = exchange.get_resources_for_place( self) if resource_1.parameter is not None: yield effects.Effect( name=place_2.name if place_2 is not None else resource_2.text, attribute=resource_1.parameter, value=-resource_1.amount * resource_1.direction) if resource_2.parameter is not None: yield effects.Effect( name=place_2.name if place_2 is not None else resource_1.text, attribute=resource_2.parameter, value=resource_2.amount * resource_2.direction) # economic yield effects.Effect(name='экономика', attribute=relations.ATTRIBUTE.PRODUCTION, value=f.place_goods_production( self.attrs.power_economic)) yield effects.Effect(name='потребление', attribute=relations.ATTRIBUTE.PRODUCTION, value=-f.place_goods_consumption(self.attrs.size)) yield effects.Effect(name='стабильность', attribute=relations.ATTRIBUTE.PRODUCTION, value=(1.0 - self.attrs.stability) * c.PLACE_STABILITY_MAX_PRODUCTION_PENALTY) if self.attrs.get_next_keepers_goods_spend_amount(): yield effects.Effect( name='дары Хранителей', attribute=relations.ATTRIBUTE.PRODUCTION, value=self.attrs.get_next_keepers_goods_spend_amount()) # safety yield effects.Effect(name='город', attribute=relations.ATTRIBUTE.SAFETY, value=1.0) yield effects.Effect(name='монстры', attribute=relations.ATTRIBUTE.SAFETY, value=-c.BATTLES_PER_TURN) yield effects.Effect(name='стабильность', attribute=relations.ATTRIBUTE.SAFETY, value=(1.0 - self.attrs.stability) * c.PLACE_STABILITY_MAX_SAFETY_PENALTY) if self.is_frontier: yield effects.Effect(name='дикие земли', attribute=relations.ATTRIBUTE.SAFETY, value=-c.WHILD_BATTLES_PER_TURN_BONUS) # transport yield effects.Effect(name='дороги', attribute=relations.ATTRIBUTE.TRANSPORT, value=1.0) yield effects.Effect(name='трафик', attribute=relations.ATTRIBUTE.TRANSPORT, value=-c.TRANSPORT_FROM_PLACE_SIZE_PENALTY * self.attrs.size) if self.is_frontier: yield effects.Effect(name='бездорожье', attribute=relations.ATTRIBUTE.TRANSPORT, value=-c.WHILD_TRANSPORT_PENALTY) yield effects.Effect(name='стабильность', attribute=relations.ATTRIBUTE.TRANSPORT, value=(1.0 - self.attrs.stability) * c.PLACE_STABILITY_MAX_TRANSPORT_PENALTY) # freedom yield effects.Effect(name='город', attribute=relations.ATTRIBUTE.FREEDOM, value=1.0) yield effects.Effect(name='стабильность', attribute=relations.ATTRIBUTE.FREEDOM, value=(1.0 - self.attrs.stability) * c.PLACE_STABILITY_MAX_FREEDOM_PENALTY) # culture yield effects.Effect(name='город', attribute=relations.ATTRIBUTE.CULTURE, value=1.0) yield effects.Effect(name='стабильность', attribute=relations.ATTRIBUTE.CULTURE, value=(1.0 - self.attrs.stability) * c.PLACE_STABILITY_MAX_CULTURE_PENALTY) for person in self.persons: for effect in person.place_effects(): yield effect