solved merge problems

This commit is contained in:
schrom01 2021-12-03 10:09:17 +01:00
parent c45471c337
commit 442cce6761
3 changed files with 21 additions and 31 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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" />
</component>
</project>

View File

@ -20,8 +20,7 @@ public class Siedler {
throwDice(game, parser);
diceThrown = true;
}
parser.displayPlayerInfo(game.getCurrentPlayerResource(), game.getCurrentPlayerWinpoints());
parser.displayPlayerInfo(game.getCurruntPlayerResource(), game.getCurrentPlayerWinpoints());
switch (parser.getAction()) {
case NEXTPLAYER:
Config.Faction winner = game.getWinner();

View File

@ -385,40 +385,31 @@ public class SiedlerGame {
*
* @return the winner of the game or null, if there is no winner (yet)
*/
public Faction getWinner() {
HashMap<Faction, Integer> winPoints = getWinPoints();
for(Faction faction : winPoints.keySet()){
if(winPoints.get(faction) >= winPointsForWin){
return faction;
public Faction getWinner() {
if(getCurrentPlayerWinpoints() >= winPointsForWin){
return getCurrentPlayerFaction();
}
return null;
}
return null;
}
private HashMap<Faction, Integer> getWinPoints(){
HashMap<Faction, Integer> winPoints = new HashMap<>();
List<Settlement> structures = board.getCorners();
for(Structure structure : structures) {
public int getCurrentPlayerWinpoints(){
int winPoints = 0;
List<Settlement> settlements = board.getCorners();
for(Structure structure : settlements) {
int newWinPoints = 0;
if(structure instanceof City){
newWinPoints = 2;
} else if(structure instanceof Settlement) {
newWinPoints = 1;
int newWinPoints = 0;
if(structure instanceof City){
newWinPoints = 2;
} else if(structure instanceof Settlement) {
newWinPoints = 1;
}
if(structure.getFaction() == getCurrentPlayerFaction()){
winPoints ++;
}
}
Faction faction = structure.getFaction();
if(winPoints.containsKey(faction)) {
winPoints.put(faction, winPoints.get(faction) + newWinPoints);
}
else {
winPoints.put(faction, newWinPoints);
}
//todo add points for longest road
return winPoints;
}
//todo add points for longest road
return winPoints;
}
/**