|
@ -29,7 +29,7 @@ public class Game { |
|
|
} while(figId == -1); |
|
|
} while(figId == -1); |
|
|
g.setFigure(figId, dice, p, g); |
|
|
g.setFigure(figId, dice, p, g); |
|
|
} |
|
|
} |
|
|
} while (g.checkDice(dice, p, c)); |
|
|
|
|
|
|
|
|
} while (g.checkDice(dice, p, c, g)); |
|
|
if(p.checkGameWin(p.figures)) { |
|
|
if(p.checkGameWin(p.figures)) { |
|
|
winner = p; |
|
|
winner = p; |
|
|
System.out.println("Spieler " + winner.name + " gewinnt!"); |
|
|
System.out.println("Spieler " + winner.name + " gewinnt!"); |
|
@ -63,18 +63,21 @@ public class Game { |
|
|
* @param dice Value of dice got from rolldice() |
|
|
* @param dice Value of dice got from rolldice() |
|
|
* @param p active Player |
|
|
* @param p active Player |
|
|
* @param countRolls Counter how often the Player already rolled the dice |
|
|
* @param countRolls Counter how often the Player already rolled the dice |
|
|
|
|
|
* @param g game instance |
|
|
* @return true if Player can roll the dice another time |
|
|
* @return true if Player can roll the dice another time |
|
|
*/ |
|
|
*/ |
|
|
public boolean checkDice(int dice, Player p, int countRolls) { |
|
|
|
|
|
boolean figuresOnBoard = false; |
|
|
|
|
|
for(Figure f : p.figures) { |
|
|
|
|
|
if (f.getPosition() > -1 && f.getPosition() < 40) { |
|
|
|
|
|
figuresOnBoard = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(!figuresOnBoard) { |
|
|
|
|
|
return countRolls < 3; |
|
|
|
|
|
|
|
|
public boolean checkDice(int dice, Player p, int countRolls, Game g) { |
|
|
|
|
|
int figuresInBase = p.checkFigureInBase(p.figures); |
|
|
|
|
|
if(countRolls >= 3) return false; |
|
|
|
|
|
if(figuresInBase == 4) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} else if (figuresInBase < 4) { |
|
|
|
|
|
for(int i = 0; i < 4 - figuresInBase; i++) { |
|
|
|
|
|
if(checkFieldClear(p.startHome+3-i,p,g) == 0) { |
|
|
|
|
|
return dice == 6; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
} else return dice == 6; |
|
|
} else return dice == 6; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|