@@ -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