Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						7afd5b98a2
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<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" />
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,7 @@ public class SiedlerGame {
 | 
			
		|||
    private final int winPointsForWin;
 | 
			
		||||
    private final Bank bank;
 | 
			
		||||
    private int activePlayer;
 | 
			
		||||
    private HashMap<Config.Faction,Integer> longestRoadFaction;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a SiedlerGame game state object.
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +44,7 @@ public class SiedlerGame {
 | 
			
		|||
        allPlayers = new ArrayList<>();
 | 
			
		||||
        createPlayer(numberOfPlayers);
 | 
			
		||||
        activePlayer = 0;
 | 
			
		||||
        longestRoadFaction = new HashMap<>();
 | 
			
		||||
        this.winPointsForWin = winPoints;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -504,7 +506,8 @@ public class SiedlerGame {
 | 
			
		|||
                    winPoints ++;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if(getLongestRoadFaction() == getCurrentPlayerFaction()){
 | 
			
		||||
            longestRoadFaction = getLongestRoadFaction(longestRoadFaction);
 | 
			
		||||
            if(longestRoadFaction.get(getCurrentPlayerFaction()) != null){
 | 
			
		||||
                winPoints += 2;
 | 
			
		||||
            }
 | 
			
		||||
            return winPoints;
 | 
			
		||||
| 
						 | 
				
			
			@ -515,12 +518,12 @@ public class SiedlerGame {
 | 
			
		|||
     * 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
 | 
			
		||||
     */
 | 
			
		||||
    private Faction getLongestRoadFaction() {
 | 
			
		||||
    private HashMap<Config.Faction, Integer> getLongestRoadFaction(HashMap<Config.Faction,Integer> currentLongestRoad) {
 | 
			
		||||
            List<Settlement> corners = board.getCorners();
 | 
			
		||||
            List<Config.Faction> factionList = getPlayerFactions();
 | 
			
		||||
            HashMap<Config.Faction,Integer> players = new HashMap<>();
 | 
			
		||||
            int highest = 0;
 | 
			
		||||
            Config.Faction longestRoad = null;
 | 
			
		||||
 | 
			
		||||
            for(Config.Faction faction : factionList) {
 | 
			
		||||
                int count = 0;
 | 
			
		||||
                players.put(faction,count);
 | 
			
		||||
| 
						 | 
				
			
			@ -535,12 +538,14 @@ public class SiedlerGame {
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
            for(Config.Faction faction : players.keySet()) {
 | 
			
		||||
                if(players.get(faction) >= 5 && players.get(faction)>highest) {
 | 
			
		||||
                    highest = players.get(faction);
 | 
			
		||||
                    longestRoad = faction;
 | 
			
		||||
                for(Config.Faction faction1 : currentLongestRoad.keySet()) {
 | 
			
		||||
                    if(players.get(faction) >= 5 && players.get(faction) > currentLongestRoad.get(faction1)) {
 | 
			
		||||
                        currentLongestRoad.remove(faction1);
 | 
			
		||||
                        currentLongestRoad.put(faction,players.get(faction));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            return longestRoad;
 | 
			
		||||
            }
 | 
			
		||||
            return currentLongestRoad;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue