-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.wasp
192 lines (163 loc) Β· 4.54 KB
/
main.wasp
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
app ProjectBird {
wasp: {
version: "^0.10.2"
},
title: "Office Wars - A Strategy Game",
auth: {
userEntity: User,
methods: {
usernameAndPassword: {}
},
onAuthFailedRedirectTo: "/login"
},
client: {
rootComponent: import App from "@client/App",
},
dependencies: [
("react-p5", "1.3.35"),
("framer-motion", "6.5.1"),
]
}
// π‘ Wasp Routes
route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
component: import Main from "@client/MainPage"
}
route GameRoute { path: "/game/:id", to: GamePage }
page GamePage {
authRequired: true,
component: import GamePage from "@client/GamePage"
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/auth/SignupPage"
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/auth/LoginPage"
}
route DemoRoute { path: "/demo/:id", to: DemoPage }
page DemoPage {
authRequired: true,
component: import Login from "@client/DemoArea/DemoPage"
}
// π Queries
query getTank {
fn: import { getTank } from "@server/queries.js",
entities: [Tank]
}
query getGame {
fn: import { getGame } from "@server/queries.js",
entities: [Game, User, PlayerInGame]
}
query getFOV {
fn: import { getFOV } from "@server/queries.js",
entities: [Game]
}
query getState {
fn: import { getState } from "@server/queries.js",
entities: [Game, Board, PlayerInGame]
}
// π Actions
action addTank {
fn: import { addTank } from "@server/actions.js",
entities: [Tank]
}
action updateTank {
fn: import { updateTank } from "@server/actions.js",
entities: [Tank]
}
action removeTank {
fn: import { removeTank } from "@server/actions.js",
entities: [Tank]
}
action generateGame {
fn: import { generateGame } from "@server/actions.js",
entities: [Tank, Game, Board, PlayerInGame]
}
action abandonGame {
fn: import { abandonGame } from "@server/actions.js",
entities: [PlayerInGame]
}
action joinGame {
fn: import { joinGame } from "@server/actions.js",
entities: [Game, Tank, PlayerInGame]
}
action launchGame {
fn: import { launchGame } from "@server/actions.js",
entities: [Game, User, PlayerInGame, Board]
}
action spawnPlayers {
fn: import { spawnPlayers } from "@server/actions.js",
entities: [Game, PlayerInGame, Board]
}
action demoAction {
fn: import { demoAction } from "@server/actions.js",
entities: []
}
action actionInGame {
fn: import { actionInGame } from "@server/actions.js",
entities: [Game, PlayerInGame, Board]
}
// π¦ Entities
entity User {=psl
id Int @id @default(autoincrement())
username String @unique
password String
adminOf Game[]
playsIn PlayerInGame[]
tanks Tank[]
psl=}
entity Game {=psl
id Int @id @default(autoincrement())
code String @unique
state String @default("lobby") // should be an enum but that's not supported yet
admin User @relation(fields: [adminId], references: [id])
adminId Int
started_at DateTime?
ended_at DateTime?
board Board?
players PlayerInGame[]
plays PlayInGame[]
psl=}
entity Board {=psl
id Int @id @default(autoincrement())
game Game @relation(fields: [gameId], references: [id])
gameId Int @unique
state String @default("[]")
psl=}
entity PlayerInGame {=psl
id Int @id @default(autoincrement())
order Int
game Game @relation(fields: [gameId], references: [id])
gameId Int
user User @relation(fields: [userId], references: [id])
userId Int
state String @default("[]")
tank Tank @relation(fields: [tankId], references: [id])
tankId Int
mp Int @default(10)
hp Int @default(100)
plays PlayInGame[]
@@unique([gameId, userId])
psl=}
entity Tank {=psl
id Int @id @default(autoincrement())
agility Int @default(1)
armor Int @default(1)
accuracy Int @default(1)
attackPower Int @default(1)
color String @default("353f4a")
creator User @relation(fields: [creatorId], references: [id])
creatorId Int
usedOn PlayerInGame[]
psl=}
entity PlayInGame {=psl
id Int @id @default(autoincrement())
player PlayerInGame @relation(fields: [playerId], references: [id])
playerId Int
game Game @relation(fields: [gameId], references: [id])
gameId Int
play String @default("")
psl=}