1- // Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
1+ // Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org)
22//
33// SPDX-License-Identifier: GPL-2.0-or-later
44
99#include " figures/nofScout_Free.h"
1010#include " worldFixtures/CreateEmptyWorld.h"
1111#include " worldFixtures/WorldFixture.h"
12+ #include " worldFixtures/WorldWithGCExecution.h"
1213#include " gameTypes/GoodTypes.h"
1314#include " gameTypes/JobTypes.h"
1415#include " gameData/ShieldConsts.h"
1516#include < rttr/test/LogAccessor.hpp>
1617#include < boost/test/unit_test.hpp>
1718#include < array>
19+ #include < gameData/SettingTypeConv.h>
1820
1921namespace {
2022struct AddGoodsFixture : public WorldFixture <CreateEmptyWorld, 1 >, public rttr::test::LogAccessor
@@ -181,3 +183,78 @@ BOOST_FIXTURE_TEST_CASE(DestroyBuilding, EmptyWorldFixture1P)
181183
182184 world.DestroyBuilding (whPos, 0 );
183185}
186+
187+ BOOST_FIXTURE_TEST_CASE (CollectGoodsAndFigures, WorldWithGCExecution1P)
188+ {
189+ GamePlayer& player = world.GetPlayer (0 );
190+
191+ MapPoint wh1Pos = player.GetHQPos () + MapPoint (2 , 0 );
192+ MapPoint wh2Pos = wh1Pos + MapPoint (2 , 0 );
193+
194+ auto * wh1 = static_cast <nobBaseWarehouse*>(
195+ BuildingFactory::CreateBuilding (world, BuildingType::Storehouse, wh1Pos, 0 , Nation::Romans));
196+ auto * wh2 = static_cast <nobBaseWarehouse*>(
197+ BuildingFactory::CreateBuilding (world, BuildingType::Storehouse, wh2Pos, 0 , Nation::Romans));
198+
199+ world.BuildRoad (0 , false , wh1->GetFlagPos (), {2 , Direction::East});
200+ MilitarySettings milSettings = MILITARY_SETTINGS_SCALE;
201+ milSettings[0 ] = 0 ; // No recruitment
202+ this ->ChangeMilitary (milSettings);
203+
204+ Inventory inv;
205+ for (const auto job : helpers::enumRange<Job>())
206+ {
207+ if (job == Job::BoatCarrier)
208+ continue ;
209+ inv.Add (job);
210+ }
211+ for (const auto good : helpers::enumRange<GoodType>())
212+ {
213+ if (ConvertShields (good) != good)
214+ continue ;
215+ inv.Add (good);
216+ }
217+ wh1->AddGoods (inv, true );
218+
219+ for (const auto job : helpers::enumRange<Job>())
220+ {
221+ if (job == Job::BoatCarrier)
222+ continue ;
223+ SetInventorySetting (wh2Pos, job, EInventorySetting::Collect);
224+ }
225+ for (const auto good : helpers::enumRange<GoodType>())
226+ {
227+ if (ConvertShields (good) != good)
228+ continue ;
229+ SetInventorySetting (wh2Pos, good, EInventorySetting::Collect);
230+ }
231+
232+ RTTR_EXEC_TILL (500 , wh2->GetNumVisualFigures (Job::Helper) > 2 );
233+ SetInventorySetting (wh2Pos, Job::Helper, EInventorySetting::Stop);
234+
235+ RTTR_EXEC_TILL (5000 , wh2->GetNumVisualWares (maxEnumValue (GoodType{})) > 0 );
236+ RTTR_EXEC_TILL (5000 , wh2->GetNumVisualFigures (maxEnumValue (Job{})) > 0 );
237+ for (const auto job : helpers::enumRange<Job>())
238+ {
239+ if (job == Job::BoatCarrier)
240+ continue ;
241+ BOOST_TEST_INFO_SCOPE (" Job: " << rttr::enum_cast (job));
242+ if (job == Job::Helper) // Helpers get recruited continuously
243+ {
244+ BOOST_TEST (wh2->GetNumVisualFigures (job) > 10u );
245+ BOOST_TEST (wh2->GetNumRealFigures (job) > 10u );
246+ } else
247+ {
248+ BOOST_TEST (wh2->GetNumVisualFigures (job) == 1u );
249+ BOOST_TEST (wh2->GetNumRealFigures (job) == 1u );
250+ }
251+ }
252+ for (const auto good : helpers::enumRange<GoodType>())
253+ {
254+ if (ConvertShields (good) != good)
255+ continue ;
256+ BOOST_TEST_INFO_SCOPE (" Good: " << rttr::enum_cast (good));
257+ BOOST_TEST (wh2->GetNumVisualWares (good) == 1u );
258+ BOOST_TEST (wh2->GetNumRealWares (good) == 1u );
259+ }
260+ }
0 commit comments