moons-ta-client 1.1.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -16
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/custom-event-emitter.d.ts +2 -1
- package/dist/custom-event-emitter.js +3 -0
- package/dist/index.d.ts +279 -180
- package/dist/index.esm.js +884 -500
- package/dist/models/commands.d.ts +33 -36
- package/dist/models/commands.js +47 -51
- package/dist/models/models.d.ts +48 -22
- package/dist/models/models.js +97 -29
- package/dist/models/packets.d.ts +6 -0
- package/dist/models/packets.js +10 -0
- package/dist/models/requests.d.ts +161 -71
- package/dist/models/requests.js +341 -157
- package/dist/models/responses.d.ts +8 -34
- package/dist/models/responses.js +29 -87
- package/dist/tournament-assistant-client.d.ts +17 -14
- package/dist/tournament-assistant-client.js +109 -62
- package/package.json +1 -1
|
@@ -62,13 +62,8 @@ export class TAClient extends CustomEventEmitter {
|
|
|
62
62
|
from: this.stateManager.getSelfGuid(),
|
|
63
63
|
id: uuidv4(),
|
|
64
64
|
packet: {
|
|
65
|
-
oneofKind: "
|
|
66
|
-
|
|
67
|
-
type: {
|
|
68
|
-
oneofKind: "heartbeat",
|
|
69
|
-
heartbeat: true,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
65
|
+
oneofKind: "heartbeat",
|
|
66
|
+
heartbeat: true,
|
|
72
67
|
},
|
|
73
68
|
});
|
|
74
69
|
}, 10000);
|
|
@@ -104,31 +99,16 @@ export class TAClient extends CustomEventEmitter {
|
|
|
104
99
|
this.token = token;
|
|
105
100
|
this.client?.setToken(token);
|
|
106
101
|
}
|
|
107
|
-
|
|
102
|
+
sendCommand(command) {
|
|
108
103
|
this.client?.send({
|
|
109
104
|
token: "",
|
|
110
|
-
from: packet.from,
|
|
111
|
-
id: packet.id,
|
|
112
|
-
packet: {
|
|
113
|
-
oneofKind: "forwardingPacket",
|
|
114
|
-
forwardingPacket: {
|
|
115
|
-
forwardTo: to,
|
|
116
|
-
packet,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
sendCommand(command, to) {
|
|
122
|
-
const packet = {
|
|
123
|
-
token: this.token,
|
|
124
105
|
from: this.stateManager.getSelfGuid(),
|
|
125
106
|
id: uuidv4(),
|
|
126
107
|
packet: {
|
|
127
108
|
oneofKind: "command",
|
|
128
109
|
command,
|
|
129
110
|
},
|
|
130
|
-
};
|
|
131
|
-
this.forwardToUsers(packet, to);
|
|
111
|
+
});
|
|
132
112
|
}
|
|
133
113
|
async sendRequest(request, to, timeout = 30000) {
|
|
134
114
|
const packet = {
|
|
@@ -213,16 +193,10 @@ export class TAClient extends CustomEventEmitter {
|
|
|
213
193
|
};
|
|
214
194
|
addListeners();
|
|
215
195
|
});
|
|
216
|
-
|
|
217
|
-
if (to) {
|
|
218
|
-
this.forwardToUsers(packet, to);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
this.client?.send(packet, to);
|
|
222
|
-
}
|
|
196
|
+
this.client?.send(packet);
|
|
223
197
|
return responsesPromise;
|
|
224
198
|
}
|
|
225
|
-
async sendResponse(response
|
|
199
|
+
async sendResponse(response) {
|
|
226
200
|
const packet = {
|
|
227
201
|
token: this.token,
|
|
228
202
|
from: this.stateManager.getSelfGuid(),
|
|
@@ -232,81 +206,86 @@ export class TAClient extends CustomEventEmitter {
|
|
|
232
206
|
response,
|
|
233
207
|
},
|
|
234
208
|
};
|
|
235
|
-
|
|
236
|
-
this.forwardToUsers(packet, to);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
this.client?.send(packet, to);
|
|
240
|
-
}
|
|
209
|
+
this.client?.send(packet);
|
|
241
210
|
}
|
|
242
211
|
// --- Commands --- //
|
|
243
|
-
playSong = (gameplayParameters, userIds) => {
|
|
212
|
+
playSong = (tournamentId, gameplayParameters, userIds) => {
|
|
244
213
|
this.sendCommand({
|
|
214
|
+
tournamentId,
|
|
215
|
+
forwardTo: userIds,
|
|
245
216
|
type: {
|
|
246
217
|
oneofKind: "playSong",
|
|
247
218
|
playSong: {
|
|
248
219
|
gameplayParameters,
|
|
249
220
|
},
|
|
250
221
|
},
|
|
251
|
-
}
|
|
222
|
+
});
|
|
252
223
|
};
|
|
253
|
-
returnToMenu = (userIds) => {
|
|
224
|
+
returnToMenu = (tournamentId, userIds) => {
|
|
254
225
|
this.sendCommand({
|
|
226
|
+
tournamentId,
|
|
227
|
+
forwardTo: userIds,
|
|
255
228
|
type: {
|
|
256
229
|
oneofKind: "returnToMenu",
|
|
257
230
|
returnToMenu: true,
|
|
258
231
|
},
|
|
259
|
-
}
|
|
232
|
+
});
|
|
260
233
|
};
|
|
261
|
-
flipColors = (userIds) => {
|
|
234
|
+
flipColors = (tournamentId, userIds) => {
|
|
262
235
|
this.sendCommand({
|
|
236
|
+
tournamentId,
|
|
237
|
+
forwardTo: userIds,
|
|
263
238
|
type: {
|
|
264
239
|
oneofKind: "modifyGameplay",
|
|
265
240
|
modifyGameplay: {
|
|
266
241
|
modifier: Command_ModifyGameplay_Modifier.InvertColors,
|
|
267
242
|
},
|
|
268
243
|
},
|
|
269
|
-
}
|
|
244
|
+
});
|
|
270
245
|
};
|
|
271
|
-
flipHands = (userIds) => {
|
|
246
|
+
flipHands = (tournamentId, userIds) => {
|
|
272
247
|
this.sendCommand({
|
|
248
|
+
tournamentId,
|
|
249
|
+
forwardTo: userIds,
|
|
273
250
|
type: {
|
|
274
251
|
oneofKind: "modifyGameplay",
|
|
275
252
|
modifyGameplay: {
|
|
276
253
|
modifier: Command_ModifyGameplay_Modifier.InvertHandedness,
|
|
277
254
|
},
|
|
278
255
|
},
|
|
279
|
-
}
|
|
256
|
+
});
|
|
280
257
|
};
|
|
281
|
-
showLoadedImage = (userIds, show = true) => {
|
|
258
|
+
showLoadedImage = (tournamentId, userIds, show = true) => {
|
|
282
259
|
this.sendCommand({
|
|
260
|
+
tournamentId,
|
|
261
|
+
forwardTo: userIds,
|
|
283
262
|
type: {
|
|
284
263
|
oneofKind: "streamSyncShowImage",
|
|
285
264
|
streamSyncShowImage: show,
|
|
286
265
|
},
|
|
287
|
-
}
|
|
266
|
+
});
|
|
288
267
|
};
|
|
289
|
-
showColor =
|
|
290
|
-
|
|
268
|
+
showColor = (tournamentId, color, userIds) => {
|
|
269
|
+
this.sendCommand({
|
|
270
|
+
tournamentId,
|
|
271
|
+
forwardTo: userIds,
|
|
291
272
|
type: {
|
|
292
273
|
oneofKind: "showColorForStreamSync",
|
|
293
274
|
showColorForStreamSync: {
|
|
294
275
|
color,
|
|
295
276
|
},
|
|
296
277
|
},
|
|
297
|
-
}
|
|
298
|
-
if (response.length <= 0) {
|
|
299
|
-
throw new Error("Server timed out, or no users responded");
|
|
300
|
-
}
|
|
301
|
-
return response;
|
|
278
|
+
});
|
|
302
279
|
};
|
|
303
|
-
delayTestFinished = (userIds) => {
|
|
280
|
+
delayTestFinished = (tournamentId, userIds) => {
|
|
304
281
|
this.sendCommand({
|
|
282
|
+
tournamentId,
|
|
283
|
+
forwardTo: userIds,
|
|
305
284
|
type: {
|
|
306
285
|
oneofKind: "delayTestFinish",
|
|
307
286
|
delayTestFinish: true,
|
|
308
287
|
},
|
|
309
|
-
}
|
|
288
|
+
});
|
|
310
289
|
};
|
|
311
290
|
// --- Requests --- //
|
|
312
291
|
joinTournament = async (tournamentId) => {
|
|
@@ -341,11 +320,13 @@ export class TAClient extends CustomEventEmitter {
|
|
|
341
320
|
}
|
|
342
321
|
return response[0].response;
|
|
343
322
|
};
|
|
344
|
-
loadSong = async (levelId, userIds, timeout) => {
|
|
323
|
+
loadSong = async (tournamentId, levelId, userIds, timeout) => {
|
|
345
324
|
const response = await this.sendRequest({
|
|
346
325
|
type: {
|
|
347
326
|
oneofKind: "loadSong",
|
|
348
327
|
loadSong: {
|
|
328
|
+
tournamentId,
|
|
329
|
+
forwardTo: userIds,
|
|
349
330
|
levelId,
|
|
350
331
|
customHostUrl: "",
|
|
351
332
|
},
|
|
@@ -356,11 +337,13 @@ export class TAClient extends CustomEventEmitter {
|
|
|
356
337
|
}
|
|
357
338
|
return response;
|
|
358
339
|
};
|
|
359
|
-
loadImage = async (bitmap, userIds) => {
|
|
340
|
+
loadImage = async (tournamentId, bitmap, userIds) => {
|
|
360
341
|
const response = await this.sendRequest({
|
|
361
342
|
type: {
|
|
362
343
|
oneofKind: "preloadImageForStreamSync",
|
|
363
344
|
preloadImageForStreamSync: {
|
|
345
|
+
tournamentId,
|
|
346
|
+
forwardTo: userIds,
|
|
364
347
|
fileId: uuidv4(),
|
|
365
348
|
data: bitmap,
|
|
366
349
|
compressed: false,
|
|
@@ -372,11 +355,13 @@ export class TAClient extends CustomEventEmitter {
|
|
|
372
355
|
}
|
|
373
356
|
return response;
|
|
374
357
|
};
|
|
375
|
-
showPrompt = async (userIds, titleText, bodyText, canClose, options, timer) => {
|
|
358
|
+
showPrompt = async (tournamentId, userIds, titleText, bodyText, canClose, options, timer) => {
|
|
376
359
|
const response = await this.sendRequest({
|
|
377
360
|
type: {
|
|
378
361
|
oneofKind: "showPrompt",
|
|
379
362
|
showPrompt: {
|
|
363
|
+
tournamentId,
|
|
364
|
+
forwardTo: userIds,
|
|
380
365
|
promptId: uuidv4(),
|
|
381
366
|
messageTitle: titleText,
|
|
382
367
|
messageText: bodyText,
|
|
@@ -854,14 +839,14 @@ export class TAClient extends CustomEventEmitter {
|
|
|
854
839
|
}
|
|
855
840
|
return response[0].response;
|
|
856
841
|
};
|
|
857
|
-
addAuthorizedUser = async (tournamentId, discordId,
|
|
842
|
+
addAuthorizedUser = async (tournamentId, discordId, roleIds) => {
|
|
858
843
|
const response = await this.sendRequest({
|
|
859
844
|
type: {
|
|
860
845
|
oneofKind: "addAuthorizedUser",
|
|
861
846
|
addAuthorizedUser: {
|
|
862
847
|
tournamentId,
|
|
863
848
|
discordId,
|
|
864
|
-
|
|
849
|
+
roleIds,
|
|
865
850
|
},
|
|
866
851
|
},
|
|
867
852
|
});
|
|
@@ -1105,6 +1090,68 @@ export class TAClient extends CustomEventEmitter {
|
|
|
1105
1090
|
}
|
|
1106
1091
|
return response[0].response;
|
|
1107
1092
|
};
|
|
1093
|
+
addTournamentRole = async (tournamentId, role) => {
|
|
1094
|
+
const response = await this.sendRequest({
|
|
1095
|
+
type: {
|
|
1096
|
+
oneofKind: "addTournamentRole",
|
|
1097
|
+
addTournamentRole: {
|
|
1098
|
+
tournamentId,
|
|
1099
|
+
role,
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
});
|
|
1103
|
+
if (response.length <= 0) {
|
|
1104
|
+
throw new Error("Server timed out");
|
|
1105
|
+
}
|
|
1106
|
+
return response[0].response;
|
|
1107
|
+
};
|
|
1108
|
+
setTournamentRoleName = async (tournamentId, roleId, roleName) => {
|
|
1109
|
+
const response = await this.sendRequest({
|
|
1110
|
+
type: {
|
|
1111
|
+
oneofKind: "setTournamentRoleName",
|
|
1112
|
+
setTournamentRoleName: {
|
|
1113
|
+
tournamentId,
|
|
1114
|
+
roleId,
|
|
1115
|
+
roleName,
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
});
|
|
1119
|
+
if (response.length <= 0) {
|
|
1120
|
+
throw new Error("Server timed out");
|
|
1121
|
+
}
|
|
1122
|
+
return response[0].response;
|
|
1123
|
+
};
|
|
1124
|
+
setTournamentRolePermissions = async (tournamentId, roleId, permissions) => {
|
|
1125
|
+
const response = await this.sendRequest({
|
|
1126
|
+
type: {
|
|
1127
|
+
oneofKind: "setTournamentRolePermissions",
|
|
1128
|
+
setTournamentRolePermissions: {
|
|
1129
|
+
tournamentId,
|
|
1130
|
+
roleId,
|
|
1131
|
+
permissions,
|
|
1132
|
+
},
|
|
1133
|
+
},
|
|
1134
|
+
});
|
|
1135
|
+
if (response.length <= 0) {
|
|
1136
|
+
throw new Error("Server timed out");
|
|
1137
|
+
}
|
|
1138
|
+
return response[0].response;
|
|
1139
|
+
};
|
|
1140
|
+
removeTournamentRole = async (tournamentId, roleId) => {
|
|
1141
|
+
const response = await this.sendRequest({
|
|
1142
|
+
type: {
|
|
1143
|
+
oneofKind: "removeTournamentRole",
|
|
1144
|
+
removeTournamentRole: {
|
|
1145
|
+
tournamentId,
|
|
1146
|
+
roleId,
|
|
1147
|
+
},
|
|
1148
|
+
},
|
|
1149
|
+
});
|
|
1150
|
+
if (response.length <= 0) {
|
|
1151
|
+
throw new Error("Server timed out");
|
|
1152
|
+
}
|
|
1153
|
+
return response[0].response;
|
|
1154
|
+
};
|
|
1108
1155
|
addTournamentTeam = async (tournamentId, team) => {
|
|
1109
1156
|
const response = await this.sendRequest({
|
|
1110
1157
|
type: {
|