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

Function testMove

tests/game_character_move.cpp:70–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69template <bool success>
70static void testMove(int move_dir, int x, int y, int dir, int face,
71 int dx, int dy, int tdir, int tface,
72 int freq, int speed, bool facing_locked) {
73 const MockGame mg(MockMap::ePassBlock20x15);
74
75 auto& ch = *mg.GetEvent(1);
76 ch.SetX(x);
77 ch.SetY(y);
78 ch.SetDirection(dir);
79 ch.SetFacing(face);
80 ch.SetMoveSpeed(speed);
81 ch.SetMoveFrequency(freq);
82 const auto maxstop = ch.GetMaxStopCount();
83 if (facing_locked) {
84 ch.SetFacingLocked(facing_locked);
85 }
86
87 const auto tx = x + dx;
88 const auto ty = y + dy;
89
90 CAPTURE(success);
91 CAPTURE(x);
92 CAPTURE(y);
93 CAPTURE(dx);
94 CAPTURE(dy);
95
96 REQUIRE_EQ(ch.Move(move_dir), success);
97
98 if (!success) {
99 testChar(ch, tx, ty, tdir, tface, 0, false, 0, 0, freq, speed, 0, maxstop);
100 return;
101 }
102 testChar(ch, tx, ty, tdir, tface, 256, false, 0, 0, freq, speed, 0, maxstop);
103
104 const auto dt = 1 << (1 + speed);
105
106 CAPTURE(dt);
107 for(int i = 256 - dt; i > 0; i -= dt) {
108 CAPTURE(i);
109 ForceUpdate(ch);
110 testChar(ch, tx, ty, tdir, tface, i, false, 0, 0, freq, speed, 0, maxstop);
111 }
112
113 ForceUpdate(ch);
114 testChar(ch, tx, ty, tdir, tface, 0, false, 0, 0, freq, speed, 0, maxstop);
115}
116
117TEST_CASE("Move") {
118 for (int freq = 1; freq <= 8; ++freq) {

Callers

nothing calls this directly

Calls 12

SetDirectionMethod · 0.80
SetFacingMethod · 0.80
SetMoveSpeedMethod · 0.80
SetMoveFrequencyMethod · 0.80
GetMaxStopCountMethod · 0.80
SetFacingLockedMethod · 0.80
testCharFunction · 0.70
ForceUpdateFunction · 0.70
GetEventMethod · 0.45
SetXMethod · 0.45
SetYMethod · 0.45
MoveMethod · 0.45

Tested by

no test coverage detected