forked from ynoproject/ynoengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_character_flash.cpp
66 lines (52 loc) · 1.33 KB
/
game_character_flash.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "doctest.h"
#include "options.h"
#include "game_map.h"
#include "game_vehicle.h"
#include "main_data.h"
#include "game_switches.h"
#include <climits>
#include <initializer_list>
#include "mock_game.h"
TEST_SUITE_BEGIN("Game_Character_Flash");
static void testChar(const Game_Character& ch, Color color, double power, int time_left) {
CAPTURE(color);
CAPTURE(power);
CAPTURE(time_left);
REQUIRE_EQ(ch.GetFlashColor(), color);
REQUIRE_EQ(ch.GetFlashLevel(), power);
REQUIRE_EQ(ch.GetFlashTimeLeft(), time_left);
}
static void testFlash(int r, int g, int b, double power, int frames) {
const MockGame mg(MockMap::ePassBlock20x15);
auto& ch = *mg.GetEvent(1);
CAPTURE(r);
CAPTURE(g);
CAPTURE(b);
CAPTURE(power);
CAPTURE(frames);
ch.Flash(r, g, b, power, frames);
testChar(ch, Flash::MakeColor(r, g, b, power), power, frames);
while (power > 0) {
ForceUpdate(ch);
Flash::Update(power, frames);
testChar(ch, Flash::MakeColor(r, g, b, power), power, frames);
}
for (int i = 0; i < 8; ++i) {
ForceUpdate(ch);
testChar(ch, Flash::MakeColor(r, g, b, 0.0), 0.0, frames);
}
}
TEST_CASE("Flash") {
for (auto r: {0, 7}) {
for (auto g: {9, 31}) {
for (auto b: {3, 28}) {
for (auto p = 0; p < 32; ++p) {
for (auto t: {0, 1, 21, 61}) {
testFlash(r, g, b, p, t);
}
}
}
}
}
}
TEST_SUITE_END();