Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/client/transport/socketio.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class SocketIO {
this.store = store;
this.socketOpts = socketOpts;
this.gameName = gameName || 'default';
this.gameName = this.gameName.replace(' ', '-');
this.gameID = gameID || 'default';
this.playerID = playerID || null;
this.numPlayers = numPlayers || 2;
Expand Down
1 change: 1 addition & 0 deletions src/core/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function Game(game) {

return {
...game,
name: game.name.replace(' ', '-'),
Comment thread
jasonharrison marked this conversation as resolved.
Outdated

moveNames: game.flow.moveNames,

Expand Down
14 changes: 7 additions & 7 deletions src/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {

router.post('/games/:name/create', koaBody(), async ctx => {
// The name of the game (for example: tic-tac-toe).
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
Comment thread
jasonharrison marked this conversation as resolved.
Outdated
// User-data to pass to the game setup function.
const setupData = ctx.request.body.setupData;
// The number of players for this game instance.
Expand All @@ -106,7 +106,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.get('/games/:name', async ctx => {
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const gameList = await db.list();
let rooms = [];
for (let key of [...gameList]) {
Expand All @@ -131,7 +131,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.get('/games/:name/:id', async ctx => {
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const gameID = ctx.params.id;
const room = await db.get(`${gameName}:${GameMetadataKey(gameID)}`);
if (!room) {
Expand All @@ -155,7 +155,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
if (!playerName) {
ctx.throw(403, 'playerName is required');
}
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const roomID = ctx.params.id;
const namespacedGameID = getNamespacedGameID(roomID, gameName);
const gameMetadata = await db.get(GameMetadataKey(namespacedGameID));
Expand All @@ -180,7 +180,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/leave', koaBody(), async ctx => {
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down Expand Up @@ -212,7 +212,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/playAgain', koaBody(), async ctx => {
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down Expand Up @@ -264,7 +264,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/rename', koaBody(), async ctx => {
const gameName = ctx.params.name;
const gameName = ctx.params.name.replace(' ', '-');
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down