role($start))->toBeNull() ->and($spec->role([...$start, 'timber_camp', 'clay_pit', 'iron_mine']))->toBeNull() ->and($spec->role([...$start, 'timber_camp', 'clay_pit', 'iron_mine', 'timber_camp']))->toBe('resources'); }); it('loses the role when the other kind takes more than 30% of the role space', function () use ($start) { $spec = new Specialisation(gameConfig()); $camps = ['timber_camp', 'clay_pit', 'iron_mine', 'timber_camp', 'clay_pit']; // 20 of 26 is 77%; 20 of 32 is 63%. expect($spec->role([...$start, ...$camps, 'barracks']))->toBe('resources') ->and($spec->role([...$start, ...$camps, 'barracks', 'stable']))->toBeNull() ->and($spec->space([...$start, ...$camps, 'barracks', 'stable']))->toBe(['resources' => 20, 'military' => 12]); }); it('makes a military village of barracks, stable and workshop beside one camp', function () use ($start) { $spec = new Specialisation(gameConfig()); // 18 of 22 is 82%. expect($spec->role([...$start, 'timber_camp', 'barracks', 'stable', 'workshop']))->toBe('military') ->and($spec->recruitBonus('military'))->toBe(0.2) ->and($spec->defenseBonus('military'))->toBe(0.1) ->and($spec->recruitBonus('resources'))->toBe(0.0) ->and($spec->recruitBonus(null))->toBe(0.0); }); it('raises only the role buildings output in a resource village', function () { $spec = new Specialisation(gameConfig()); expect($spec->productionBonus('resources', 'timber_camp'))->toBe(0.2) ->and($spec->productionBonus('resources', 'farm'))->toBe(0.0) ->and($spec->productionBonus('military', 'timber_camp'))->toBe(0.0) ->and($spec->bonuses('military'))->toBe(['recruit_speed' => 0.2, 'defense' => 0.1]); });