game-village-politics-backend/tests/Unit/Game/ConquestTest.php

30 lines
1.1 KiB
PHP

<?php
use App\Game\Military\Conquest;
it('grows loyalty back at world speed, up to the maximum', function () {
expect((new Conquest(gameConfig()))->loyalty(40, 10))->toBe(50.0)
->and((new Conquest(gameConfig(['world' => ['speed' => 5]])))->loyalty(40, 10))->toBe(90.0)
->and((new Conquest(gameConfig()))->loyalty(95, 10))->toBe(100.0);
});
it('drops loyalty by 20 to 35 per nobleman', function () {
$conquest = new Conquest(gameConfig());
expect($conquest->drop(0.0))->toBe(20.0)
->and($conquest->drop(0.5))->toBe(28.0)
->and($conquest->drop(0.9999))->toBe(35.0);
});
it('gives the n-th noble slot for n more coins', function () {
expect(array_map(Conquest::slots(...), [0, 1, 2, 3, 5, 6, 10]))->toBe([0, 1, 1, 2, 2, 3, 4])
->and(Conquest::coinsFor(4))->toBe(10);
});
it('knows the noblemen and what a coin costs', function () {
$conquest = new Conquest(gameConfig());
expect($conquest->nobleUnits())->toBe(['nobleman'])
->and($conquest->coinCost(2))->toBe(['wood' => 56000, 'clay' => 60000, 'iron' => 50000]);
});