diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-25 20:31:39 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-25 20:31:39 +0100 |
commit | 4f84ca4fc2c9f044dc6814da6e8c365d17a76a28 (patch) | |
tree | 7e6decb49ea12dc33f49fc7a98da30ebd2159494 /game-engine/src | |
parent | Change page title to "Seven Wonders" (diff) | |
download | seven-wonders-4f84ca4fc2c9f044dc6814da6e8c365d17a76a28.tar.gz seven-wonders-4f84ca4fc2c9f044dc6814da6e8c365d17a76a28.tar.bz2 seven-wonders-4f84ca4fc2c9f044dc6814da6e8c365d17a76a28.zip |
Improve output model
Diffstat (limited to 'game-engine/src')
-rw-r--r-- | game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Boards.kt | 17 |
1 files changed, 14 insertions, 3 deletions
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, |