MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / TEST_F

Function TEST_F

test/tests/PlayTests.cpp:89–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89TEST_F(PlayTests, SecondGuestInQueueShouldNotRideIfNoFunds)
90{
91 /* This test verifies that a guest, when second in queue, won't be forced to enter
92 * the ride if it has not enough money to pay for it.
93 * To simulate this scenario, two guests (a rich and a poor) are encouraged to enter
94 * the ride queue, and then the price is raised such that the second guest in line
95 * (the poor one) cannot pay. The poor guest should not enter the ride.
96 */
97 std::string initStateFile = TestData::GetParkPath("small_park_with_ferris_wheel.sv6");
98
99 auto context = localStartGame(initStateFile);
100 ASSERT_NE(context.get(), nullptr);
101
102 auto& gameState = getGameState();
103
104 // Open park for free but charging for rides
105 execute<GameActions::ParkSetParameterAction>(GameActions::ParkParameter::open);
106 execute<GameActions::ParkSetEntranceFeeAction>(0);
107 gameState.park.flags |= PARK_FLAGS_UNLOCK_ALL_PRICES;
108
109 // Find ferris wheel
110 auto rideManager = RideManager(gameState);
111 auto it = std::find_if(
112 rideManager.begin(), rideManager.end(), [](auto& ride) { return ride.type == RIDE_TYPE_FERRIS_WHEEL; });
113 ASSERT_NE(it, rideManager.end());
114 Ride& ferrisWheel = *it;
115
116 // Open it for free
117 execute<GameActions::RideSetStatusAction>(ferrisWheel.id, RideStatus::open);
118 execute<GameActions::RideSetPriceAction>(ferrisWheel.id, 0, true);
119
120 // Ignore intensity to stimulate peeps to queue into ferris wheel
121 gameState.cheats.ignoreRideIntensity = true;
122
123 // Insert a rich guest
124 auto richGuest = Park::GenerateGuest();
125 richGuest->cashInPocket = 3000;
126
127 // Wait for rich guest to get in queue
128 bool matched = updateUntil(1000, [&]() { return richGuest->State == PeepState::queuing; });
129 ASSERT_TRUE(matched);
130
131 // Insert poor guest
132 auto poorGuest = Park::GenerateGuest();
133 poorGuest->cashInPocket = 5;
134
135 // Wait for poor guest to get in queue
136 matched = updateUntil(1000, [&]() { return poorGuest->State == PeepState::queuing; });
137 ASSERT_TRUE(matched);
138
139 // Raise the price of the ride to a value poor guest can't pay
140 execute<GameActions::RideSetPriceAction>(ferrisWheel.id, 10, true);
141
142 // Verify that the poor guest goes back to walking without riding
143 // since it doesn't have enough money to pay for it
144 bool enteredTheRide = false;
145 matched = updateUntil(10000, [&]() {
146 enteredTheRide |= poorGuest->State == PeepState::onRide;

Callers

nothing calls this directly

Calls 10

GetParkPathFunction · 0.85
localStartGameFunction · 0.85
RideManagerClass · 0.85
GenerateGuestFunction · 0.85
updateUntilFunction · 0.85
gameStateUpdateLogicFunction · 0.85
getMethod · 0.65
endMethod · 0.65
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected