solved merge problems
This commit is contained in:
parent
c45471c337
commit
442cce6761
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -20,8 +20,7 @@ public class Siedler {
|
||||||
throwDice(game, parser);
|
throwDice(game, parser);
|
||||||
diceThrown = true;
|
diceThrown = true;
|
||||||
}
|
}
|
||||||
|
parser.displayPlayerInfo(game.getCurruntPlayerResource(), game.getCurrentPlayerWinpoints());
|
||||||
parser.displayPlayerInfo(game.getCurrentPlayerResource(), game.getCurrentPlayerWinpoints());
|
|
||||||
switch (parser.getAction()) {
|
switch (parser.getAction()) {
|
||||||
case NEXTPLAYER:
|
case NEXTPLAYER:
|
||||||
Config.Faction winner = game.getWinner();
|
Config.Faction winner = game.getWinner();
|
||||||
|
|
|
@ -386,19 +386,16 @@ public class SiedlerGame {
|
||||||
* @return the winner of the game or null, if there is no winner (yet)
|
* @return the winner of the game or null, if there is no winner (yet)
|
||||||
*/
|
*/
|
||||||
public Faction getWinner() {
|
public Faction getWinner() {
|
||||||
HashMap<Faction, Integer> winPoints = getWinPoints();
|
if(getCurrentPlayerWinpoints() >= winPointsForWin){
|
||||||
for(Faction faction : winPoints.keySet()){
|
return getCurrentPlayerFaction();
|
||||||
if(winPoints.get(faction) >= winPointsForWin){
|
|
||||||
return faction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<Faction, Integer> getWinPoints(){
|
public int getCurrentPlayerWinpoints(){
|
||||||
HashMap<Faction, Integer> winPoints = new HashMap<>();
|
int winPoints = 0;
|
||||||
List<Settlement> structures = board.getCorners();
|
List<Settlement> settlements = board.getCorners();
|
||||||
for(Structure structure : structures) {
|
for(Structure structure : settlements) {
|
||||||
|
|
||||||
int newWinPoints = 0;
|
int newWinPoints = 0;
|
||||||
if(structure instanceof City){
|
if(structure instanceof City){
|
||||||
|
@ -406,15 +403,9 @@ public class SiedlerGame {
|
||||||
} else if(structure instanceof Settlement) {
|
} else if(structure instanceof Settlement) {
|
||||||
newWinPoints = 1;
|
newWinPoints = 1;
|
||||||
}
|
}
|
||||||
|
if(structure.getFaction() == getCurrentPlayerFaction()){
|
||||||
Faction faction = structure.getFaction();
|
winPoints ++;
|
||||||
if(winPoints.containsKey(faction)) {
|
|
||||||
winPoints.put(faction, winPoints.get(faction) + newWinPoints);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
winPoints.put(faction, newWinPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//todo add points for longest road
|
//todo add points for longest road
|
||||||
return winPoints;
|
return winPoints;
|
||||||
|
|
Loading…
Reference in New Issue