Skip to content

Commit

Permalink
feat(tblock): implement initial position
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablito2020 committed Apr 16, 2022
1 parent 66f35f4 commit 5d80824
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/kotlin/blocks/implementation/TBlock.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package blocks.implementation

import blocks.Block
import blocks.Rotation
import movements.Direction
import movements.Position

class TBlock(private val initialPosition: Position): Block {

val positions = listOf(Position(0, 1), Position(1, 0), Position(1,1), Position(1, 2))

override fun getNeededPositions(): Collection<Position> {
return positions.map({pos -> pos.addAxes(initialPosition)})
}

override fun rotate(degree: Rotation) {
TODO("Not yet implemented")
}

override fun move(direction: Direction) {
TODO("Not yet implemented")
}

}
36 changes: 36 additions & 0 deletions src/test/kotlin/blocks/TBlock/TBlockTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package blocks.TBlock

import blocks.implementation.TBlock
import movements.Position
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class TBlockTest {

@Test
fun `position 0,0 needed positions are (0,0), (1,0), (1,1), (1,2)`() {
val tBlock = TBlock(Position(0, 0))
assertEquals(
listOf(Position(0, 1), Position(1, 0), Position(1, 1), Position(1, 2)),
tBlock.getNeededPositions()
)
}

@Test
fun `position 0,1 needed positions are (0,2), (1, 1), (1,2), (1,3)`() {
val tBlock = TBlock(Position(0, 1))
assertEquals(
listOf(Position(0, 2), Position(1, 1), Position(1, 2), Position(1, 3)),
tBlock.getNeededPositions()
)
}

@Test
fun `position 1,0 needed positions are (1, 1), (2,0), (2,1), (2,2)`() {
val tBlock = TBlock(Position(1, 0))
assertEquals(
listOf(Position(1, 1), Position(2, 0), Position(2, 1), Position(2, 2)),
tBlock.getNeededPositions()
)
}
}

0 comments on commit 5d80824

Please sign in to comment.