-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_campaign_data_events.py
More file actions
151 lines (127 loc) · 5.24 KB
/
test_campaign_data_events.py
File metadata and controls
151 lines (127 loc) · 5.24 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
"""This file contains tests to ensure all required regular and special events exist
Imports From:
campaign.py
report.py
Functions:
test_campaign_data_events()
"""
from campaign import Campaign
from report import Report
def test_campaign_data_events(current_campaign: Campaign) -> Report:
"""Test all events specified for completeness and existance in the filesystem
Parameters:
current_campaign: Campaign | The parsed campaign to be tested
Returns:
Report | The completed Report to be returned
"""
report = Report()
if not current_campaign.campaign_data.parsed:
return report
important_special_events = [
"START",
"ARMISTICE_ADVANTAGE",
"ARMISTICE_DISADVANTAGE",
"WIN",
"DRAW",
"FAIL",
"CRITICAL_FAIL",
"COURT_MARTIAL",
"RESCUE",
"CAPTURE",
"LOST_AT_SEA",
"STATISTICS",
]
for event in current_campaign.campaign_data.events:
if event not in current_campaign.language_info.events.events:
report.errors.append(
f"ERROR: Event {event} found in campaign_data but not present in language files!"
)
for special_event in current_campaign.campaign_data.special_events.keys():
if special_event in important_special_events:
important_special_events.remove(special_event)
if len(important_special_events) > 0:
report.warnings.append(
f"WARNING: The following important events are not found in campaign_data:"
f"\n {important_special_events}"
)
if (
"PLAYER_INVASION_SEA" not in important_special_events
or "PLAYER_INVASION_LAND" not in important_special_events
or "PLAYER_INVASION_AIR" not in important_special_events
):
if "ENEMY_LIBERATION_SEA" in important_special_events:
report.warnings.append(
"WARNING: Player side is able to INVADE territory, "
"but no ENEMY_LIBERATION_SEA event found."
)
if "ENEMY_LIBERATION_LAND" in important_special_events:
report.warnings.append(
"WARNING: Player side is able to INVADE territory, "
"but no ENEMY_LIBERATION_LAND event found."
)
if "ENEMY_LIBERATION_AIR" in important_special_events:
report.warnings.append(
"WARNING: Player side is able to INVADE territory, "
"but no ENEMY_LIBERATION_AIR event found."
)
if (
"ENEMY_INVASION_SEA" not in important_special_events
or "ENEMY_INVASION_LAND" not in important_special_events
or "ENEMY_INVASION_AIR" not in important_special_events
):
if "PLAYER_LIBERATION_SEA" in important_special_events:
report.warnings.append(
"WARNING: Enemy side is able to INVADE territory, "
"but no PLAYER_LIBERATION_SEA event found."
)
if "PLAYER_LIBERATION_LAND" in important_special_events:
report.warnings.append(
"WARNING: Player side is able to INVADE territory, "
"but no PLAYER_LIBERATION_LAND event found."
)
if "PLAYER_LIBERATION_AIR" in important_special_events:
report.warnings.append(
"WARNING: Player side is able to INVADE territory, "
"but no PLAYER_LIBERATION_AIR event found."
)
if (
"PLAYER_LIBERATION_SEA" not in important_special_events
or "PLAYER_LIBERATION_LAND" not in important_special_events
or "PLAYER_LIBERATION_AIR" not in important_special_events
):
if "ENEMY_INVASION_SEA" in important_special_events:
report.infos.append(
"INFO: Player side is able to LIBERATE territory, "
"but no ENEMY_INVASION_SEA event found."
)
if "ENEMY_INVASION_LAND" in important_special_events:
report.infos.append(
"INFO: Player side is able to LIBERATE territory, "
"but no ENEMY_INVASION_LAND event found."
)
if "ENEMY_INVASION_AIR" in important_special_events:
report.infos.append(
"INFO: Player side is able to LIBERATE territory, "
"but no ENEMY_INVASION_AIR event found."
)
if (
"ENEMY_LIBERATION_SEA" not in important_special_events
or "ENEMY_LIBERATION_LAND" not in important_special_events
or "ENEMY_LIBERATION_AIR" not in important_special_events
):
if "PLAYER_INVASION_SEA" in important_special_events:
report.infos.append(
"INFO: Enemy side is able to LIBERATE territory, "
"but no PLAYER_INVASION_SEA event found."
)
if "PLAYER_INVASION_LAND" in important_special_events:
report.infos.append(
"INFO: Enemy side is able to LIBERATE territory, "
"but no PLAYER_INVASION_LAND event found."
)
if "PLAYER_INVASION_AIR" in important_special_events:
report.infos.append(
"INFO: Enemy side is able to LIBERATE territory, "
"but no PLAYER_INVASION_AIR event found."
)
return report