Skip to content

Commit 57a477f

Browse files
committed
style: some automated reformatting
1 parent c94cdf3 commit 57a477f

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

src/main/kotlin/sc/gui/controller/GameFlowController.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package sc.gui.controller
22

3+
import io.github.oshai.kotlinlogging.KotlinLogging
34
import javafx.animation.Animation
45
import javafx.animation.KeyFrame
56
import javafx.animation.Timeline
67
import javafx.stage.FileChooser
78
import javafx.util.Duration
8-
import io.github.oshai.kotlinlogging.KotlinLogging
99
import sc.api.plugins.IGameState
1010
import sc.framework.HelperMethods
1111
import sc.framework.ReplayLoader
@@ -124,9 +124,10 @@ class GameFlowController: Controller() {
124124
gameModel.availableTurns.set(history.last().turn)
125125
gameModel.gameResult.set(result.second)
126126
gameModel.playerNames.setAll(
127-
result.second?.scores?.keys
128-
?.sortedBy { it.team.index }
129-
?.map { it.displayName }.orEmpty())
127+
result.second?.scores?.keys
128+
?.sortedBy { it.team.index }
129+
?.map { it.displayName }.orEmpty()
130+
)
130131
gameModel.gameState.set(history.first())
131132

132133
fire(GameReadyEvent())

src/main/kotlin/sc/gui/view/game/PenguinsBoard.kt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ class PenguinBoard: View() {
6868
// TODO finish pending movements
6969
logger.trace { "New state for board: ${state.longString()}" }
7070

71-
val lastMove = arrayOf(state to state.lastMove, oldState to oldState?.lastMove?.reversed()).maxByOrNull {
72-
it.first?.turn ?: -1
73-
}!!.second
71+
val lastMove =
72+
arrayOf(state to state.lastMove, oldState to oldState?.lastMove?.reversed()).maxByOrNull {
73+
it.first?.turn ?: -1
74+
}!!.second
7475
// TODO tornadofx: nested CSS, Color.derive with defaults, configProperty, CSS important, selectClass/Pseudo
7576
// TODO sounds for figure movements
7677
lastMove?.let { move ->
@@ -80,15 +81,19 @@ class PenguinBoard: View() {
8081
parallelTransition {
8182
var cur = -1
8283
val moveType =
83-
if((oldState?.board?.getOrEmpty(move.to)?.fish ?: 0) > 1) "consume"
84-
else "move"
84+
if((oldState?.board?.getOrEmpty(move.to)?.fish ?: 0) > 1) "consume"
85+
else "move"
8586
timeline {
8687
cycleCount = 8
8788
this += KeyFrame(animationDuration, {
8889
cur = piece.nextFrame(moveType, cur, randomize = false)
8990
})
9091
}.apply { setOnFinished { piece.nextFrame(moveType, cur, remove = true) } }
91-
children += piece.move(transitionDuration - animationDuration.multiply(2.0), Point2D(move.delta!!.dx * gridSize, move.delta!!.dy * gridSize), play = false) {
92+
children += piece.move(
93+
transitionDuration - animationDuration.multiply(2.0),
94+
Point2D(move.delta!!.dx * gridSize, move.delta!!.dy * gridSize),
95+
play = false
96+
) {
9297
delay = animationDuration.multiply(1.0)
9398
setOnFinished {
9499
piece.translateX = 0.0
@@ -168,11 +173,13 @@ class PenguinBoard: View() {
168173
addPiece(createPiece("penguin"), coordinates)
169174
}
170175
penguin.scaleX = -(piece.index.xor(state.startTeam.index) * 2 - 1.0)
171-
penguin.fade(transitionDuration, AppStyle.pieceOpacity * when {
172-
piece != state.currentTeam -> 0.7
173-
gameModel.atLatestTurn.value && gameState?.isOver == false -> 1.0
174-
else -> 0.9
175-
})
176+
penguin.fade(
177+
transitionDuration, AppStyle.pieceOpacity * when {
178+
piece != state.currentTeam -> 0.7
179+
gameModel.atLatestTurn.value && gameState?.isOver == false -> 1.0
180+
else -> 0.9
181+
}
182+
)
176183
penguin.nextFrame()
177184
penguin.setClass("inactive", piece != state.currentTeam)
178185

@@ -186,12 +193,20 @@ class PenguinBoard: View() {
186193
}
187194
penguin.onLeftClick {
188195
lockedHighlight =
189-
if(coordinates == lockedHighlight || !isSelectable(coordinates)) {
190-
pieces[coordinates]?.let { highlight(it, false, coordinates) }
191-
null
192-
} else {
193-
coordinates.also { pieces[coordinates]?.let { highlight(it, true, coordinates) } }
196+
if(coordinates == lockedHighlight || !isSelectable(coordinates)) {
197+
pieces[coordinates]?.let { highlight(it, false, coordinates) }
198+
null
199+
} else {
200+
coordinates.also {
201+
pieces[coordinates]?.let {
202+
highlight(
203+
it,
204+
true,
205+
coordinates
206+
)
207+
}
194208
}
209+
}
195210
logger.trace { "Clicked $coordinates (lock at $lockedHighlight, current $currentHighlight)" }
196211
}
197212
penguin.setOnMouseExited { event ->

0 commit comments

Comments
 (0)