Skip to content

Commit fc59cd1

Browse files
committed
fix(plugin): repair failing tests
1 parent 89359a0 commit fc59cd1

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class GameState @JvmOverloads constructor(
9898
(team as Team).colors.map { getPointsForColor(it) }.sum()
9999

100100
private fun getPointsForColor(color: Color): Int {
101-
val pieces = undeployedPieceShapes.getValue(color)
101+
val pieces = undeployedPieceShapes[color] ?: return GameRuleLogic.SMALLEST_SCORE_POSSIBLE
102102
val lastMono = lastMoveMono[color] ?: false
103103
return GameRuleLogic.getPointsFromUndeployed(pieces, lastMono)
104104
}

plugin/src/test/sc/plugin2021/GameRuleLogicTest.kt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,17 @@ class GameRuleLogicTest: StringSpec({
7979
}
8080
}
8181
"Point score calculation works" {
82-
GameRuleLogic.getPointsFromUndeployed(emptySet()) shouldBe GameRuleLogic.SMALLEST_SCORE_POSSIBLE
82+
GameRuleLogic.getPointsFromUndeployed(PieceShape.values().toSet()) shouldBe GameRuleLogic.SMALLEST_SCORE_POSSIBLE
8383

84-
val fewPieces = listOf(
85-
Piece(Color.BLUE, PieceShape.TRIO_I, Rotation.NONE, true),
86-
Piece(Color.BLUE, PieceShape.TETRO_O, Rotation.NONE, true),
87-
Piece(Color.BLUE, PieceShape.PENTO_P, Rotation.NONE, true),
88-
Piece(Color.BLUE, PieceShape.MONO, Rotation.NONE, true)
84+
val fewPieces = setOf(
85+
PieceShape.MONO,
86+
PieceShape.PENTO_W,
87+
PieceShape.TETRO_I
8988
)
90-
GameRuleLogic.getPointsFromUndeployed(fewPieces.map{it.kind}.toSet()) shouldBe -76
89+
GameRuleLogic.getPointsFromUndeployed(fewPieces) shouldBe -10
9190

92-
val allPieces = PieceShape.shapes.map{
93-
Piece(Color.BLUE, it.key, Rotation.NONE, false)
94-
}.toList()
95-
GameRuleLogic.getPointsFromUndeployed(allPieces.map{it.kind}.toSet(), false) shouldBe 15
96-
97-
val perfectPieces = allPieces.reversed()
98-
GameRuleLogic.getPointsFromUndeployed(perfectPieces.map{it.kind}.toSet(), true) shouldBe 20
91+
GameRuleLogic.getPointsFromUndeployed(emptySet(), false) shouldBe 15
92+
GameRuleLogic.getPointsFromUndeployed(emptySet(), true) shouldBe 20
9993
}
10094
"After the color check, PassMoves throw" {
10195
val state = GameState()

0 commit comments

Comments
 (0)