本文整理匯總了TypeScript中app/services/game.service.GameService類的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.GameService類的具體用法?TypeScript service.GameService怎麽用?TypeScript service.GameService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了service.GameService類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe("PlayingState", () => {
let player1PlayingState: State;
let player2PlayingState: State;
let gameService: GameService;
let board: Board;
beforeEach(() => {
gameService = new GameService();
board = gameService.getBoard();
player1PlayingState = gameService.getPlayer1PlayingState();
player2PlayingState = gameService.getPlayer2PlayingState();
});
it("should change player at end of turn", () => {
gameService.changeState(player1PlayingState);
player1PlayingState.endTurn();
expect(gameService.getState()).toEqual(player2PlayingState);
});
it("should not change player if can't play disc", () => {
spyOn(board, "playDisc").and.returnValue(false);
gameService.changeState(player1PlayingState);
player1PlayingState.takeTurn(0);
expect(gameService.getState()).toEqual(player1PlayingState);
});
it("should set state to tie if no more moves can be made", () => {
spyOn(board, "isFull").and.returnValue(true);
gameService.changeState(player1PlayingState);
player1PlayingState.endTurn();
expect(gameService.getState()).toEqual(gameService.getTieState());
});
it("should set state to win if win is detected", () => {
spyOn(board, "playDisc").and.returnValue(true);
spyOn(board, "checkForWin").and.returnValue(true);
gameService.changeState(player1PlayingState);
player1PlayingState.takeTurn(0);
expect(gameService.getState()).toEqual(gameService.getPlayer1WinState());
});
});
示例2: beforeEach
beforeEach(() => {
gameService = new GameService();
board = gameService.getBoard();
player1PlayingState = gameService.getPlayer1PlayingState();
player2PlayingState = gameService.getPlayer2PlayingState();
});
示例3: it
it("should set state to win if win is detected", () => {
spyOn(board, "playDisc").and.returnValue(true);
spyOn(board, "checkForWin").and.returnValue(true);
gameService.changeState(player1PlayingState);
player1PlayingState.takeTurn(0);
expect(gameService.getState()).toEqual(gameService.getPlayer1WinState());
});