void Migration::Impl::createMigrationToCity( PlayerCityPtr city ) { unsigned int vh = calcVacantHouse( city ); if( vh == 0 ) { return; } EmigrantList migrants; migrants << city->walkers(); if( vh <= migrants.size() * 5 ) { return; } Tile& roadTile = city->tilemap().at( city->borderInfo().roadEntry ); ImmigrantPtr emigrant = Immigrant::create( city ); if( emigrant.isValid() ) { bool success = emigrant->send2city( roadTile ); emigrant->setSpeedMultiplier( 0.8f + math::random( 40 ) / 100.f ); if( success ) lastMonthComing += emigrant->peoples().count(); } }
void Neptune::_doWrath(PlayerCityPtr city) { GameEventPtr event = ShowInfobox::create( _("##wrath_of_neptune_title##"), _("##wrath_of_neptune_description##"), ShowInfobox::send2scribe, "god_neptune"); event->dispatch(); ShipList boats; boats << city->walkers(); ShipList destroyBoats = boats.random( 5 ); for( auto ship : destroyBoats ) { ship->die(); } }
void Mars::_doBlessing(PlayerCityPtr city) { EnemySoldierList enemies; enemies << city->walkers( walker::any ); bool blessingDone = false; int step = enemies.size() / 3; for( int k=0; k < step; k++ ) { int index = math::random( enemies.size() ); EnemySoldierList::iterator it = enemies.begin(); std::advance( it, index ); (*it)->die(); blessingDone = true; } if( blessingDone ) { events::GameEventPtr event = events::ShowInfobox::create( _("##spirit_of_mars_title##"), _("##spirit_of_mars_text##"), events::ShowInfobox::send2scribe ); event->dispatch(); } }