diff --git a/src/lobby/react.js b/src/lobby/react.js index b4de722a1..4e4c86a44 100644 --- a/src/lobby/react.js +++ b/src/lobby/react.js @@ -10,6 +10,8 @@ import React from 'react'; import Cookies from 'react-cookies'; import PropTypes from 'prop-types'; import { Client } from '../client/react'; +import { MCTSBot } from '../ai/mcts-bot'; +import { Local } from '../client/transport/local'; import { SocketIO } from '../client/transport/socketio'; import { LobbyConnection } from './connection'; import LobbyLoginForm from './login-form'; @@ -188,6 +190,15 @@ class Lobby extends React.Component { } } + if (gameOpts.numPlayers == 1) { + const maxPlayers = gameCode.game.maxPlayers; + let bots = {}; + for (let i = 1; i < maxPlayers; i++) { + bots[i + ''] = MCTSBot; + } + multiplayer = Local({ bots }); + } + const app = this.props.clientFactory({ game: gameCode.game, board: gameCode.board, @@ -198,7 +209,7 @@ class Lobby extends React.Component { const game = { app: app, gameID: gameOpts.gameID, - playerID: gameOpts.numPlayers > 1 ? gameOpts.playerID : null, + playerID: gameOpts.numPlayers > 1 ? gameOpts.playerID : '0', credentials: this.connection.playerCredentials, }; diff --git a/src/lobby/react.test.js b/src/lobby/react.test.js index a2a3615cc..b7cd9e39d 100644 --- a/src/lobby/react.test.js +++ b/src/lobby/react.test.js @@ -443,8 +443,9 @@ describe('lobby', () => { .simulate('click'); expect(lobby.instance().state.runningGame).toEqual({ app: NullComponent, + credentials: undefined, gameID: 'gameID2', - playerID: null, + playerID: '0', }); });