From d3f59772aafa9dc06a7cae8a16ac4b5093e42527 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Thu, 12 Jul 2018 02:28:19 +0200 Subject: Replace String.format() with template strings --- .../src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt | 2 +- .../kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt index 38a80989..34cccc49 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt @@ -95,5 +95,5 @@ class Board(val wonder: Wonder, val playerIndex: Int, settings: Settings) { private fun computeGoldPoints(): Int = gold / 3 * pointsPer3Gold internal class InsufficientFundsException(current: Int, required: Int) : - RuntimeException(String.format("Current balance is %d gold, but %d are required", current, required)) + IllegalStateException("Current balance is $current gold, but $required are required") } diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt index 67b176df..7e259023 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt @@ -20,9 +20,7 @@ enum class ResourceType(val symbol: Char?) { return fromSymbol(symbol[0]) } - fun fromSymbol(symbol: Char?): ResourceType { - return typesPerSymbol[symbol] - ?: throw IllegalArgumentException(String.format("Unknown resource type symbol '%s'", symbol)) - } + fun fromSymbol(symbol: Char?): ResourceType = + typesPerSymbol[symbol] ?: throw IllegalArgumentException("Unknown resource type symbol '$symbol'") } } -- cgit