Commit d7b15bee authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

Functions for checking if a player is finished

parent 6856a143
......@@ -47,7 +47,7 @@ public class GameController {
activePiece.setRotateHead(false);
activePiece = null;
previousCoordinateClicked = null;
// TODO: Check if all pieces are in goal?
// TODO: Check if all pieces of the player are in goal? (model.isPlayerFinished)
} else {
// TODO: Give feedback (move was not valid/not executed)
}
......
......@@ -31,4 +31,16 @@ class Game(gameState: GameState) {
return this.gameState.getBoardState()?.movePiece(fromCoordinates, toCoordinates) ?: false
}
fun isPlayerFinished(player: Player): Boolean {
val targetFields = this.gameState.getRules()?.getPlayerTargetFields(player.id)
if (targetFields != null) {
for (targetField: Vector3 in targetFields) {
if (this.gameState.getBoardState()?.fields?.get(targetField)?.getPiece()?.getOwner()?.id != player.id) {
return false
}
}
}
return true
}
}
\ No newline at end of file
......@@ -2,10 +2,14 @@ package com.mygdx.game.model
class Piece(owner: Player) {
var owner:Player
private var owner: Player
init {
this.owner = owner
}
fun getOwner(): Player {
return this.owner
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment