Skip to content

Commit 77ca835

Browse files
committed
refactor(plugin): add redundant safe calls for serialisation safety
1 parent 2cde70a commit 77ca835

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

plugin/src/shared/sc/plugin2021/GameState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class GameState @JvmOverloads constructor(
131131
result = 31 * result + (lastMove?.hashCode() ?: 0)
132132
result = 31 * result + board.hashCode()
133133
result = 31 * result + undeployedPieceShapes.hashCode()
134-
result = 31 * result + deployedPieces.hashCode()
135134
result = 31 * result + currentTeam.hashCode()
136135
result = 31 * result + turn
137136
return result

plugin/src/shared/sc/plugin2021/util/GameRuleLogic.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object GameRuleLogic {
3939
gameState.board[it] = +move.color
4040
}
4141
gameState.undeployedPieceShapes.getValue(move.color).remove(move.piece.kind)
42-
gameState.deployedPieces.getValue(move.color).add(move.piece)
42+
gameState.deployedPieces?.getValue(move.color).add(move.piece)
4343

4444
// If it was the last piece for this color, remove him from the turn queue
4545
if (gameState.undeployedPieceShapes.getValue(move.color).isEmpty()) {
@@ -80,7 +80,7 @@ object GameRuleLogic {
8080
if (bordersOnColor(gameState.board, it, move.color))
8181
throw InvalidMoveException("Field $it already borders on ${move.color}", move)
8282
}
83-
if (gameState.deployedPieces[move.color].isNullOrEmpty()) {
83+
if (gameState.deployedPieces?.getValue(move.color).isNullOrEmpty()) {
8484
// Check if it's the requested shape
8585
if (move.piece.kind != gameState.startPiece)
8686
throw InvalidMoveException("Expected the predetermined staring piece, ${gameState.startPiece}", move)

0 commit comments

Comments
 (0)