solved merge problems
This commit is contained in:
parent
c45471c337
commit
442cce6761
|
@ -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>
|
|
@ -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();
|
||||
|
|
|
@ -386,19 +386,16 @@ 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;
|
||||
}
|
||||
if(getCurrentPlayerWinpoints() >= winPointsForWin){
|
||||
return getCurrentPlayerFaction();
|
||||
}
|
||||
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){
|
||||
|
@ -406,15 +403,9 @@ public class SiedlerGame {
|
|||
} else if(structure instanceof Settlement) {
|
||||
newWinPoints = 1;
|
||||
}
|
||||
|
||||
Faction faction = structure.getFaction();
|
||||
if(winPoints.containsKey(faction)) {
|
||||
winPoints.put(faction, winPoints.get(faction) + newWinPoints);
|
||||
if(structure.getFaction() == getCurrentPlayerFaction()){
|
||||
winPoints ++;
|
||||
}
|
||||
else {
|
||||
winPoints.put(faction, newWinPoints);
|
||||
}
|
||||
|
||||
}
|
||||
//todo add points for longest road
|
||||
return winPoints;
|
||||
|
|
Loading…
Reference in New Issue