@@ -61,6 +61,23 @@ auto calcSum(const T& collection)
6161 return std::accumulate (std::begin (collection), std::end (collection), 0u );
6262}
6363
64+ std::array<unsigned , NUM_SOLDIER_RANKS > CountTroopsByRank (const nobMilitary& bld)
65+ {
66+ std::array<unsigned , NUM_SOLDIER_RANKS > counts{};
67+ for (const auto & soldier : bld.GetTroops ())
68+ ++counts[soldier.GetRank ()];
69+ return counts;
70+ }
71+
72+ void DeliverCoin (nobMilitary& bld, GameWorld& world, const MapPoint hqPos)
73+ {
74+ auto * hq = world.GetSpecObj <nobBaseWarehouse>(hqPos);
75+ BOOST_TEST_REQUIRE (hq);
76+
77+ hq->AddToInventory (GoodCounts::make (GoodType::Coins, 1 ), true );
78+ bld.SearchCoins ();
79+ }
80+
6481// / Reschedule the walk event of the obj to be executed in numGFs GFs
6582void rescheduleWalkEvent (TestEventManager& em, noMovable& obj, unsigned numGFs)
6683{
@@ -601,6 +618,44 @@ BOOST_FIXTURE_TEST_CASE(TroopLimitKeepsOrderedRestrictedSoldier, AttackFixture<>
601618 BOOST_TEST_REQUIRE (milBld0->GetLeavingFigures ().empty ());
602619}
603620
621+ BOOST_FIXTURE_TEST_CASE (CoinTrainingUpgradesRankChainByDefault, AttackFixture<>)
622+ {
623+ AddSoldiers (milBld0Pos, 1 , Job::Private);
624+ AddSoldiers (milBld0Pos, 1 , Job::PrivateFirstClass);
625+ AddSoldiers (milBld0Pos, 1 , Job::Sergeant);
626+
627+ BuildRoadForBlds (milBld0Pos, hqPos[0 ]);
628+ DeliverCoin (*milBld0, world, hqPos[0 ]);
629+
630+ RTTR_EXEC_TILL (5000 , CountTroopsByRank (*milBld0)[3 ] == 1u );
631+
632+ const auto counts = CountTroopsByRank (*milBld0);
633+ BOOST_TEST_REQUIRE (counts[0 ] == 0u );
634+ BOOST_TEST_REQUIRE (counts[1 ] == 1u );
635+ BOOST_TEST_REQUIRE (counts[2 ] == 1u );
636+ BOOST_TEST_REQUIRE (counts[3 ] == 1u );
637+ }
638+
639+ BOOST_FIXTURE_TEST_CASE (SingleSoldierCoinTrainingUpgradesOnlyLowestRankSoldier, AttackFixture<>)
640+ {
641+ this ->ggs .setSelection (AddonId::SINGLE_SOLDIER_COIN_TRAINING , 1 );
642+
643+ AddSoldiers (milBld0Pos, 1 , Job::Private);
644+ AddSoldiers (milBld0Pos, 1 , Job::PrivateFirstClass);
645+ AddSoldiers (milBld0Pos, 1 , Job::Sergeant);
646+
647+ BuildRoadForBlds (milBld0Pos, hqPos[0 ]);
648+ DeliverCoin (*milBld0, world, hqPos[0 ]);
649+
650+ RTTR_EXEC_TILL (5000 , CountTroopsByRank (*milBld0)[1 ] == 2u );
651+
652+ const auto counts = CountTroopsByRank (*milBld0);
653+ BOOST_TEST_REQUIRE (counts[0 ] == 0u );
654+ BOOST_TEST_REQUIRE (counts[1 ] == 2u );
655+ BOOST_TEST_REQUIRE (counts[2 ] == 1u );
656+ BOOST_TEST_REQUIRE (counts[3 ] == 0u );
657+ }
658+
604659BOOST_FIXTURE_TEST_CASE (ConquerBldCoinAddonEnable, AttackFixture<>)
605660{
606661 this ->ggs .setSelection (AddonId::COINS_CAPTURED_BLD , 1 ); // addon is active on second run
0 commit comments