Skip to content

Commit bdc978f

Browse files
committed
feat(plugin): add transform method to Piece, returning a new Piece
1 parent fc59cd1 commit bdc978f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class Piece(@XStreamAsAttribute val color: Color = Color.BLUE,
4242
val coordinates by lazy {shape.map{position + +it}.toSet()}
4343
return coordinates
4444
}
45+
46+
fun transform(rotation: Rotation, isFlipped: Boolean = false): Piece =
47+
Piece(color, kind, rotation, isFlipped, position)
4548

4649
override fun toString(): String =
4750
"$color Piece $kind:${rotation.value}${if (isFlipped) " (flipped)" else ""} [${position.x},${position.y}]"

0 commit comments

Comments
 (0)