Begin work on a randomize teams method.
This commit is contained in:
parent
a7d718333d
commit
c6546af332
1 changed files with 31 additions and 0 deletions
31
server/src/events/RandomizeTeam.ts
Normal file
31
server/src/events/RandomizeTeam.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { games, log } from '../main';
|
||||
import { Server, Socket } from 'socket.io';
|
||||
|
||||
export default (io: Server, socket: Socket, data: RandomizeTeam) => {
|
||||
try {
|
||||
socket.emit(`RandomizeTeam`, {
|
||||
status: 501,
|
||||
message: `Not Implemented Yet`,
|
||||
source: `RandomizeTeam`,
|
||||
});
|
||||
|
||||
// Assert game exists
|
||||
if (!games[data.game_code]) {
|
||||
log.debug(`Can't find game with code: ${data.game_code}`);
|
||||
socket.emit(`RandomizedTeams`, {
|
||||
status: 404,
|
||||
message: `Game with code ${data.game_code} could not be found`,
|
||||
source: `RandomizeTeams`
|
||||
});
|
||||
return;
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
log.prettyError(err);
|
||||
socket.emit(`RandomizeTeam`, {
|
||||
status: 500,
|
||||
message: `${err.name}: ${err.message}`,
|
||||
source: `RandomizeTeam`,
|
||||
});
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue