void Disorder::Impl::generateMugger(PlayerCityPtr city, HousePtr house )
{
  int taxesThisYear = city->treasury().getIssueValue( econ::Issue::taxIncome );
  int maxMoneyStolen = city->states().population / 10;

  if( taxesThisYear > minCityTax4mugger )
  {
    int moneyStolen = taxesThisYear / 4;

    if( moneyStolen > maxMoneyStolen )
      moneyStolen = math::random( maxMoneyStolen );

    GameEventPtr e = ShowInfobox::create( "##money_stolen_title##", "##money_stolen_text##",
                                          ShowInfobox::send2scribe, "mugging" );
    e->dispatch();

    city->treasury().resolveIssue( econ::Issue( econ::Issue::moneyStolen, -moneyStolen ) );
  }

  crime.level.current++;
  crime.muggers.thisYear++;
  //house->appendServiceValue( Service::crime, -crime::defaultValue / 2 );
  changeCrimeLevel( city, -crime::muggerCost );
}
Example #2
0
void Level::Impl::checkFailedMission( Level* lvl, bool forceFailed )
{
  PlayerCityPtr pcity = game->city();

  const city::VictoryConditions& vc = pcity->victoryConditions();
  MilitaryPtr mil = pcity->statistic().services.find<Military>();
  InfoPtr info = pcity->statistic().services.find<Info>();

  if (mil.isValid() && info.isValid())
  {
    const city::Info::MaxParameters& params = info->maxParams();

    bool failedByDestroy = mil->value() > 0 && params[ Info::population ].value > 0 && !pcity->states().population;
    bool failedByTime = ( !vc.isSuccess() && game::Date::current() > vc.finishDate() );

    if( failedByDestroy || failedByTime || forceFailed )
    {
      game->pause();
      events::dispatch<ScriptFunc>("OnMissionLose");
      steamapi::missionLose(vc.name());
    }
  }
}
Example #3
0
float Migration::Impl::getMigrationKoeff( PlayerCityPtr city )
{
  return ( std::min<float>( city->states().population, 300 ) / 300.f );
}