Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
7afd5b98a2
|
@ -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_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" 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>
|
|
@ -24,6 +24,7 @@ public class SiedlerGame {
|
||||||
private final int winPointsForWin;
|
private final int winPointsForWin;
|
||||||
private final Bank bank;
|
private final Bank bank;
|
||||||
private int activePlayer;
|
private int activePlayer;
|
||||||
|
private HashMap<Config.Faction,Integer> longestRoadFaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a SiedlerGame game state object.
|
* Constructs a SiedlerGame game state object.
|
||||||
|
@ -43,6 +44,7 @@ public class SiedlerGame {
|
||||||
allPlayers = new ArrayList<>();
|
allPlayers = new ArrayList<>();
|
||||||
createPlayer(numberOfPlayers);
|
createPlayer(numberOfPlayers);
|
||||||
activePlayer = 0;
|
activePlayer = 0;
|
||||||
|
longestRoadFaction = new HashMap<>();
|
||||||
this.winPointsForWin = winPoints;
|
this.winPointsForWin = winPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +506,8 @@ public class SiedlerGame {
|
||||||
winPoints ++;
|
winPoints ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(getLongestRoadFaction() == getCurrentPlayerFaction()){
|
longestRoadFaction = getLongestRoadFaction(longestRoadFaction);
|
||||||
|
if(longestRoadFaction.get(getCurrentPlayerFaction()) != null){
|
||||||
winPoints += 2;
|
winPoints += 2;
|
||||||
}
|
}
|
||||||
return winPoints;
|
return winPoints;
|
||||||
|
@ -515,12 +518,12 @@ public class SiedlerGame {
|
||||||
* This method returns the faction of the player with the longest road longer than 5.
|
* This method returns the faction of the player with the longest road longer than 5.
|
||||||
* @return null if there is no player with a road longer than 5 otherwise it returns the faction of the specific player
|
* @return null if there is no player with a road longer than 5 otherwise it returns the faction of the specific player
|
||||||
*/
|
*/
|
||||||
private Faction getLongestRoadFaction() {
|
private HashMap<Config.Faction, Integer> getLongestRoadFaction(HashMap<Config.Faction,Integer> currentLongestRoad) {
|
||||||
List<Settlement> corners = board.getCorners();
|
List<Settlement> corners = board.getCorners();
|
||||||
List<Config.Faction> factionList = getPlayerFactions();
|
List<Config.Faction> factionList = getPlayerFactions();
|
||||||
HashMap<Config.Faction,Integer> players = new HashMap<>();
|
HashMap<Config.Faction,Integer> players = new HashMap<>();
|
||||||
int highest = 0;
|
int highest = 0;
|
||||||
Config.Faction longestRoad = null;
|
|
||||||
for(Config.Faction faction : factionList) {
|
for(Config.Faction faction : factionList) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
players.put(faction,count);
|
players.put(faction,count);
|
||||||
|
@ -535,12 +538,14 @@ public class SiedlerGame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Config.Faction faction : players.keySet()) {
|
for(Config.Faction faction : players.keySet()) {
|
||||||
if(players.get(faction) >= 5 && players.get(faction)>highest) {
|
for(Config.Faction faction1 : currentLongestRoad.keySet()) {
|
||||||
highest = players.get(faction);
|
if(players.get(faction) >= 5 && players.get(faction) > currentLongestRoad.get(faction1)) {
|
||||||
longestRoad = faction;
|
currentLongestRoad.remove(faction1);
|
||||||
|
currentLongestRoad.put(faction,players.get(faction));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return longestRoad;
|
return currentLongestRoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue