Commit 477de5b4 authored by Alex MOULIN's avatar Alex MOULIN
Browse files
parents 60a68e36 176d14fa
......@@ -42,3 +42,7 @@ testem.log
# System Files
.DS_Store
Thumbs.db
#package-lock.json
/not-alone-web/package-lock.json
/not-alone-player/package-lock.json
\ No newline at end of file
#Fri Dec 04 16:20:07 CET 2020
gradle.version=6.7
......@@ -10,12 +10,44 @@ exception GameNotFound {
1: i32 code,
2: string description
}
struct Winner {
1: Player winner,
2: string message
}
struct TrackingKard {
1: i32 phase,
2: string name,
3: bool visible
}
struct PlaceCard {
1: i32 number,
2: string name,
3: bool visible
}
enum PlayerState {
UNBLOCKED = 0,
BLOCKED
}
enum PlayerRole {
TRACKED = 0,
CREATURE
}
struct PlayerStateResponse {
1: PlayerState state,
2: string message
}
struct Player{
1: i32 id
2: string name
3: string ip
4: string port
5: PlayerState state,
6: PlayerRole role,
7: optional list<TrackingKard> huntCards,
8: optional list<PlaceCard> placeCards,
}
......
......@@ -3,51 +3,19 @@ include "common.thrift"
namespace java fr.univnantes.alma.thrift
namespace js common
enum PlayerState {
UNBLOCKED = 0,
BLOCKED
}
struct PlayerStateResponse {
1: PlayerState state,
2: string message
}
struct GamePlayer {
1: i32 id,
2: string name,
3: PlayerState state,
4: optional list<HuntCard> huntCards,
5: optional list<PlaceCard> placeCards,
}
struct Winner {
1: GamePlayer winner,
2: string message
}
struct HuntCard {
1: i32 phase,
2: string name,
3: bool visible
}
struct PlaceCard {
1: i32 number,
2: string name,
3: bool visible
}
struct BoardGameState {
1: i32 assimilationTokenPosition,
2: i32 rescuePawnPosition,
3: optional bool isBoardFacing,
4: list<GamePlayer> players
4: list<common.Player> players
}
service PlayerService {
bool ping() throws (1:common.InvalidOperationException e)
string startGame(i32 gameId)
PlayerStateResponse blockActions()
PlayerStateResponse unblockActions()
common.PlayerStateResponse blockActions()
common.PlayerStateResponse unblockActions()
void showPlayedCard()
string updatedGameBoard(BoardGameState bordGameState)
string endGame(Winner winner);
string endGame(common.Winner winner);
}
This diff is collapsed.
......@@ -21,7 +21,9 @@
"dependencies": {
"@creditkarma/thrift-client": "^0.16.1",
"@creditkarma/thrift-server-core": "^0.16.1",
"@creditkarma/thrift-server-express": "^0.16.1"
"@creditkarma/thrift-server-express": "^0.16.1",
"@types/express": "^4.17.9",
"express": "^4.17.1"
},
"browser": {
"crypto": false,
......
import { IPlace } from './../codegen/common/Place';
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 { IJoinRequest} from 'src/codegen/common';
import { Player } from 'src/codegen/common/Player';
/**
* Game interface.
*/
export interface GameInterface {
createGame(numberOfPlayers: number): Promise<number>;
join(gameId: number): Promise<number>;
/**
* Create new game.
* @param creator Player
* @param numberOfPlayers number of player
*/
createGame(creator: Player, numberOfPlayers: number): Promise<number>;
/**
* Join an existing game.
* @param request JoinRequest
*/
join(request: IJoinRequest): Promise<number>;
/**
* Next phase.
* @param phase Phase of game
*/
nextPhase(phase: IPhase): Promise<IPhase>;
/**
* Play a tracking card.
* @param creature Creature player
* @param card Card to play
*/
playHuntCard(creature: IPlayer, card: ICard): Promise<IResponse>;
/**
* Play a place card.
* @param hunted Tracked player
* @param card Place card
*/
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse>;
/**
* Put token on a place card.
* @param token Token to put
* @param place Card where to put the token
*/
putToken(token: IToken, place: IPlace): Promise<IResponse>;
/**
* Resists action.
* @param hunted Tracked player
*/
resits(hunted: IPlayer): Promise<IResponse>;
/**
* Let go
* @param hunted Tracked player
*/
toGo(hunted: IPlayer): Promise<IResponse>;
}
import { IJoinRequest } from 'src/codegen/common';
import { ICard, IJoinRequest, IPhase, IPhaseArgs, IPlace, IPlayer, IResponseArgs, IToken } from 'src/codegen/common';
import { IHandler } from '../codegen/common/GameService';
import { PlayerService } from '../player/player-service';
......@@ -10,17 +10,52 @@ export class ClientServiceHandler<Context> implements IHandler<Context> {
this.service = new PlayerService();
}
public createGame(numberOfPlayers: number, context?: Context): number | Promise<number> {
createGame(creator: IPlayer, numberOfPlayers: number, context?: Context): number | Promise<number> {
throw new Error('Method not implemented.');
}
join(request: IJoinRequest, context?: Context): number | Promise<number> {
throw new Error('Method not implemented.');
}
public join(gameId: number, request: IJoinRequest, context?: Context): number | Promise<number> {
/*public createGame(numberOfPlayers: number, context?: Context): number | Promise<number> {
throw new Error('Method not implemented.');
}
public join(gameId: number, request: IJoinRequest, context?: Context): number | Promise<number> {
throw new Error('Method not implemented.');
}*/
public startGame(gameId: number): void | Promise<void> {
return this.service.startGame(gameId);
}
isConnected(player: any, params: any, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
nextPhase(phase: IPhase, context?: Context): IPhaseArgs | Promise<IPhaseArgs> {
throw new Error('Method not implemented.');
}
resits(hunted: any, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
toGo(hunted: any, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
playPlaceCard(hunted: any, card: ICard, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
putToken(token: IToken, place: IPlace, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
playHuntCard(creature: any, card: ICard, context?: Context): IResponseArgs | Promise<IResponseArgs> {
throw new Error('Method not implemented.');
}
}
......@@ -2,7 +2,9 @@ import { Client } from 'src/codegen/common/GameService';
import { GameInterface } from '../core/game';
import { CoreOptions } from 'request';
import { createHttpClient, ICreateHttpClientOptions } from '@creditkarma/thrift-client';
import { IJoinRequest, JoinRequest } from '../codegen/common/JoinRequest';
import { JoinRequest } from '../codegen/common/JoinRequest';
import { IPlayer, Player } from 'src/codegen/common/Player';
import { IPhase, ICard, IResponse, IToken, IPlace } from 'src/codegen/common';
export class GameProxy implements GameInterface {
private thriftClient: Client<CoreOptions>;
......@@ -11,13 +13,35 @@ export class GameProxy implements GameInterface {
this.thriftClient = createHttpClient(Client, options);
}
createGame(numberOfPlayers: number): Promise<number> {
return this.thriftClient.createGame(numberOfPlayers);
createGame(creator: Player, numberOfPlayers: number): Promise<number> {
return this.thriftClient.createGame(creator, numberOfPlayers);
}
join(gameId: number): Promise<number> {
const request: IJoinRequest = new JoinRequest();
request.name = 'me';
return this.thriftClient.join(gameId, request);
join(request: JoinRequest): Promise<number> {
return this.thriftClient.join(request);
}
nextPhase(phase: IPhase): Promise<IPhase> {
return this.thriftClient.nextPhase(phase);
}
playHuntCard(creature: IPlayer, card: ICard): Promise<IResponse> {
return this.thriftClient.playHuntCard(creature, card);
}
playPlaceCard(hunted: IPlayer, card: ICard): Promise<IResponse> {
return this.thriftClient.playPlaceCard(hunted, card);
}
putToken(token: IToken, place: IPlace): Promise<IResponse> {
return this.thriftClient.putToken(token, place);
}
resits(hunted: IPlayer): Promise<IResponse> {
return this.thriftClient.resits(hunted);
}
toGo(hunted: IPlayer): Promise<IResponse> {
return this.thriftClient.toGo(hunted);
}
}
......@@ -11,6 +11,6 @@ const CONFIG = {
const thriftClient: Client<CoreOptions> = createHttpClient(Client, CONFIG);
const id: Promise<Number> = thriftClient.createGame(8);
// const id: Promise<Number> = thriftClient.createGame(8);
export class ThriftClient {}
package fr.univnantes.alma.model.card.player.survival;
import fr.univnantes.alma.model.BoardGame;
public class AdrenalineCard extends BasicSurvivalCard {
/**
* Phase of game.
*/
private static final String PHASE = "Phase 1";
/**
* Card name.
*/
private static final String CARD_NAME = "Adrénaline";
/**
* Create new instance of adrenaline card.
*/
public AdrenalineCard() {
super(PHASE, CARD_NAME);
}
/**
* {@inheritdoc}
*/
@Override
public void applyEffect(final BoardGame boardGame) {
}
}
package fr.univnantes.alma.model.card.player.survival;
import fr.univnantes.alma.model.BoardGame;
public class AlertCard extends BasicSurvivalCard{
/**
* Phase of game.
*/
private static final String PHASE = "Phase 3";
/**
* Card name.
*/
private static final String CARD_NAME = "Alerte";
/**
* Create new instance of alert card.
*/
public AlertCard() {
super(PHASE, CARD_NAME);
}
/**
* {@inheritdoc}
*/
@Override
public void applyEffect(final BoardGame boardGame) {
}
}
package fr.univnantes.alma.model.card.player.survival;
import fr.univnantes.alma.model.BoardGame;
public class AmplifierCard extends BasicSurvivalCard {
/**
* Phase of game.
*/
private static final String PHASE = "Phase 4";
/**
* Card name.
*/
private static final String CARD_NAME = "Amplificateur";
/**
* Create new instance of amplifier card.
*/
public AmplifierCard() {
super(PHASE, CARD_NAME);
}
/**
* {@inheritdoc}
*/
@Override
public void applyEffect(final BoardGame boardGame) {
}
}
\ No newline at end of file
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