This repository has been archived by the owner on Aug 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
final_database.sql
270 lines (244 loc) · 11.5 KB
/
final_database.sql
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
-- Final Database for CS364
-- Created by C2C Jack Kulp and C2C Christopher Darcy (fixed by C1C Spencer Adolph)
-- April 2018
-- Database = island_rush
DROP DATABASE IF EXISTS island_rush;
CREATE DATABASE island_rush;
USE island_rush;
-- User Table
CREATE TABLE IF NOT EXISTS `admins` (
`adminId` int(11) NOT NULL AUTO_INCREMENT,
`adminName` varchar(50) NOT NULL,
`adminPassword` varchar(72) DEFAULT NULL,
PRIMARY KEY (`adminId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- insert admin
INSERT INTO `admins` VALUES (1, 'admin', '$2y$10$9RiuIs3Er77Rrp5pB/QfkOHaV/jilXngj41SUZHeT6H8PnUh91Pui');
-- Table of Games
CREATE TABLE IF NOT EXISTS `games`(
`gameId` int(5) NOT NULL AUTO_INCREMENT,
`gameSection` varchar(3) NOT NULL,
`gameInstructor` varchar(50) NOT NULL,
`gameRedLeader` varchar(50), -- just a name for the cadet commander
`gameBlueLeader` varchar(50), -- just a name for the cadet commander
`gameCurrentTeam` varchar(5) NOT NULL, -- 'Red' or 'Blue'
`gameTurn` int(4) NOT NULL, -- 0, 1, 2, 3, ....changes each team's turn (hopefully?)
`gamePhase` varchar(20) NOT NULL, -- ex: 'newsflash', 'buytroops', 'combat', 'fortify', 'placetroops', 'hybridwarfare'
`gameRedRpoints` int(5) NOT NULL,
`gameBlueRpoints` int(5) NOT NULL,
`gameRedHybridPoints` int(5) NOT NULL,
`gameBlueHybridpoints` int(5) NOT NULL,
`gameRedJoined` INT(1) NOT NULL, -- 0 or 1
`gameBlueJoined` INT(1) NOT NULL, -- 0 or 1
PRIMARY KEY(`gameId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-- Insert Default Games
INSERT INTO `games` VALUES (1, 'M1A', 'Darcy', 'Jacobs', 'Brown', 'Red', 0, 'Attack', 10, 40, 0, 0, 0, 0);
INSERT INTO `games` VALUES (2, 'T2B', 'Kulp', 'Hillmann', 'George', 'Blue', 0, 'Fortify', 0, 53, 0, 4, 0, 0);
INSERT INTO `games` VALUES (3, 'M1A', 'Adolph', 'Kulp', 'Smith', 'Blue', 0, 'Newsflash', 0, 53, 0, 4, 0, 0);
-- Table of Units
CREATE TABLE IF NOT EXISTS `units`(
`unitId` int(5) NOT NULL ,
`unitName` varchar(20) NOT NULL,
`unitMoves` int(3) NOT NULL,
PRIMARY KEY(`unitId`)
);
-- Insert units into table.
INSERT INTO `units` VALUES (1, 'transport', 2);
INSERT INTO `units` VALUES (2, 'submarine', 2);
INSERT INTO `units` VALUES (3, 'destroyer', 2);
INSERT INTO `units` VALUES (4, 'aircraftCarrier', 2);
INSERT INTO `units` VALUES (5, 'soldier', 1);
INSERT INTO `units` VALUES (6, 'artillery', 1);
INSERT INTO `units` VALUES (7, 'tank', 2);
INSERT INTO `units` VALUES (8, 'marine', 1);
INSERT INTO `units` VALUES (9, 'lav', 2);
INSERT INTO `units` VALUES (10, 'attackHeli', 3);
INSERT INTO `units` VALUES (11, 'sam', 1);
INSERT INTO `units` VALUES (12, 'fighter', 4);
INSERT INTO `units` VALUES (13, 'bomber', 6);
INSERT INTO `units` VALUES (14, 'stealthBomber', 5);
INSERT INTO `units` VALUES (15, 'tanker', 5);
INSERT INTO `units` VALUES (16, 'test_piece', 2);
-- Table for Game Board Allowed Positions (for troops and whatnot)
CREATE TABLE IF NOT EXISTS `positions` (
`positionId`int(4) NOT NULL,
`positionIsland` varchar(16) NOT NULL,
PRIMARY KEY(`positionID`)
) ;
-- 55 empty water positions? (1-55 top left going right, then restart row on the left counting (because float divs)
INSERT INTO `positions` VALUES (1, 'water');
INSERT INTO `positions` VALUES (2, 'water');
INSERT INTO `positions` VALUES (3, 'water');
INSERT INTO `positions` VALUES (4, 'water');
INSERT INTO `positions` VALUES (5, 'water');
INSERT INTO `positions` VALUES (6, 'water');
INSERT INTO `positions` VALUES (7, 'water');
INSERT INTO `positions` VALUES (8, 'water');
INSERT INTO `positions` VALUES (9, 'water');
INSERT INTO `positions` VALUES (10, 'water');
INSERT INTO `positions` VALUES (11, 'water');
INSERT INTO `positions` VALUES (12, 'water');
INSERT INTO `positions` VALUES (13, 'water');
INSERT INTO `positions` VALUES (14, 'water');
INSERT INTO `positions` VALUES (15, 'water');
INSERT INTO `positions` VALUES (16, 'water');
INSERT INTO `positions` VALUES (17, 'water');
INSERT INTO `positions` VALUES (18, 'water');
INSERT INTO `positions` VALUES (19, 'water');
INSERT INTO `positions` VALUES (20, 'water');
INSERT INTO `positions` VALUES (21, 'water');
INSERT INTO `positions` VALUES (22, 'water');
INSERT INTO `positions` VALUES (23, 'water');
INSERT INTO `positions` VALUES (24, 'water');
INSERT INTO `positions` VALUES (25, 'water');
INSERT INTO `positions` VALUES (26, 'water');
INSERT INTO `positions` VALUES (27, 'water');
INSERT INTO `positions` VALUES (28, 'water');
INSERT INTO `positions` VALUES (29, 'water');
INSERT INTO `positions` VALUES (30, 'water');
INSERT INTO `positions` VALUES (31, 'water');
INSERT INTO `positions` VALUES (32, 'water');
INSERT INTO `positions` VALUES (33, 'water');
INSERT INTO `positions` VALUES (34, 'water');
INSERT INTO `positions` VALUES (35, 'water');
INSERT INTO `positions` VALUES (36, 'water');
INSERT INTO `positions` VALUES (37, 'water');
INSERT INTO `positions` VALUES (38, 'water');
INSERT INTO `positions` VALUES (39, 'water');
INSERT INTO `positions` VALUES (40, 'water');
INSERT INTO `positions` VALUES (41, 'water');
INSERT INTO `positions` VALUES (42, 'water');
INSERT INTO `positions` VALUES (43, 'water');
INSERT INTO `positions` VALUES (44, 'water');
INSERT INTO `positions` VALUES (45, 'water');
INSERT INTO `positions` VALUES (46, 'water');
INSERT INTO `positions` VALUES (47, 'water');
INSERT INTO `positions` VALUES (48, 'water');
INSERT INTO `positions` VALUES (49, 'water');
INSERT INTO `positions` VALUES (50, 'water');
INSERT INTO `positions` VALUES (51, 'water');
INSERT INTO `positions` VALUES (52, 'water');
INSERT INTO `positions` VALUES (53, 'water');
INSERT INTO `positions` VALUES (54, 'water');
INSERT INTO `positions` VALUES (55, 'water');
-- 10 for big left? (missing the G)
INSERT INTO `positions` VALUES (56, 'special_island13');
INSERT INTO `positions` VALUES (57, 'special_island13');
INSERT INTO `positions` VALUES (58, 'special_island13');
INSERT INTO `positions` VALUES (59, 'special_island13');
INSERT INTO `positions` VALUES (60, 'special_island13');
INSERT INTO `positions` VALUES (61, 'special_island13');
INSERT INTO `positions` VALUES (62, 'special_island13');
INSERT INTO `positions` VALUES (63, 'special_island13');
INSERT INTO `positions` VALUES (64, 'special_island13');
INSERT INTO `positions` VALUES (65, 'special_island13');
-- 10 for big right
INSERT INTO `positions` VALUES (66, 'special_island14');
INSERT INTO `positions` VALUES (67, 'special_island14');
INSERT INTO `positions` VALUES (68, 'special_island14');
INSERT INTO `positions` VALUES (69, 'special_island14');
INSERT INTO `positions` VALUES (70, 'special_island14');
INSERT INTO `positions` VALUES (71, 'special_island14');
INSERT INTO `positions` VALUES (72, 'special_island14');
INSERT INTO `positions` VALUES (73, 'special_island14');
INSERT INTO `positions` VALUES (74, 'special_island14');
INSERT INTO `positions` VALUES (75, 'special_island14');
-- 4 for island1
INSERT INTO `positions` VALUES (76, 'special_island1');
INSERT INTO `positions` VALUES (77, 'special_island1');
INSERT INTO `positions` VALUES (78, 'special_island1');
INSERT INTO `positions` VALUES (79, 'special_island1');
-- 4 for island2
INSERT INTO `positions` VALUES (80, 'special_island2');
INSERT INTO `positions` VALUES (81, 'special_island2');
INSERT INTO `positions` VALUES (82, 'special_island2');
INSERT INTO `positions` VALUES (83, 'special_island2');
-- 3 for island3
INSERT INTO `positions` VALUES (84, 'special_island3');
INSERT INTO `positions` VALUES (85, 'special_island3');
INSERT INTO `positions` VALUES (86, 'special_island3');
-- 4 for island4
INSERT INTO `positions` VALUES (87, 'special_island4');
INSERT INTO `positions` VALUES (88, 'special_island4');
INSERT INTO `positions` VALUES (89, 'special_island4');
INSERT INTO `positions` VALUES (90, 'special_island4');
-- 4 for island5
INSERT INTO `positions` VALUES (91, 'special_island5');
INSERT INTO `positions` VALUES (92, 'special_island5');
INSERT INTO `positions` VALUES (93, 'special_island5');
INSERT INTO `positions` VALUES (94, 'special_island5');
-- 3 for island6
INSERT INTO `positions` VALUES (95, 'special_island6');
INSERT INTO `positions` VALUES (96, 'special_island6');
INSERT INTO `positions` VALUES (97, 'special_island6');
-- 3 for island7
INSERT INTO `positions` VALUES (98, 'special_island7');
INSERT INTO `positions` VALUES (99, 'special_island7');
INSERT INTO `positions` VALUES (100, 'special_island7');
-- 3 for island8
INSERT INTO `positions` VALUES (101, 'special_island8');
INSERT INTO `positions` VALUES (102, 'special_island8');
INSERT INTO `positions` VALUES (103, 'special_island8');
-- 4 for island9
INSERT INTO `positions` VALUES (104, 'special_island9');
INSERT INTO `positions` VALUES (105, 'special_island9');
INSERT INTO `positions` VALUES (106, 'special_island9');
INSERT INTO `positions` VALUES (107, 'special_island9');
-- 4 for island10
INSERT INTO `positions` VALUES (108, 'special_island10');
INSERT INTO `positions` VALUES (109, 'special_island10');
INSERT INTO `positions` VALUES (110, 'special_island10');
INSERT INTO `positions` VALUES (111, 'special_island10');
-- 3 for island11
INSERT INTO `positions` VALUES (112, 'special_island11');
INSERT INTO `positions` VALUES (113, 'special_island11');
INSERT INTO `positions` VALUES (114, 'special_island11');
-- 4 for island12
INSERT INTO `positions` VALUES (115, 'special_island12');
INSERT INTO `positions` VALUES (116, 'special_island12');
INSERT INTO `positions` VALUES (117, 'special_island12');
INSERT INTO `positions` VALUES (118, 'special_island12');
INSERT INTO `positions` VALUES (119, 'purchase_square');
-- Table of Units
CREATE TABLE IF NOT EXISTS `placements`(
`placementId` int(16) NOT NULL AUTO_INCREMENT,
`gameId` int(5) NOT NULL,
`unitId` int(5) NOT NULL,
`teamId` varchar(10) NOT NULL,
`currentMoves` int(3) NOT NULL,
`positionId` int(4) NOT NULL,
PRIMARY KEY(`placementId`),
FOREIGN KEY (unitId) REFERENCES units(unitId),
FOREIGN KEY (gameId) REFERENCES games(gameId),
FOREIGN KEY (positionId) REFERENCES positions(positionId)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-- Insert placements into table.
INSERT INTO `placements` VALUES (1, 1, 6, 'red', 2, 1);
-- INSERT INTO `placements` VALUES (2, 1, 6, 'red', 1);
-- INSERT INTO `placements` VALUES (3, 1, 6, 'red', 1);
-- INSERT INTO `placements` VALUES (4, 1, 6, 'red', 1);
-- Start-of-Game Placement Map
INSERT INTO `placements` VALUES (1, 3, 6, 'red', 119);
-- this shows overflow mechanics (may change to 9 per position possible)
-- INSERT INTO `placements` VALUES (5, 1, 6, 'red', 1);
-- Table of Movements
CREATE TABLE IF NOT EXISTS `movements`(
`movementId` int(16) NOT NULL AUTO_INCREMENT,
`movementFromPosition` int(4) NOT NULL, -- meat of what is used
`movementNowPlacement` int(16) NOT NULL, -- used for undo moves
`movementCost` int(3) NOT NULL,
`movementGameId` int(5) NOT NULL, -- which game is the movement
`movementTurn` int(5) NOT NULL, -- need what phase/turn movement was made (only undo current phase/turn)
`movementPhase` varchar(20) NOT NULL,
PRIMARY KEY(`movementId`),
FOREIGN KEY (movementGameId) REFERENCES games(gameId),
FOREIGN KEY (movementFromPosition) REFERENCES positions(positionId),
FOREIGN KEY (movementNowPlacement) REFERENCES placements(placementId)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
-- this used for easy testing alone
UPDATE games SET gameBlueJoined=1 WHERE gameId = 1;
-- INSERT INTO placements (gameId, unitId, teamId, positionId) VALUES(1, 6, 'red', 119);
SELECT * FROM placements;
SELECT * FROM movements;
SELECT * FROM movements ORDER BY movementId DESC LIMIT 0, 1;