Skip to content
Snippets Groups Projects
Commit b29a247a authored by morkolai's avatar morkolai
Browse files

finishing touches on zigzag algorithm

parent 5d2df832
No related branches found
No related tags found
1 merge request!14WIP: Default game
...@@ -36,7 +36,7 @@ public class GameController { ...@@ -36,7 +36,7 @@ public class GameController {
} }
// TODO: Check if the piece is owned by this player // TODO: Check if the piece is owned by this player
activePiece = this.view.getPiece(cubeCoordinates); activePiece = this.view.getPiece(cubeCoordinates);
System.out.print(this.model.getGameState().getGameMode().getPossibleMoves(cubeCoordinates,1,1)); System.out.print(this.model.getGameState().getGameMode().getPossibleMoves(cubeCoordinates));
activePiece.setRotateHead(true); activePiece.setRotateHead(true);
previousCoordinateClicked = cubeCoordinates; previousCoordinateClicked = cubeCoordinates;
} else { // Field does NOT have piece } else { // Field does NOT have piece
......
...@@ -7,7 +7,7 @@ import com.badlogic.gdx.math.Vector3 ...@@ -7,7 +7,7 @@ import com.badlogic.gdx.math.Vector3
class Game(gameState: GameState) { class Game(gameState: GameState) {
var gameState: GameState private var gameState: GameState
init { init {
this.gameState = gameState this.gameState = gameState
...@@ -43,4 +43,8 @@ class Game(gameState: GameState) { ...@@ -43,4 +43,8 @@ class Game(gameState: GameState) {
} }
return true return true
} }
fun getGameState(): GameState? {
return this.gameState
}
} }
\ No newline at end of file
...@@ -117,9 +117,9 @@ class GameMode(rules:AbstractRules? = null, board:AbstractBoard? = null) { ...@@ -117,9 +117,9 @@ class GameMode(rules:AbstractRules? = null, board:AbstractBoard? = null) {
} }
} }
fun getPossibleMoves(position: Vector3, moveRange: Int, jumpRange: Int): ArrayList<Vector3> { fun getPossibleMoves(position: Vector3): ArrayList<Vector3> {
var possibleMoves: ArrayList<Vector3> = arrayListOf() var possibleMoves: ArrayList<Vector3> = arrayListOf()
zigzagAlgorithm(position, possibleMoves, moveRange, jumpRange) zigzagAlgorithm(position, possibleMoves, this.rules?.moveRange ?: 1, this.rules?.jumpRange ?: 1)
return possibleMoves return possibleMoves
} }
} }
......
...@@ -7,7 +7,7 @@ Holds the state of the game and all data related to this. ...@@ -7,7 +7,7 @@ Holds the state of the game and all data related to this.
*/ */
class GameState(gameMode: GameMode? = null) { class GameState(gameMode: GameMode? = null) {
var gameMode: GameMode? private var gameMode: GameMode?
private var boardState:AbstractBoard? private var boardState:AbstractBoard?
private var rules:AbstractRules? private var rules:AbstractRules?
private var isStarted: Boolean private var isStarted: Boolean
...@@ -40,6 +40,10 @@ class GameState(gameMode: GameMode? = null) { ...@@ -40,6 +40,10 @@ class GameState(gameMode: GameMode? = null) {
return rules return rules
} }
fun getGameMode(): GameMode? {
return this.gameMode
}
fun isStarted(): Boolean { fun isStarted(): Boolean {
return isStarted return isStarted
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment