diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-22 03:00:54 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-22 03:00:54 +0200 |
commit | 4a328a310384300e00527bbcbdaa9efbc4453547 (patch) | |
tree | 2f09067d2681bc199ef686722a617df5b30a7150 /sw-engine/src | |
parent | Reorganize packages again (diff) | |
download | seven-wonders-4a328a310384300e00527bbcbdaa9efbc4453547.tar.gz seven-wonders-4a328a310384300e00527bbcbdaa9efbc4453547.tar.bz2 seven-wonders-4a328a310384300e00527bbcbdaa9efbc4453547.zip |
Use import aliases to remove annoying prefixes
Diffstat (limited to 'sw-engine/src')
3 files changed, 42 insertions, 44 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt index bbd96d33..8cdda393 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt @@ -5,7 +5,7 @@ import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.engine.cards.Card import org.luxons.sevenwonders.engine.cards.Decks import org.luxons.sevenwonders.engine.cards.Hands -import org.luxons.sevenwonders.engine.converters.toApiTable +import org.luxons.sevenwonders.engine.converters.toGameState import org.luxons.sevenwonders.engine.converters.toPlayedMove import org.luxons.sevenwonders.engine.converters.toTableCard import org.luxons.sevenwonders.engine.data.LAST_AGE @@ -14,7 +14,7 @@ import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.engine.moves.resolve import org.luxons.sevenwonders.engine.score.ScoreBoard import org.luxons.sevenwonders.model.Action -import org.luxons.sevenwonders.model.ApiTable +import org.luxons.sevenwonders.model.GameState import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.model.PlayerTurnInfo import org.luxons.sevenwonders.model.cards.CardBack @@ -54,7 +54,7 @@ class Game internal constructor( return PlayerTurnInfo( playerIndex = player.index, - table = table.toApiTable(), + table = table.toGameState(), action = action, hand = hand, preparedMove = preparedMoves[player.index]?.toPlayedMove(), @@ -107,7 +107,7 @@ class Game internal constructor( * had not prepared their moves (unless these players had nothing to do). To avoid this, please check if everyone * is ready using [allPlayersPreparedTheirMove]. */ - fun playTurn(): ApiTable { + fun playTurn(): GameState { makeMoves() if (endOfAgeReached()) { executeEndOfAgeEvents() @@ -118,7 +118,7 @@ class Game internal constructor( rotateHandsIfRelevant() startNewTurn() } - return table.toApiTable() + return table.toGameState() } private fun makeMoves() { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt index ad03c228..efb2613e 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt @@ -1,26 +1,26 @@ package org.luxons.sevenwonders.engine.converters import org.luxons.sevenwonders.engine.Player -import org.luxons.sevenwonders.engine.boards.Military -import org.luxons.sevenwonders.engine.boards.Science import org.luxons.sevenwonders.engine.boards.ScienceType -import org.luxons.sevenwonders.engine.cards.Requirements import org.luxons.sevenwonders.engine.moves.Move -import org.luxons.sevenwonders.engine.resources.Production import org.luxons.sevenwonders.engine.resources.Resources import org.luxons.sevenwonders.model.MoveType -import org.luxons.sevenwonders.model.boards.ApiBoard -import org.luxons.sevenwonders.model.boards.ApiMilitary -import org.luxons.sevenwonders.model.boards.ApiProduction -import org.luxons.sevenwonders.model.boards.ApiRequirements -import org.luxons.sevenwonders.model.boards.ApiScience import org.luxons.sevenwonders.model.cards.TableCard import org.luxons.sevenwonders.model.resources.CountedResource -import org.luxons.sevenwonders.model.wonders.ApiWonder -import org.luxons.sevenwonders.model.wonders.ApiWonderStage import org.luxons.sevenwonders.engine.boards.Board as InternalBoard +import org.luxons.sevenwonders.engine.boards.Military as InternalMilitary +import org.luxons.sevenwonders.engine.boards.Science as InternalScience +import org.luxons.sevenwonders.engine.cards.Requirements as InternalRequirements +import org.luxons.sevenwonders.engine.resources.Production as InternalProduction import org.luxons.sevenwonders.engine.wonders.Wonder as InternalWonder import org.luxons.sevenwonders.engine.wonders.WonderStage as InternalWonderStage +import org.luxons.sevenwonders.model.boards.Board as ApiBoard +import org.luxons.sevenwonders.model.boards.Military as ApiMilitary +import org.luxons.sevenwonders.model.boards.Production as ApiProduction +import org.luxons.sevenwonders.model.boards.Requirements as ApiRequirements +import org.luxons.sevenwonders.model.boards.Science as ApiScience +import org.luxons.sevenwonders.model.wonders.ApiWonder as ApiWonder +import org.luxons.sevenwonders.model.wonders.ApiWonderStage as ApiWonderStage internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?): ApiBoard = ApiBoard( @@ -45,34 +45,33 @@ internal fun List<TableCard>.toColumns(): List<List<TableCard>> { return listOf(resourceCardsCol) + otherColsSorted } -internal fun InternalWonder.toApiWonder(player: Player, lastMove: Move?): ApiWonder = - ApiWonder( - name = name, - initialResource = initialResource, - stages = stages.map { it.toApiWonderStage(lastBuiltStage == it, lastMove) }, - image = image, - nbBuiltStages = nbBuiltStages, - buildability = computeBuildabilityBy(player) - ) - -internal fun InternalWonderStage.toApiWonderStage( - isLastBuiltStage: Boolean, - lastMove: Move? -): ApiWonderStage = ApiWonderStage( - cardBack = cardBack, - isBuilt = isBuilt, - requirements = requirements.toApiRequirements(), - builtDuringLastMove = lastMove?.type == MoveType.UPGRADE_WONDER && isLastBuiltStage +internal fun InternalWonder.toApiWonder(player: Player, lastMove: Move?): ApiWonder = ApiWonder( + name = name, + initialResource = initialResource, + stages = stages.map { it.toApiWonderStage(lastBuiltStage == it, lastMove) }, + image = image, + nbBuiltStages = nbBuiltStages, + buildability = computeBuildabilityBy(player) ) -internal fun Production.toApiProduction(): ApiProduction = +internal fun InternalWonderStage.toApiWonderStage(isLastBuiltStage: Boolean, lastMove: Move?): ApiWonderStage = + ApiWonderStage( + cardBack = cardBack, + isBuilt = isBuilt, + requirements = requirements.toApiRequirements(), + builtDuringLastMove = lastMove?.type == MoveType.UPGRADE_WONDER && isLastBuiltStage + ) + +internal fun InternalProduction.toApiProduction(): ApiProduction = ApiProduction( - fixedResources = getFixedResources().toCountedResourcesList(), alternativeResources = getAlternativeResources() + fixedResources = getFixedResources().toCountedResourcesList(), + alternativeResources = getAlternativeResources() ) -internal fun Requirements.toApiRequirements(): ApiRequirements = +internal fun InternalRequirements.toApiRequirements(): ApiRequirements = ApiRequirements( - gold = gold, resources = resources.toCountedResourcesList() + gold = gold, + resources = resources.toCountedResourcesList() ) internal fun Resources.toCountedResourcesList(): List<CountedResource> = @@ -80,10 +79,9 @@ internal fun Resources.toCountedResourcesList(): List<CountedResource> = .map { (type, count) -> CountedResource(count, type) } .sortedBy { it.type } -internal fun Military.toApiMilitary(): ApiMilitary = - ApiMilitary(nbShields, totalPoints, nbDefeatTokens) +internal fun InternalMilitary.toApiMilitary(): ApiMilitary = ApiMilitary(nbShields, totalPoints, nbDefeatTokens) -internal fun Science.toApiScience(): ApiScience = +internal fun InternalScience.toApiScience(): ApiScience = ApiScience( jokers = jokers, nbWheels = getQuantity(ScienceType.WHEEL), diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt index d2f5410b..77843334 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt @@ -1,12 +1,12 @@ package org.luxons.sevenwonders.engine.converters import org.luxons.sevenwonders.engine.SimplePlayer -import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.engine.moves.Move -import org.luxons.sevenwonders.model.ApiTable import org.luxons.sevenwonders.model.PlayedMove +import org.luxons.sevenwonders.engine.boards.Table +import org.luxons.sevenwonders.model.GameState -internal fun Table.toApiTable(): ApiTable = ApiTable( +internal fun Table.toGameState(): GameState = GameState( boards = boards.mapIndexed { i, b -> b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i)) }, currentAge = currentAge, handRotationDirection = handRotationDirection, |