MerchantPtr Merchant::create( EmpirePtr empire, TraderoutePtr route, const std::string& start, good::Store &sell, good::Store &buy ) { MerchantPtr ret( new Merchant( empire ) ); ret->drop(); ret->_d->route = route; bool startCity = (route->beginCity()->name() == start); ret->_d->sells.resize( sell ); ret->_d->sells.storeAll( sell ); ret->_d->buys.resize( buy ); ret->_d->buys.storeAll( buy ); CityPtr baseCity = startCity ? route->beginCity() : route->endCity(); CityPtr destCity = startCity ? route->endCity() : route->beginCity(); ret->_d->baseCity = baseCity->name(); ret->_d->destCity = destCity->name(); ret->_d->steps = route->points( !startCity ); ret->_d->step = 0; bool noWayForMe = ret->_d->steps.empty(); if( noWayForMe ) { return MerchantPtr(); } ret->setPicture( gfx::Picture( ResourceGroup::empirebits, route->isSeaRoute() ? PicID::seaTradeRoute : PicID::landTradeRoute )); ret->setLocation( ret->_d->steps.front() ); return ret; }
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); } }