Commit 85473dd0 authored by Mamadou Saliou DIALLO's avatar Mamadou Saliou DIALLO
Browse files

start of player-service implementation

parent 176d14fa
import { ICard, IJoinRequest, IPhase, IPhaseArgs, IPlace, IPlayer, IResponseArgs, IToken } from 'src/codegen/common';
import { ICard, IJoinRequest, IPhase, IPhaseArgs, IPlace, IPlayer, IResponseArgs, IToken, Player } from 'src/codegen/common';
import { IHandler } from '../codegen/common/GameService';
import { PlayerService } from '../player/player-service';
......@@ -7,7 +7,7 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
private service: PlayerService;
constructor() {
this.service = new PlayerService();
this.service = new PlayerService(new Player());
}
createGame(creator: IPlayer, numberOfPlayers: number, context?: Context): number | Promise<number> {
......
import { Player } from 'src/codegen/common/Player';
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 {
startGame(gameId: number): void {
console.log('Start game', gameId);
}
private player: Player;
/**
* Create new player service.
* @param player Player
*/
constructor(player: Player) {
this.player = player;
}
/**
* Return the associed player to the service.
*/
public getPlayer(): Player {
return this.player;
}
startGame(gameId: number): void {
console.log('Start game', gameId);
}
/**
* Blocked all actions of the player.
*/
blockActions(): PlayerStateResponse {
this.player.state = PlayerState.BLOCKED
return this.builPlayerStateMessage("Player blocked successfully !");
}
/**
* Unblock all actions of the player.
*/
unblockActions(): PlayerStateResponse {
this.player.state = PlayerState.UNBLOCKED
return this.builPlayerStateMessage("Player blocked successfully !");
}
showPlayedCard() : void {
}
updatedGameBoard(bordGameState: BoardGameState): string {
}
endGame(winner: Winner): string {
}
/**
* Create new instance of PlayerStateResponse.
* @param message message text
*/
private builPlayerStateMessage(message: string): PlayerStateResponse {
let response:PlayerStateResponse = new PlayerStateResponse();
response.state = this.player.state;
response.message = message;
return response;
}
}
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