Commit ecf85a4e authored by Joseph NISON--GUYON's avatar Joseph NISON--GUYON
Browse files

Ajout de la pioche de la réserve

parent 197a2424
......@@ -37,4 +37,6 @@ service GameService {
string piocherSurvie(i32 idGame, i32 id)
bool piocherReserve(i32 idGame, i32 lieu)
}
......@@ -37,4 +37,6 @@ service PlayerService {
void piocherSurvie(i32 gameId)
void piocherReserve(i32 gameId, i32 lieu)
}
......@@ -93,4 +93,8 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
public piocherSurvie (idGame: number, id: number): string {
return '';
}
public piocherReserve(idGame: number, lieu: number): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {});
}
}
......@@ -24,6 +24,7 @@ export class PlayerService implements IHandler<any> {
lacherPrise(gameId: number): void {}
resister(gameId: number, cartes: Array<number>): void {}
piocherSurvie(gameId: number): void {}
piocherReserve(gameId: number, lieu: number): void {}
// methodes de la créature
troisCartes(gameId: number): void {}
......
......@@ -4,12 +4,15 @@ import { Lieu } from '../lieu/lieu';
export class Traque {
private main: Array<Lieu>;
private mainSurvie: Array<CarteSurvie>;
private reserve: Array<Lieu>;
private defausse: Array<Lieu>;
private gameProxy: GameProxy;
private volonte: number;
constructor(gameProxy: GameProxy) {
this.main = [{id: 1, name: 'L\'Antre'}, {id: 2, name: 'Jungle'}, {id: 3, name: 'La Rivière'}, {id: 4, name: 'La Plage'}];
this.main.concat({id: 5, name: 'Le Rover'});
this.reserve = [{id: 6, name: 'Marais'}, {id: 7, name: 'L\'Abris'}, {id: 8, name: 'L\'Epave'}, {id: 9, name: 'La Source'}];
this.reserve.concat({id: 10, name: 'Artefact'});
this.defausse = [];
this.gameProxy = gameProxy;
this.volonte = 3;
......@@ -80,4 +83,17 @@ export class Traque {
const carte = await this.gameProxy.piocherSurvie(gameId, id);
this.mainSurvie.push(carte);
}
public async piocherReserve(gameId: number, lieu: Lieu): Promise<void> {
if (await this.gameProxy.piocherReserve(gameId, lieu)) {
let param = 0;
while (param < this.reserve.length) {
if (lieu.id === this.reserve[param]) {
this.main.push(this.reserve[param]);
this.reserve.splice(param, 1);
}
param++;
}
}
}
}
......@@ -121,4 +121,12 @@ export class GameProxy implements GameInterface {
this.thriftClient.setCarteTraque(gameId, carte.name);
}
}
public piocherReserve(gameId: number, lieu: Lieu): Promise<boolean> {
if (lieu.id == null) {
return this.thriftClient.piocherReserve(gameId, 0);
} else {
return this.thriftClient.piocherReserve(gameId, lieu.id);
}
}
}
......@@ -96,4 +96,9 @@ public class GameServiceHandler implements GameService.Iface {
public String piocherSurvie(int idGame, int id) {
return this.service.piocherSurvie(idGame, id);
}
@Override
public boolean piocherReserve(int idGame, int id) {
return this.service.piocherReserve(idGame, builder.buildCarteLieu(id));
}
}
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