-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv1.yml
421 lines (421 loc) · 11.9 KB
/
v1.yml
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
openapi: 3.1.0
info:
title: hackathon_22_winter_01
version: '1.0'
servers:
- url: 'http://localhost:8080'
paths:
/ping:
get:
summary: GET /ping
tags:
- ping
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
operationId: ping
description: ヘルスチェック用のエンドポイント
/ws:
get:
summary: GET /ws
tags:
- ws
parameters:
- name: name
schema:
type: string
in: query
required: true
description: ユーザー名
- name: roomId
schema:
$ref: '#/components/schemas/RoomId'
in: query
required: false
description: ルームID (指定しない場合は部屋を作成する)
# TODO: implement
# - name: random
# type: boolean
# in: query
# required: false
# description: ランダムマッチに参加するかどうか
responses:
'200':
description: OK
operationId: connect-to-ws
description: |-
Websocketを用いて双方向通信を行う
- クライアント → サーバー (送信)
- `#/components/schemas/WsRequest`型のJSON文字列をサーバーに送信します
- `type`が`XXX`のとき`body`の型は`#/components/schemas/WsRequestBodyXXX`です
- サーバー → クライアント (受信)
- `#/components/schemas/WsResponse`型のJSON文字列をサーバーに送信します
- `type`が`XXX`のとき`body`の型は`#/components/schemas/WsResponseBodyXXX`です
components:
schemas:
RoomId:
title: RoomId
type: string
format: uuid
description: ルームUUID
PlayerId:
title: PlayerId
type: string
format: uuid
description: プレイヤーUUID
CardId:
title: CardId
type: string
format: uuid
description: カードUUID
RailId:
title: RailId
type: string
format: uuid
description: レールUUID
CardType:
title: CardType
type: string
enum:
- yolo
- galaxyBrain
- openSourcerer
- refactoring
- pairExtraordinaire
- lgtm
- pullShark
- starstruck
- zeroDay
- ooops
- none
description: カードの効果の種類
LifeEventType:
title: LifeEventType
type: string
enum:
- damaged
- healed
description: ライフに関するイベントの種類
BlockEventType:
title: BlockEventType
type: string
enum:
- canceled
- crashed
description: ブロックに関するイベントの種類
Card:
title: Card
type: object
properties:
id:
$ref: '#/components/schemas/CardId'
type:
$ref: '#/components/schemas/CardType'
required:
- id
- type
description: カード情報
Player:
title: Player
type: object
properties:
id:
$ref: '#/components/schemas/PlayerId'
description: プレイヤーのレールのリスト
name:
type: string
description: プレイヤーの名前
life:
$ref: '#/components/schemas/Life'
required:
- id
- name
- life
description: プレイヤー情報
RailIndex:
title: RailIndex
type: integer
minimum: 0
maximum: 6
description: レールのインデックス
Life:
title: Life
type: number
maximum: 100
minimum: 0
description: ライフ
WsRequest:
title: WsRequest
type: object
properties:
type:
$ref: '#/components/schemas/WsRequestType'
body:
oneOf:
- $ref: '#/components/schemas/WsRequestBodyGameStartEvent'
- $ref: '#/components/schemas/WsRequestBodyLifeEvent'
- $ref: '#/components/schemas/WsRequestBodyCardEvent'
- $ref: '#/components/schemas/WsRequestBodyBlockEvent'
- $ref: '#/components/schemas/WsRequestBodyCardForAllEvent'
description: イベントの情報
required:
- type
- body
description: Websocket接続中にサーバーに送信するオブジェクト
WsRequestType:
title: WsRequestType
type: string
enum:
- gameStartEvent
- lifeEvent
- cardEvent
- blockEvent
- cardForAllEvent
description: イベントの種類
WsRequestBodyGameStartEvent:
title: WsRequestBodyGameStartEvent
type: object
description: ゲーム開始時にサーバーに送信するオブジェクト
WsRequestBodyLifeEvent:
title: WsRequestBodyLifeEvent
type: object
properties:
type:
$ref: '#/components/schemas/LifeEventType'
diff:
type: number
description: ライフの変化量
required:
- type
- diff
description: ライフに関するイベントの情報
WsRequestBodyCardEvent:
title: WsRequestBodyCardEvent
type: object
properties:
id:
$ref: '#/components/schemas/CardId'
targetId:
$ref: '#/components/schemas/PlayerId'
type:
$ref: '#/components/schemas/CardType'
required:
- id
- targetId
- type
description: カードに関するイベントの情報
WsRequestBodyBlockEvent:
title: WsRequestBodyBlockEvent
type: object
properties:
type:
$ref: '#/components/schemas/BlockEventType'
cardType:
$ref: '#/components/schemas/CardType'
railIndex:
$ref: '#/components/schemas/RailIndex'
required:
- type
- railIndex
description: ブロックに関するイベントの情報
WsRequestBodyCardForAllEvent:
title: WsRequestBodyCardForAllEvent
type: object
properties:
id:
$ref: '#/components/schemas/CardId'
type:
$ref: '#/components/schemas/CardType'
required:
- id
- type
description: 全プレイヤーに影響を与えるカードに関するイベントの情報
WsResponse:
title: WsResponse
type: object
properties:
type:
$ref: '#/components/schemas/WsResponseType'
body:
oneOf:
- $ref: '#/components/schemas/WsResponseBodyConnected'
- $ref: '#/components/schemas/WsResponseBodyGameStarted'
- $ref: '#/components/schemas/WsResponseBodyLifeChanged'
- $ref: '#/components/schemas/WsResponseBodyRailCreated'
- $ref: '#/components/schemas/WsResponseBodyRailMerged'
- $ref: '#/components/schemas/WsResponseBodyBlockCreated'
- $ref: '#/components/schemas/WsResponseBodyBlockCanceled'
- $ref: '#/components/schemas/WsResponseBodyBlockCrashed'
- $ref: '#/components/schemas/WsResponseBodyGameOverred'
description: イベントの情報
eventTime:
type: string
format: date-time
description: イベントの発生時刻
required:
- type
- body
- eventTime
description: Websocket接続中にサーバーから受信するオブジェクト
WsResponseType:
title: WsResponseType
type: string
enum:
- connected
- gameStarted
- lifeChanged
- railCreated
- railMerged
- blockCreated
- blockCanceled
- blockCrashed
- gameOverred
- noop
description: イベントの種類
WsResponseBodyConnected:
type: object
properties:
playerId:
$ref: '#/components/schemas/PlayerId'
required:
- playerId
description: 接続したプレイヤーのID
WsResponseBodyGameStarted:
type: object
properties:
players:
type: array
items:
$ref: '#/components/schemas/Player'
description: 各プレイヤーの情報
required:
- players
description: ゲーム開始時の情報
WsResponseBodyLifeChanged:
type: object
properties:
playerId:
$ref: '#/components/schemas/PlayerId'
cardType:
$ref: '#/components/schemas/CardType'
newLife:
$ref: '#/components/schemas/Life'
description: 変動後のライフ
required:
- playerId
- newLife
description: ライフの変動情報
WsResponseBodyRailCreated:
type: object
properties:
newRail:
$ref: '#/components/schemas/RailIndex'
description: 新規に作成されたレールのインデックス
parentRail:
$ref: '#/components/schemas/RailIndex'
description: 分岐元のレールのインデックス
attackerId:
$ref: '#/components/schemas/PlayerId'
targetId:
$ref: '#/components/schemas/PlayerId'
cardType:
$ref: '#/components/schemas/CardType'
required:
- newRail
- parentRail
- attackerId
- targetId
- cardType
description: 新規レールの作成情報
WsResponseBodyRailMerged:
type: object
properties:
childRail:
$ref: '#/components/schemas/RailIndex'
description: マージされたレールのインデックス
parentRail:
$ref: '#/components/schemas/RailIndex'
description: 結合先のレールのインデックス
playerId:
$ref: '#/components/schemas/PlayerId'
cardType:
$ref: '#/components/schemas/CardType'
required:
- childRail
- parentRail
- playerId
- cardType
description: レールのマージ情報
WsResponseBodyBlockCreated:
type: object
properties:
attackerId:
$ref: '#/components/schemas/PlayerId'
targetId:
$ref: '#/components/schemas/PlayerId'
cardType:
$ref: '#/components/schemas/CardType'
railIndex:
$ref: '#/components/schemas/RailIndex'
delay:
type: integer
minimum: 1
maximum: 5
description: 障害物を解消するために必要な秒数
attack:
type: number
format: float
minimum: 10
maximum: 50
description: 障害物と衝突したときに与えるダメージ
required:
- attackerId
- targetId
- cardType
- railIndex
- delay
- attack
description: 新規障害物の作成情報
WsResponseBodyBlockCanceled:
type: object
properties:
targetId:
$ref: '#/components/schemas/PlayerId'
railIndex:
$ref: '#/components/schemas/RailIndex'
cardType:
$ref: '#/components/schemas/CardType'
required:
- targetId
- railIndex
description: 障害物の解消情報
WsResponseBodyBlockCrashed:
type: object
properties:
targetId:
$ref: '#/components/schemas/PlayerId'
railIndex:
$ref: '#/components/schemas/RailIndex'
description: 衝突したレールのインデックス
cardType:
$ref: '#/components/schemas/CardType'
required:
- targetId
- railIndex
description: 障害物と衝突したときの情報
WsResponseBodyGameOverred:
type: object
properties:
playerId:
$ref: '#/components/schemas/PlayerId'
required:
- playerId
tags:
- name: ping
description: Ping API
- name: ws
description: Websocket API