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';
import { ICard } from './../codegen/common/Card';
import { IPhase } from './../codegen/common/Phase';
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 { Player } from 'src/codegen/common/Player';
// import { IITPlayer } from 'src/codegen/common/TITPlayer';
/**
* Game interface.
......@@ -14,10 +14,10 @@ export interface GameInterface {
/**
* Create new game.
* @param creator Player
* @param numberOfPlayers number of player
* @param creator ITPlayer
* @param numberOfITPlayers number of ITplayer
*/
createGame(creator: Player, numberOfPlayers: number): Promise<number>;
createGame(creator: TPlayer, numberOfITPlayers: number): Promise<number>;
/**
* Join an existing game.
......@@ -33,17 +33,17 @@ export interface GameInterface {
/**
* Play a tracking card.
* @param creature Creature player
* @param creature Creature ITplayer
* @param card Card to play
*/
playHuntCard(creature: IPlayer, card: ICard): Promise<IResponse>;
playHuntCard(creature: TPlayer, card: ICard): Promise<IResponse>;
/**
* Play a place card.
* @param hunted Tracked player
* @param hunted Tracked ITplayer
* @param card Place card
*/
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse>;
playPlaceCard(hunted: TPlayer, card: ICard): Promise<IResponse>;
/**
* Put token on a place card.
......@@ -54,13 +54,13 @@ export interface GameInterface {
/**
* Resists action.
* @param hunted Tracked player
* @param hunted Tracked ITplayer
*/
resits(hunted: IPlayer): Promise<IResponse>;
resits(hunted: TPlayer): Promise<IResponse>;
/**
* 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 { PlayerService } from '../player/player-service';
......@@ -7,10 +7,10 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
private service: PlayerService;
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.');
}
join(request: IJoinRequest, context?: Context): number | Promise<number> {
......@@ -41,7 +41,7 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
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.');
}
......
import { Player } from 'src/codegen/common/Player';
import { TPlayer } from 'src/codegen/common/TPlayer';
import { Winner } from './../codegen/common/Winner';
import { BoardGameState } from './../codegen/common/BoardGameState';
import { PlayerStateResponse } from './../codegen/common/PlayerStateResponse';
import { PlayerState } from 'src/codegen/common';
export class PlayerService {
private player: Player;
private player: TPlayer;
/**
* Create new player service.
* @param player Player
*/
constructor(player: Player) {
constructor(player: TPlayer) {
this.player = player;
}
/**
* Return the associed player to the service.
*/
public getPlayer(): Player {
public getPlayer(): TPlayer {
return this.player;
}
......@@ -30,31 +30,31 @@ export class PlayerService {
* Blocked all actions of the player.
*/
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.
*/
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 {
return '';
}
endGame(winner: Winner): string {
return '';
}
/**
......@@ -62,7 +62,7 @@ export class PlayerService {
* @param message message text
*/
private builPlayerStateMessage(message: string): PlayerStateResponse {
let response:PlayerStateResponse = new PlayerStateResponse();
const response: PlayerStateResponse = new PlayerStateResponse();
response.state = this.player.state;
response.message = message;
......
......@@ -3,7 +3,7 @@ import { GameInterface } from '../core/game';
import { CoreOptions } from 'request';
import { createHttpClient, ICreateHttpClientOptions } from '@creditkarma/thrift-client';
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';
export class GameProxy implements GameInterface {
......@@ -13,7 +13,7 @@ export class GameProxy implements GameInterface {
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);
}
......@@ -25,11 +25,11 @@ export class GameProxy implements GameInterface {
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);
}
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse> {
playPlaceCard(hunted: TPlayer, card: ICard): Promise<IResponse> {
return this.thriftClient.playPlaceCard(hunted, card);
}
......@@ -37,11 +37,11 @@ export class GameProxy implements GameInterface {
return this.thriftClient.putToken(token, place);
}
resits(hunted: IPlayer): Promise<IResponse> {
resits(hunted: TPlayer): Promise<IResponse> {
return this.thriftClient.resits(hunted);
}
toGo(hunted: IPlayer): Promise<IResponse> {
return this.thriftClient.toGo(hunted);
letGo(hunted: TPlayer): Promise<IResponse> {
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