generated from robo-technical-group/javascript-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.ts
140 lines (119 loc) · 4.02 KB
/
tests.ts
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
namespace Tests {
export const TESTING_KEY: string = 'CURRENT_TEST'
const TITLE: string = '** TESTING MODE **'
const INSTRUCTIONS: string = 'Stop tests in system menu.'
export function run(): void {
let currTest: number = 0
if (settings.exists(TESTING_KEY)) {
currTest = settings.readNumber(TESTING_KEY)
} else {
settings.writeNumber(TESTING_KEY, currTest)
}
switch (currTest) {
case 0:
splash('Test action menu.')
startTestMenu()
break
case 1:
splash('Test in-jail menu.')
testJailMenu()
break
case 2:
splash('Automated game.')
startAutomatedGame(0)
break
case 3:
splash('Animated board and background tests.')
BackgroundTests.setup()
break
case 4:
splash('Animated board tests (no background).')
BoardTests.setup()
break
case 5:
splash('Game state tests')
GameStateTests.start()
break
case 6:
splash('First roll test with four players.')
FirstRollTests.start(4)
break
case 7:
splash('First roll test with three players.')
FirstRollTests.start(3)
break
case 8:
splash('First roll test with two players.')
FirstRollTests.start(2)
break
case 9:
splash('Dice tests: D-pad=change direction, A=roll')
DiceTests.start()
break
case 10:
splash('Speed die tests: D-pad=change direction, A=roll')
DiceTests.start(3)
break
default:
// Restart tests upon reboot
currTest = -1
splash('Avatar tests.')
AvatarTest.startAvatarTest()
break
}
currTest++
settings.writeNumber(TESTING_KEY, currTest)
}
function setupMenuTest(board: number): void {
scene.setBackgroundImage(assets.image`bg`)
GameStateTests.loadTestState()
g_state.CurrPlayer = randint(1, g_state.NumPlayers)
g_state.testMode = true
g_state.Board.draw(board)
}
function splash(message: string): void {
game.showLongText(TITLE + '\n' + message + '\n' + INSTRUCTIONS,
DialogLayout.Full)
}
export function startAutomatedGame(board: number): void {
GameStateTests.loadTestState()
g_state.CurrPlayer = randint(1, g_state.NumPlayers)
g_state.testMode = true
if (board > 0) {
g_state.BoardIndex = board
g_state.SpeedDie = true
g_state.Bus = true
g_state.Depots = true
for (let p of g_state.Players) {
p.Bank = 2500
}
}
startGame()
}
export function startBoardSpaceMenu(board: number): void {
setupMenuTest(board)
let menu: ActionMenu = new SelectSpaceActionMenu()
menu.show()
}
export function startJailTest(board: number): void {
startAutomatedGame(board)
for (let i of [1, 2]) {
let p: Player = g_state.getPlayer(i)
p.Location = g_state.Board.Jail
p.InJail = true
}
}
export function startTestMenu(): void {
setupMenuTest(0)
let menu: ActionMenu = new TestActionMenu()
menu.show()
}
export function testJailMenu(): void {
setupMenuTest(0)
let p: Player = g_state.getCurrPlayer()
g_state.Properties.state[Properties.GROUP_JAIL].properties[0].owner = g_state.CurrPlayer
g_state.Properties.state[Properties.GROUP_JAIL].properties[1].owner = g_state.CurrPlayer
p.goToJail()
startGame()
}
}