Commit 4cb11592 authored by Alex MOULIN's avatar Alex MOULIN
Browse files

npm

parent 328eaa8b
This diff is collapsed.
...@@ -3,9 +3,9 @@ import { IToken } from './../codegen/common/Token'; ...@@ -3,9 +3,9 @@ import { IToken } from './../codegen/common/Token';
import { ICard } from './../codegen/common/Card'; import { ICard } from './../codegen/common/Card';
import { IPhase } from './../codegen/common/Phase'; import { IPhase } from './../codegen/common/Phase';
import { IResponse } from './../codegen/common/Response'; import { IResponse } from './../codegen/common/Response';
import { IPlayer } from './../codegen/common/Player'; import { TPlayer } from './../codegen/common/TPlayer';
import { IJoinRequest} from 'src/codegen/common'; import { IJoinRequest} from 'src/codegen/common';
import { Player } from 'src/codegen/common/Player'; // import { IITPlayer } from 'src/codegen/common/TITPlayer';
/** /**
* Game interface. * Game interface.
...@@ -14,10 +14,10 @@ export interface GameInterface { ...@@ -14,10 +14,10 @@ export interface GameInterface {
/** /**
* Create new game. * Create new game.
* @param creator Player * @param creator ITPlayer
* @param numberOfPlayers number of player * @param numberOfITPlayers number of ITplayer
*/ */
createGame(creator: Player, numberOfPlayers: number): Promise<number>; createGame(creator: TPlayer, numberOfITPlayers: number): Promise<number>;
/** /**
* Join an existing game. * Join an existing game.
...@@ -33,17 +33,17 @@ export interface GameInterface { ...@@ -33,17 +33,17 @@ export interface GameInterface {
/** /**
* Play a tracking card. * Play a tracking card.
* @param creature Creature player * @param creature Creature ITplayer
* @param card Card to play * @param card Card to play
*/ */
playHuntCard(creature: IPlayer, card: ICard): Promise<IResponse>; playHuntCard(creature: TPlayer, card: ICard): Promise<IResponse>;
/** /**
* Play a place card. * Play a place card.
* @param hunted Tracked player * @param hunted Tracked ITplayer
* @param card Place card * @param card Place card
*/ */
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse>; playPlaceCard(hunted: TPlayer, card: ICard): Promise<IResponse>;
/** /**
* Put token on a place card. * Put token on a place card.
...@@ -54,13 +54,13 @@ export interface GameInterface { ...@@ -54,13 +54,13 @@ export interface GameInterface {
/** /**
* Resists action. * Resists action.
* @param hunted Tracked player * @param hunted Tracked ITplayer
*/ */
resits(hunted: IPlayer): Promise<IResponse>; resits(hunted: TPlayer): Promise<IResponse>;
/** /**
* Let go * Let go
* @param hunted Tracked player * @param hunted Tracked ITplayer
*/ */
toGo(hunted: IPlayer): Promise<IResponse>; letGo(hunted: TPlayer): Promise<IResponse>;
} }
import { ICard, IJoinRequest, IPhase, IPhaseArgs, IPlace, IPlayer, IResponseArgs, IToken, Player } from 'src/codegen/common'; import { ICard, IJoinRequest, IPhase, IPhaseArgs, IPlace, ITPlayer, IResponseArgs, IToken, TPlayer} from 'src/codegen/common';
import { IHandler } from '../codegen/common/GameService'; import { IHandler } from '../codegen/common/GameService';
import { PlayerService } from '../player/player-service'; import { PlayerService } from '../player/player-service';
...@@ -7,10 +7,10 @@ export class ClientServiceHandler<Context> implements IHandler<Context> { ...@@ -7,10 +7,10 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
private service: PlayerService; private service: PlayerService;
constructor() { constructor() {
this.service = new PlayerService(new Player()); this.service = new PlayerService(new TPlayer());
} }
createGame(creator: IPlayer, numberOfPlayers: number, context?: Context): number | Promise<number> { createGame(creator: TPlayer, numberOfPlayers: number, context?: Context): number | Promise<number> {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
join(request: IJoinRequest, context?: Context): number | Promise<number> { join(request: IJoinRequest, context?: Context): number | Promise<number> {
...@@ -41,7 +41,7 @@ export class ClientServiceHandler<Context> implements IHandler<Context> { ...@@ -41,7 +41,7 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
toGo(hunted: any, context?: Context): IResponseArgs | Promise<IResponseArgs> { letGo(hunted: any, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
......
import { Player } from 'src/codegen/common/Player'; import { TPlayer } from 'src/codegen/common/TPlayer';
import { Winner } from './../codegen/common/Winner'; import { Winner } from './../codegen/common/Winner';
import { BoardGameState } from './../codegen/common/BoardGameState'; import { BoardGameState } from './../codegen/common/BoardGameState';
import { PlayerStateResponse } from './../codegen/common/PlayerStateResponse'; import { PlayerStateResponse } from './../codegen/common/PlayerStateResponse';
import { PlayerState } from 'src/codegen/common'; import { PlayerState } from 'src/codegen/common';
export class PlayerService { export class PlayerService {
private player: Player; private player: TPlayer;
/** /**
* Create new player service. * Create new player service.
* @param player Player * @param player Player
*/ */
constructor(player: Player) { constructor(player: TPlayer) {
this.player = player; this.player = player;
} }
/** /**
* Return the associed player to the service. * Return the associed player to the service.
*/ */
public getPlayer(): Player { public getPlayer(): TPlayer {
return this.player; return this.player;
} }
startGame(gameId: number): void { startGame(gameId: number): void {
console.log('Start game', gameId); console.log('Start game', gameId);
} }
...@@ -30,31 +30,31 @@ export class PlayerService { ...@@ -30,31 +30,31 @@ export class PlayerService {
* Blocked all actions of the player. * Blocked all actions of the player.
*/ */
blockActions(): PlayerStateResponse { blockActions(): PlayerStateResponse {
this.player.state = PlayerState.BLOCKED this.player.state = PlayerState.BLOCKED;
return this.builPlayerStateMessage("Player blocked successfully !"); return this.builPlayerStateMessage('Player blocked successfully !');
} }
/** /**
* Unblock all actions of the player. * Unblock all actions of the player.
*/ */
unblockActions(): PlayerStateResponse { unblockActions(): PlayerStateResponse {
this.player.state = PlayerState.UNBLOCKED this.player.state = PlayerState.UNBLOCKED;
return this.builPlayerStateMessage("Player blocked successfully !"); return this.builPlayerStateMessage('Player blocked successfully !');
} }
showPlayedCard() : void { showPlayedCard(): void {
} }
updatedGameBoard(bordGameState: BoardGameState): string { updatedGameBoard(bordGameState: BoardGameState): string {
return '';
} }
endGame(winner: Winner): string { endGame(winner: Winner): string {
return '';
} }
/** /**
...@@ -62,7 +62,7 @@ export class PlayerService { ...@@ -62,7 +62,7 @@ export class PlayerService {
* @param message message text * @param message message text
*/ */
private builPlayerStateMessage(message: string): PlayerStateResponse { private builPlayerStateMessage(message: string): PlayerStateResponse {
let response:PlayerStateResponse = new PlayerStateResponse(); const response: PlayerStateResponse = new PlayerStateResponse();
response.state = this.player.state; response.state = this.player.state;
response.message = message; response.message = message;
......
...@@ -3,7 +3,7 @@ import { GameInterface } from '../core/game'; ...@@ -3,7 +3,7 @@ import { GameInterface } from '../core/game';
import { CoreOptions } from 'request'; import { CoreOptions } from 'request';
import { createHttpClient, ICreateHttpClientOptions } from '@creditkarma/thrift-client'; import { createHttpClient, ICreateHttpClientOptions } from '@creditkarma/thrift-client';
import { JoinRequest } from '../codegen/common/JoinRequest'; import { JoinRequest } from '../codegen/common/JoinRequest';
import { IPlayer, Player } from 'src/codegen/common/Player'; import { ITPlayer, TPlayer } from 'src/codegen/common/TPlayer';
import { IPhase, ICard, IResponse, IToken, IPlace } from 'src/codegen/common'; import { IPhase, ICard, IResponse, IToken, IPlace } from 'src/codegen/common';
export class GameProxy implements GameInterface { export class GameProxy implements GameInterface {
...@@ -13,7 +13,7 @@ export class GameProxy implements GameInterface { ...@@ -13,7 +13,7 @@ export class GameProxy implements GameInterface {
this.thriftClient = createHttpClient(Client, options); this.thriftClient = createHttpClient(Client, options);
} }
createGame(creator: Player, numberOfPlayers: number): Promise<number> { createGame(creator: TPlayer, numberOfPlayers: number): Promise<number> {
return this.thriftClient.createGame(creator, numberOfPlayers); return this.thriftClient.createGame(creator, numberOfPlayers);
} }
...@@ -25,11 +25,11 @@ export class GameProxy implements GameInterface { ...@@ -25,11 +25,11 @@ export class GameProxy implements GameInterface {
return this.thriftClient.nextPhase(phase); return this.thriftClient.nextPhase(phase);
} }
playHuntCard(creature: IPlayer, card: ICard): Promise<IResponse> { playHuntCard(creature: TPlayer, card: ICard): Promise<IResponse> {
return this.thriftClient.playHuntCard(creature, card); return this.thriftClient.playHuntCard(creature, card);
} }
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse> { playPlaceCard(hunted: TPlayer, card: ICard): Promise<IResponse> {
return this.thriftClient.playPlaceCard(hunted, card); return this.thriftClient.playPlaceCard(hunted, card);
} }
...@@ -37,11 +37,11 @@ export class GameProxy implements GameInterface { ...@@ -37,11 +37,11 @@ export class GameProxy implements GameInterface {
return this.thriftClient.putToken(token, place); return this.thriftClient.putToken(token, place);
} }
resits(hunted: IPlayer): Promise<IResponse> { resits(hunted: TPlayer): Promise<IResponse> {
return this.thriftClient.resits(hunted); return this.thriftClient.resits(hunted);
} }
toGo(hunted: IPlayer): Promise<IResponse> { letGo(hunted: TPlayer): Promise<IResponse> {
return this.thriftClient.toGo(hunted); return this.thriftClient.letGo(hunted);
} }
} }
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment