Пример #1
0
void Emperor::Impl::updateRelation(CityPtr cityp) {
  if (!cityp->isAvailable())
    return;

  Relation &relation = relations[cityp->name()];

  relation.soldiers.sent = 0; // clear chasteners count
  relation.change(-config::emperor::yearlyFavorDecrease);

  int monthWithoutTax = relation.lastTaxDate.monthsTo(game::Date::current());
  if (monthWithoutTax > DateTime::monthsInYear) {
    int decrease = math::clamp(taxBrokenFavourDecrease +
                                   monthWithoutTax / DateTime::monthsInYear * 2,
                               0, taxBrokenFavourDecreaseMax);
    relation.change(-decrease);
  }

  float salaryKoeff = EmpireHelper::governorSalaryKoeff(cityp);
  if (salaryKoeff > 1.f) {
    salaryKoeff = -(int)salaryKoeff * salaryKoeff;
  } else if (salaryKoeff < 1.f) {
    salaryKoeff = normalSalaryFavourUpdate;
  } else {
    salaryKoeff = 0;
  }

  relation.change(salaryKoeff);

  int brokenEmpireTax = cityp->treasury().getIssueValue(
      econ::Issue::overdueEmpireTax, econ::Treasury::lastYear);
  if (brokenEmpireTax > 0) {
    relation.change(-brokenTaxPenalty);

    brokenEmpireTax = cityp->treasury().getIssueValue(
        econ::Issue::overdueEmpireTax, econ::Treasury::twoYearsAgo);
    if (brokenEmpireTax > 0)
      relation.change(-brokenMoreTaxPenalty);
  }
}