From 4f84ca4fc2c9f044dc6814da6e8c365d17a76a28 Mon Sep 17 00:00:00 2001 From: jbion Date: Mon, 25 Feb 2019 20:31:39 +0100 Subject: Improve output model --- .../kotlin/org/luxons/sevenwonders/game/api/Boards.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'game-engine') 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> + val fixedResources: List, + val alternativeResources: Set> ) -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 = + quantities.map { (type, count) -> ApiCountedResource(count, type)}.sortedBy { it.type } data class ApiMilitary( var nbShields: Int, -- cgit