mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 11:03:54 -07:00
harden implementations
This commit is contained in:
parent
c3ae4cffd6
commit
559a3ff1f4
25 changed files with 240 additions and 37 deletions
|
|
@ -30,6 +30,8 @@ import { setSideboardLock } from './setSideboardLock';
|
|||
import { setSideboardPlan } from './setSideboardPlan';
|
||||
import { shuffle } from './shuffle';
|
||||
import { undoDraw } from './undoDraw';
|
||||
import { unconcede } from './unconcede';
|
||||
import { judge } from './judge';
|
||||
|
||||
jest.mock('../../services/BackendService', () => ({
|
||||
BackendService: { sendGameCommand: jest.fn() },
|
||||
|
|
@ -197,4 +199,19 @@ describe('Game commands — delegate to BackendService.sendGameCommand', () => {
|
|||
undoDraw(gameId);
|
||||
expect(BackendService.sendGameCommand).toHaveBeenCalledWith(gameId, 'Command_UndoDraw', {});
|
||||
});
|
||||
|
||||
it('unconcede sends Command_Unconcede with empty object', () => {
|
||||
unconcede(gameId);
|
||||
expect(BackendService.sendGameCommand).toHaveBeenCalledWith(gameId, 'Command_Unconcede', {});
|
||||
});
|
||||
|
||||
it('judge sends Command_Judge with targetId and wrapped gameCommand array', () => {
|
||||
const targetId = 3;
|
||||
const innerGameCommand = { '.Command_DrawCards.ext': { numberOfCards: 2 } };
|
||||
judge(gameId, targetId, innerGameCommand);
|
||||
expect(BackendService.sendGameCommand).toHaveBeenCalledWith(gameId, 'Command_Judge', {
|
||||
targetId,
|
||||
gameCommand: [innerGameCommand],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ export { kickFromGame } from './kickFromGame';
|
|||
export { gameSay } from './gameSay';
|
||||
export { readyStart } from './readyStart';
|
||||
export { concede } from './concede';
|
||||
export { unconcede } from './unconcede';
|
||||
export { judge } from './judge';
|
||||
export { nextTurn } from './nextTurn';
|
||||
export { setActivePhase } from './setActivePhase';
|
||||
export { reverseTurn } from './reverseTurn';
|
||||
|
|
|
|||
8
webclient/src/websocket/commands/game/judge.ts
Normal file
8
webclient/src/websocket/commands/game/judge.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { BackendService } from '../../services/BackendService';
|
||||
|
||||
export function judge(gameId: number, targetId: number, innerGameCommand: any): void {
|
||||
BackendService.sendGameCommand(gameId, 'Command_Judge', {
|
||||
targetId,
|
||||
gameCommand: [innerGameCommand],
|
||||
});
|
||||
}
|
||||
5
webclient/src/websocket/commands/game/unconcede.ts
Normal file
5
webclient/src/websocket/commands/game/unconcede.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { BackendService } from '../../services/BackendService';
|
||||
|
||||
export function unconcede(gameId: number): void {
|
||||
BackendService.sendGameCommand(gameId, 'Command_Unconcede', {});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue