Skip to content

Instantly share code, notes, and snippets.

@RomainMazB
Created March 31, 2020 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomainMazB/3a9938e3dd72be7a6030b2cbd1a03833 to your computer and use it in GitHub Desktop.
Save RomainMazB/3a9938e3dd72be7a6030b2cbd1a03833 to your computer and use it in GitHub Desktop.
public function testSacrifyEggsIncreaseFood(): void
{
$expected_food = $this->city->getFood();
$this->city->buildings->nursery->populate(4, 'warrior');
$expected_food += 4 * config('city_default_values.abilities.food_ratio_for_sacrifices_egg');
$this->city->buildings->nursery->sacrifyEggs(4, 'egg');
$this->assertEquals($expected_food, $this->city->getFood());
/**
* Test food increase for larvae
*/
$this->city->buildings->nursery->populate(4, 'warrior');
// Update the born_time to make them Larvae
$larvae_offset = config('game.total_development_time.end') - config('game.development_times.larvae.end') + 25;
DB::update("UPDATE ants SET born_time = NOW() + CONCAT(?::INT, ' minutes')::INTERVAL", [$larvae_offset]);
$expected_food += 4 * config('city_default_values.abilities.food_ratio_for_sacrifices_larvae');
$this->city->buildings->nursery->sacrifyEggs(4, 'larvae');
$this->assertEquals($expected_food, $this->city->getFood());
/**
* Test food increase for pupae
*/
$this->city->buildings->nursery->populate(4, 'warrior');
// Update the born_time to make them Pupae
$pupae_offset = config('game.total_development_time.end') - config('game.development_times.pupae.end') + 25;
DB::update("UPDATE ants SET born_time = NOW() + CONCAT(?::INT, ' minutes')::INTERVAL", [$pupae_offset]);
$expected_food += 4 * (int) config('city_default_values.abilities.food_ratio_for_sacrifices_pupae');
$this->city->buildings->nursery->sacrifyEggs(4, 'pupae');
$this->assertEquals($expected_food, $this->city->getFood());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment