-
Notifications
You must be signed in to change notification settings - Fork 99
fixed emergency protocol by removing sheduled wares requested before ... #1961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
89c524a
0e13b2c
97f5b63
324d8ed
9dac609
2b5735f
0fe2d3c
689112e
0c79309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -331,6 +331,8 @@ class GamePlayer : public GamePlayerInfo | |||||
| const Statistic& GetStatistic(StatisticTime time) const { return statistic[time]; }; | ||||||
| unsigned GetStatisticCurrentValue(StatisticType idx) const { return statisticCurrentData[idx]; } | ||||||
|
|
||||||
| // remove all wares that are already scheduled but ignoring emergency protocol | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what "ignoring ..." means here. Maybe:
Suggested change
|
||||||
| void CancelWaresForEmergencyProtocol(); | ||||||
| // Testet ob Notfallprogramm aktiviert werden muss und tut dies dann | ||||||
| void TestForEmergencyProgramm(); | ||||||
| bool hasEmergency() const { return emergency; } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,87 @@ | ||||||||||||||||
| // Copyright (C) 2005 - 2026 Settlers Freaks (sf-team at siedler25.org) | ||||||||||||||||
| // | ||||||||||||||||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||||||||||||||||
|
|
||||||||||||||||
| #include "EconomyModeHandler.h" | ||||||||||||||||
| #include "EventManager.h" | ||||||||||||||||
| #include "GamePlayer.h" | ||||||||||||||||
| #include "Savegame.h" | ||||||||||||||||
| #include "SerializedGameData.h" | ||||||||||||||||
| #include "addons/AddonEconomyModeGameLength.h" | ||||||||||||||||
| #include "factories/BuildingFactory.h" | ||||||||||||||||
| #include "worldFixtures/MockLocalGameState.h" | ||||||||||||||||
| #include "worldFixtures/WorldFixture.h" | ||||||||||||||||
| #include "worldFixtures/WorldWithGCExecution.h" | ||||||||||||||||
| #include "worldFixtures/initGameRNG.hpp" | ||||||||||||||||
| #include "gameTypes/GO_Type.h" | ||||||||||||||||
| #include <boost/test/unit_test.hpp> | ||||||||||||||||
| #include <buildings/nobHQ.h> | ||||||||||||||||
| #include <buildings/nobUsual.h> | ||||||||||||||||
|
|
||||||||||||||||
| struct EmergencyFixture : public WorldFixture<CreateEmptyWorld, 1> | ||||||||||||||||
| { | ||||||||||||||||
| nobHQ* HQ = world.GetPlayer(0).GetHQ(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| EmergencyFixture() | ||||||||||||||||
| { | ||||||||||||||||
| HQ->AddToInventory(HQ->getStartInventory(StartWares::VLow), true); | ||||||||||||||||
| MapPoint pos; | ||||||||||||||||
|
|
||||||||||||||||
| pos = world.GetPlayer(0).GetHQPos() + MapPoint(3, 0); | ||||||||||||||||
| world.SetBuildingSite(BuildingType::Farm, pos, 0); | ||||||||||||||||
| world.BuildRoad(0, false, world.GetNeighbour(pos, Direction::SouthEast), | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe derive from |
||||||||||||||||
| std::vector<Direction>(3, Direction::West)); | ||||||||||||||||
|
|
||||||||||||||||
| pos = world.GetPlayer(0).GetHQPos() + MapPoint(-3, 0); | ||||||||||||||||
| world.SetBuildingSite(BuildingType::Farm, pos, 0); | ||||||||||||||||
| world.BuildRoad(0, false, world.GetNeighbour(pos, Direction::SouthEast), | ||||||||||||||||
| std::vector<Direction>(3, Direction::East)); | ||||||||||||||||
|
|
||||||||||||||||
| // wait until emergency protocol should be activated | ||||||||||||||||
| RTTR_EXEC_TILL(500, HQ->GetInventory()[GoodType::Boards] == 10); | ||||||||||||||||
|
|
||||||||||||||||
| // activate program (with 10 boards it should trigger) | ||||||||||||||||
| world.GetPlayer(0).TestForEmergencyProgramm(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we test that this is done automatically? I.e. shouldn't the above activate it? Or at least in the next GF |
||||||||||||||||
|
|
||||||||||||||||
| // wait for some more ticks to give time if not working to deliver more boards | ||||||||||||||||
| RTTR_SKIP_GFS(200); | ||||||||||||||||
| // check boards are still fine and protocol working | ||||||||||||||||
| BOOST_TEST_CHECK(world.GetPlayer(0).GetHQ()->GetInventory()[GoodType::Boards] == 10); | ||||||||||||||||
|
Comment on lines
+45
to
+48
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| BOOST_FIXTURE_TEST_CASE(EmergencyProtoclActiveWoodcutterAndSawmillCanBuild, EmergencyFixture) | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo here and below
Suggested change
|
||||||||||||||||
| { | ||||||||||||||||
| initGameRNG(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to fixture |
||||||||||||||||
|
|
||||||||||||||||
| MapPoint posWoodcutter = world.GetPlayer(0).GetHQPos() + MapPoint(-1, 2); | ||||||||||||||||
| world.SetBuildingSite(BuildingType::Woodcutter, posWoodcutter, 0); | ||||||||||||||||
| world.BuildRoad(0, false, world.GetNeighbour(posWoodcutter, Direction::SouthEast), | ||||||||||||||||
| std::vector<Direction>(2, Direction::NorthEast)); | ||||||||||||||||
|
|
||||||||||||||||
| MapPoint posSawmill = world.GetPlayer(0).GetHQPos() + MapPoint(-2, 4); | ||||||||||||||||
| world.SetBuildingSite(BuildingType::Sawmill, posSawmill, 0); | ||||||||||||||||
| world.BuildRoad(0, false, world.GetNeighbour(posSawmill, Direction::SouthEast), | ||||||||||||||||
| std::vector<Direction>(2, Direction::NorthEast)); | ||||||||||||||||
|
|
||||||||||||||||
| // check if inventory boards are given out | ||||||||||||||||
| RTTR_EXEC_TILL(200, HQ->GetInventory()[GoodType::Boards] < 10); | ||||||||||||||||
|
|
||||||||||||||||
| // check if building where found | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| RTTR_EXEC_TILL(2000, world.GetNO(posWoodcutter)->GetType() == NodalObjectType::Building); | ||||||||||||||||
| RTTR_EXEC_TILL(2000, world.GetNO(posSawmill)->GetType() == NodalObjectType::Building); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| BOOST_FIXTURE_TEST_CASE(EmergencyProtoclActiveOtherBuldingsnotBuild, EmergencyFixture) | ||||||||||||||||
| { | ||||||||||||||||
| initGameRNG(); | ||||||||||||||||
|
|
||||||||||||||||
| MapPoint pos = world.GetPlayer(0).GetHQPos() + MapPoint(-1, 2); | ||||||||||||||||
| world.SetBuildingSite(BuildingType::Watchtower, pos, 0); | ||||||||||||||||
| world.BuildRoad(0, false, world.GetNeighbour(pos, Direction::SouthEast), | ||||||||||||||||
| std::vector<Direction>(2, Direction::NorthEast)); | ||||||||||||||||
|
|
||||||||||||||||
| // wait for some more ticks to give time if not working to deliver more boards | ||||||||||||||||
| RTTR_SKIP_GFS(500); | ||||||||||||||||
| // check boards are still fine and protocol working | ||||||||||||||||
| BOOST_TEST_CHECK(world.GetPlayer(0).GetHQ()->GetInventory()[GoodType::Boards] == 10); | ||||||||||||||||
|
Comment on lines
+83
to
+86
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incomplete comment?