diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2019-03-05 01:47:45 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2019-03-05 02:12:32 +0100 |
commit | 5391dfa02d9d4ea7938fe0c036570df33b3f56bc (patch) | |
tree | 331789bd17da09e49a86b88df1a6af6ec3eee17a /frontend/src | |
parent | Fix types in model.js (diff) | |
download | seven-wonders-5391dfa02d9d4ea7938fe0c036570df33b3f56bc.tar.gz seven-wonders-5391dfa02d9d4ea7938fe0c036570df33b3f56bc.tar.bz2 seven-wonders-5391dfa02d9d4ea7938fe0c036570df33b3f56bc.zip |
Fix type declaration order in model.js
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/api/model.js | 170 |
1 files changed, 86 insertions, 84 deletions
diff --git a/frontend/src/api/model.js b/frontend/src/api/model.js index 422b7d6d..aca4b054 100644 --- a/frontend/src/api/model.js +++ b/frontend/src/api/model.js @@ -1,14 +1,12 @@ // @flow -export type ApiError = { - message: string, - details: ApiErrorDetail[] -}; - export type ApiErrorDetail = { message: string }; -export type ApiGameState = "LOBBY" | "PLAYING"; +export type ApiError = { + message: string, + details: ApiErrorDetail[] +}; export type ApiPlayer = { username: string, @@ -18,15 +16,6 @@ export type ApiPlayer = { user: Boolean, }; -export type ApiLobby = { - id: number, - name: string, - owner: string, - players: ApiPlayer[], - settings: ApiSettings, - state: ApiGameState -}; - export type ApiWonderSidePickMethod = "EACH_RANDOM" | "ALL_A" | "ALL_B" | "SAME_RANDOM_FOR_ALL"; export type ApiSettings = { @@ -41,12 +30,15 @@ export type ApiSettings = { wonPointsPerVictoryPerAge: Map<number, number> }; -export type ApiTable = { - boards: ApiBoard[], - currentAge: number, - handRotationDirection: HandRotationDirection, - lastPlayedMoves: ApiPlayedMove[], - nbPlayers: number, +export type ApiGameState = "LOBBY" | "PLAYING"; + +export type ApiLobby = { + id: number, + name: string, + owner: string, + players: ApiPlayer[], + settings: ApiSettings, + state: ApiGameState }; export type ApiScience = { @@ -62,26 +54,21 @@ export type ApiMilitary = { nbDefeatTokens: number, } -export type ApiBoard = { - playerIndex: number, - wonder: ApiWonder, - production: ApiProduction, - publicProduction: ApiProduction, - science: ApiScience, - military: ApiMilitary, - playedCards: ApiTableCard[][], - gold: number, +export type ApiResourceType = "WOOD" | "STONE" | "ORE" | "CLAY" | "GLASS" | "PAPYRUS" | "LOOM"; + +export type ApiResources = { + quantities: Map<ApiResourceType, number>, }; -export type ApiWonder = { - name: string, - initialResource: ApiResourceType, - stages: ApiWonderStage[], - image: string, - nbBuiltStages: number, - buildability: ApiWonderBuildability, +export type ApiRequirements = { + gold: number, + resources: ApiResources } +export type ApiCardBack = { + image: string, +}; + export type ApiWonderStage = { cardBack: ApiCardBack | null, isBuilt: boolean, @@ -89,17 +76,38 @@ export type ApiWonderStage = { builtDuringLastMove: boolean, } -export type HandRotationDirection = 'LEFT' | 'RIGHT'; +export type ApiWonderBuildability = { + buildable: boolean +} -export type ApiAction = 'PLAY' | 'PLAY_2' | 'PLAY_LAST' | 'PICK_NEIGHBOR_GUILD' | 'WAIT'; +export type ApiWonder = { + name: string, + initialResource: ApiResourceType, + stages: ApiWonderStage[], + image: string, + nbBuiltStages: number, + buildability: ApiWonderBuildability, +} export type Color = 'BLUE' | 'GREEN' | 'RED' | 'BROWN' | 'GREY' | 'PURPLE' | 'YELLOW'; -export type ApiRequirements = { - gold: number, - resources: ApiResources +export type ApiProvider = "LEFT_NEIGHBOUR" | "RIGHT_NEIGHBOUR"; + +export type ApiCountedResource = { + type: ApiResourceType, + count: number, +} + +export type ApiProduction = { + fixedResources: ApiCountedResource[], + alternativeResources: ApiResourceType[][], } +export type ApiBoughtResources = { + provider: ApiProvider, + resources: ApiResources, +}; + export type ApiCard = { name: string, color: Color, @@ -110,22 +118,50 @@ export type ApiCard = { back: ApiCardBack }; -export type ApiHandCard = ApiCard & { - playability: ApiPlayability, +export type ApiTableCard = ApiCard & { + playedDuringLastMove: boolean, +}; + +export type ApiBoard = { + playerIndex: number, + wonder: ApiWonder, + production: ApiProduction, + publicProduction: ApiProduction, + science: ApiScience, + military: ApiMilitary, + playedCards: ApiTableCard[][], + gold: number, }; +export type HandRotationDirection = 'LEFT' | 'RIGHT'; + +export type ApiMoveType = "PLAY" | "PLAY_FREE" | "UPGRADE_WONDER" | "DISCARD" | "COPY_GUILD"; + +export type ApiPlayedMove = { + playerIndex: number, + type: ApiMoveType, + card: ApiTableCard, + boughtResources: ApiBoughtResources[], +}; + +export type ApiTable = { + boards: ApiBoard[], + currentAge: number, + handRotationDirection: HandRotationDirection, + lastPlayedMoves: ApiPlayedMove[], + nbPlayers: number, +}; + +export type ApiAction = 'PLAY' | 'PLAY_2' | 'PLAY_LAST' | 'PICK_NEIGHBOR_GUILD' | 'WAIT'; + export type ApiPlayability = { playable: boolean, chainable: boolean, minPrice: number, }; -export type ApiTableCard = ApiCard & { - playedDuringLastMove: boolean, -}; - -export type ApiCardBack = { - image: string, +export type ApiHandCard = ApiCard & { + playability: ApiPlayability, }; export type ApiPreparedCard = { @@ -145,42 +181,8 @@ export type ApiPlayerTurnInfo = { wonderBuildability: ApiWonderBuildability, }; -export type ApiWonderBuildability = { - buildable: boolean -} - -export type ApiMoveType = "PLAY" | "PLAY_FREE" | "UPGRADE_WONDER" | "DISCARD" | "COPY_GUILD"; -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>, -}; - -export type ApiBoughtResources = { - provider: ApiProvider, - resources: ApiResources, -}; - export type ApiPlayerMove = { type: ApiMoveType, cardName: string, boughtResources: ApiBoughtResources[], }; - -export type ApiPlayedMove = { - playerIndex: number, - type: ApiMoveType, - card: ApiTableCard, - boughtResources: ApiBoughtResources[], -}; |