summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/src/api/model.js77
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt17
2 files changed, 82 insertions, 12 deletions
diff --git a/frontend/src/api/model.js b/frontend/src/api/model.js
index 54be5cf8..011b59ec 100644
--- a/frontend/src/api/model.js
+++ b/frontend/src/api/model.js
@@ -42,34 +42,75 @@ export type ApiPlayer = {
};
export type ApiTable = {
+ boards: ApiBoard[],
+ currentAge: number,
+ handRotationDirection: HandRotationDirection,
+ lastPlayedMoves: ApiPlayedMove[],
+ nbPlayers: number,
+};
+export type ApiBoard = {
+ playerIndex: number,
+ wonder: ApiWonder,
+ production: ApiProduction,
+ publicProduction: ApiProduction,
+ science: ApiScience,
+ military: ApiMilitary,
+ playedCards: ApiTableCard[],
+ gold: number,
};
-export type ApiAction = {};
+export type ApiWonder = {
+ name: string,
+ initialResource: ApiResourceType,
+ stages: ApiWonderStage[],
+ image: string,
+ nbBuiltStages: Int,
+ buildability: ApiWonderBuildability,
+}
+
+export type ApiWonderStage = {
+ cardBack: ApiCardBack | null,
+ isBuilt: boolean,
+ requirements: ApiRequirements,
+ builtDuringLastMove: boolean,
+}
+
+export type HandRotationDirection = 'LEFT' | 'RIGHT';
+
+export type ApiAction = 'PLAY' | 'PLAY_2' | 'PLAY_LAST' | 'PICK_NEIGHBOR_GUILD' | 'WAIT';
export type ApiCard = {
name: string,
- image: string
+ color: Color,
+ requirements: ApiRequirements,
+ chainParent: String | null,
+ chainChildren: String[],
+ image: string,
+ back: ApiCardBack
};
export type ApiHandCard = ApiCard & {
- playability: ApiPlayability
+ playability: ApiPlayability,
};
export type ApiPlayability = {
- playable: boolean
+ playable: boolean,
+ chainable: boolean,
+ minPrice: number,
};
export type ApiTableCard = ApiCard & {
+ playedDuringLastMove: boolean,
};
export type ApiCardBack = {
- image: string
+ image: string,
};
export type ApiPreparedCard = {
player: ApiPlayer,
- cardBack: ApiCardBack
+ cardBack: ApiCardBack,
};
export type ApiPlayerTurnInfo = {
@@ -91,16 +132,34 @@ export type ApiMoveType = "PLAY" | "PLAY_FREE" | "UPGRADE_WONDER" | "DISCARD" |
export type ApiProvider = "LEFT_NEIGHBOUR" | "RIGHT_NEIGHBOUR";
export type ApiResourceType = "WOOD" | "STONE" | "ORE" | "CLAY" | "GLASS" | "PAPYRUS" | "LOOM";
+export type ApiProduction = {
+ fixedResources: ApiCountedResource[],
+ alternativeResources: ApiResourceType[][],
+}
+
+export type ApiCountedResource = {
+ type: ApiResourceType,
+ count: number,
+}
+
export type ApiResources = {
- quantities: Map<ApiResourceType, number>
+ quantities: Map<ApiResourceType, number>,
};
+
export type ApiBoughtResources = {
provider: ApiProvider,
- resources: ApiResources
+ resources: ApiResources,
};
export type ApiPlayerMove = {
type: ApiMoveType,
cardName: string,
- boughtResources: ApiBoughtResources[]
+ boughtResources: ApiBoughtResources[],
+};
+
+export type ApiPlayedMove = {
+ playerIndex: number,
+ type: ApiMoveType,
+ card: ApiTableCard,
+ boughtResources: ApiBoughtResources[],
};
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt
index 8bc87b55..da0f390f 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt
@@ -75,11 +75,22 @@ internal fun InternalWonderStage.toApiWonderStage(
)
data class ApiProduction(
- val fixedResources: Resources,
- val aternativeResources: Set<Set<ResourceType>>
+ val fixedResources: List<ApiCountedResource>,
+ val alternativeResources: Set<Set<ResourceType>>
)
-internal fun Production.toApiProduction(): ApiProduction = ApiProduction(getFixedResources(), getAlternativeResources())
+internal fun Production.toApiProduction(): ApiProduction = ApiProduction(
+ fixedResources = getFixedResources().toCountedResourcesList(),
+ alternativeResources = getAlternativeResources()
+)
+
+data class ApiCountedResource(
+ val count: Int,
+ val type: ResourceType
+)
+
+internal fun Resources.toCountedResourcesList(): List<ApiCountedResource> =
+ quantities.map { (type, count) -> ApiCountedResource(count, type)}.sortedBy { it.type }
data class ApiMilitary(
var nbShields: Int,
bgstack15