MCPcopy Create free account
hub / github.com/EasyRPG/Player / testMove

Function testMove

tests/game_player_input.cpp:43–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43static void testMove(bool success, int input_dir, int dir, int x, int y, int dx, int dy, bool cheat, bool debug) {
44 DebugGuard dg(debug);
45 const MockGame mg(map_id);
46 auto& ch = *mg.GetPlayer();
47
48 CAPTURE(cheat);
49 CAPTURE(debug);
50 CAPTURE(input_dir);
51 CAPTURE(dir);
52 CAPTURE(x);
53 CAPTURE(y);
54
55 ch.SetX(x);
56 ch.SetY(y);
57
58 Input::ResetKeys();
59
60 Input::dir4 = input_dir;
61
62 if (cheat) {
63 Input::press_time[Input::DEBUG_THROUGH] = 1;
64 }
65
66 const auto tx = x + dx;
67 const auto ty = y + dy;
68
69 // Force RNG to always fail to generate a random encounter
70 Rand::LockGuard lk(INT32_MAX);
71 ForceUpdate(ch);
72 if (success) {
73 int acc_rate = (cheat && debug) ? 0 : 100;
74 testPos(ch, tx, ty, dir, dir, 224, false, 0, 0, acc_rate, false, false, 0, false, false);
75 } else {
76 testPos(ch, tx, ty, dir, dir, 0, false, 1, 0, 0, false, false, 0, false, false);
77 }
78}
79
80TEST_CASE("Move") {
81 testMove(true, 8, Up, 4, 8, 0, -1, false, false);

Callers 1

Calls 5

testPosFunction · 0.85
GetPlayerMethod · 0.80
ForceUpdateFunction · 0.70
SetXMethod · 0.45
SetYMethod · 0.45

Tested by

no test coverage detected