Skip to content

Commit df35dfb

Browse files
committed
feat(plugin): have piece transformations first rotate, then flip
1 parent 89da3e1 commit df35dfb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum class PieceShape(coordinates: Set<Coordinates>) {
5353

5454
/** Applies all the given transformations. */
5555
fun transform(rotation: Rotation, shouldFlip: Boolean): Set<Coordinates> =
56-
coordinates.flip(shouldFlip).rotate(rotation)
56+
coordinates.rotate(rotation).flip(shouldFlip)
5757

5858
companion object {
5959
val shapes: Map<Int, PieceShape> = ((0 until Constants.TOTAL_PIECE_SHAPES) zip values()).toMap()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class PieceTest: StringSpec({
4444
PieceShape.PENTO_W.transform(Rotation.MIRROR, false) shouldBe shapes[2]
4545
PieceShape.PENTO_W.transform(Rotation.LEFT, false) shouldBe shapes[3]
4646
PieceShape.PENTO_W.transform(Rotation.NONE, true) shouldBe shapes[3]
47-
PieceShape.PENTO_W.transform(Rotation.RIGHT, true) shouldBe shapes[0]
47+
PieceShape.PENTO_W.transform(Rotation.RIGHT, true) shouldBe shapes[2]
4848
PieceShape.PENTO_W.transform(Rotation.MIRROR, true) shouldBe shapes[1]
49-
PieceShape.PENTO_W.transform(Rotation.LEFT, true) shouldBe shapes[2]
49+
PieceShape.PENTO_W.transform(Rotation.LEFT, true) shouldBe shapes[0]
5050
}
5151
"Piece coordination calculation" {
5252
val position = Coordinates(2, 2)

0 commit comments

Comments
 (0)