Skip to content

Commit aed5cd1

Browse files
committed
don't run bot once game is over
1 parent 7c65046 commit aed5cd1

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/client/transport/local.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { Transport } from './transport';
1616
* Otherwise, returns a playerID of a bot that may play now.
1717
*/
1818
export function GetBotPlayer(state, bots) {
19+
if (state.ctx.gameover !== undefined) {
20+
return null;
21+
}
22+
1923
if (state.ctx.stage) {
2024
for (const key of Object.keys(bots)) {
2125
if (key in state.ctx.stage) {

src/client/transport/local.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ describe('GetBotPlayer', () => {
106106
);
107107
expect(result).toEqual(null);
108108
});
109+
110+
test('gameover', () => {
111+
const result = GetBotPlayer(
112+
{
113+
ctx: {
114+
currentPlayer: '0',
115+
gameover: true,
116+
},
117+
},
118+
{ '0': {} }
119+
);
120+
expect(result).toEqual(null);
121+
});
109122
});
110123

111124
describe('LocalMaster', () => {

0 commit comments

Comments
 (0)