Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -5,6 +5,8 @@ import java.awt.Point;
|
||||
/**
|
||||
* Sub Class of Structure and Super Class of City
|
||||
* Can be saved in Siedler Board on a corner
|
||||
*
|
||||
* @author Andrin Fassbind, Roman Schenk
|
||||
*/
|
||||
public class Settlement extends Structure {
|
||||
|
||||
@@ -17,6 +19,8 @@ public class Settlement extends Structure {
|
||||
}
|
||||
|
||||
/**
|
||||
* This Methode Returns the Position of the Settlement
|
||||
*
|
||||
* @return the datafield position
|
||||
*/
|
||||
public Point getPosition() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.Random;
|
||||
|
||||
/**
|
||||
* This Class manages the game process and contains the Main Method which creates and starts a new Parser and a new Game.
|
||||
*
|
||||
* @author Leonardo Brandeberger, Roman Schenk
|
||||
*/
|
||||
public class Siedler {
|
||||
/**
|
||||
@@ -29,7 +31,7 @@ public class Siedler {
|
||||
boolean diceThrown = false;
|
||||
while (running) {
|
||||
Config.Faction currentPlayerFaction = game.getCurrentPlayerFaction();
|
||||
parser.displayGameboard(game.getBoard().getTextView()); //TODO Every turn or separate command?
|
||||
parser.displayGameboard(game.getBoard().getTextView());
|
||||
parser.playerTurn(currentPlayerFaction);
|
||||
if (!diceThrown) {
|
||||
throwDice(parser, game);
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
//TODO Enhance JavaDoc
|
||||
|
||||
/**
|
||||
* Subclass of HexBoard
|
||||
@@ -22,12 +21,11 @@ public class SiedlerBoard extends HexBoard<Config.Land, Settlement, Road, String
|
||||
/**
|
||||
* HashMap to save all Fields which are set yet.
|
||||
* Key: Point with coordinates of the field
|
||||
* //TODO Enhance JavaDoc
|
||||
* Value: Field Object
|
||||
*/
|
||||
private final HashMap<Point, Field> fields = new HashMap<>();
|
||||
private Config.Faction longestRoadFaction = null;
|
||||
private int longestRoadLenth = 0;
|
||||
private int longestRoadLength = 0;
|
||||
|
||||
/**
|
||||
* Method to create the predefined game field from Config.
|
||||
@@ -49,6 +47,15 @@ public class SiedlerBoard extends HexBoard<Config.Land, Settlement, Road, String
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paramter longestRoad
|
||||
*
|
||||
* @return longestRoadLength
|
||||
*/
|
||||
public int getLongestRoadLength() {
|
||||
return longestRoadLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the DiceNumber of a specific field.
|
||||
*
|
||||
@@ -134,10 +141,9 @@ public class SiedlerBoard extends HexBoard<Config.Land, Settlement, Road, String
|
||||
}
|
||||
return List.of(lands);
|
||||
}
|
||||
//TODO Java Doc more details
|
||||
|
||||
/**
|
||||
* This method checks for the player with the longest road according to the siedler game rules.
|
||||
* This method checks for the player with the longest road according to the Siedler game rules.
|
||||
*
|
||||
* @param factionList a List with all factions which can place structures on the board
|
||||
* @return the faction who owns the longest road with minimum length of 5, null there is no road longer then 4
|
||||
@@ -163,19 +169,14 @@ public class SiedlerBoard extends HexBoard<Config.Land, Settlement, Road, String
|
||||
}
|
||||
|
||||
for (Config.Faction factionA : players.keySet()) {
|
||||
if (players.get(factionA) > longestRoadLenth && players.get(factionA) > 4) {
|
||||
if (players.get(factionA) > longestRoadLength && players.get(factionA) > 4) {
|
||||
longestRoadFaction = factionA;
|
||||
longestRoadLenth = players.get(factionA);
|
||||
longestRoadLength = players.get(factionA);
|
||||
}
|
||||
}
|
||||
return longestRoadFaction;
|
||||
}
|
||||
|
||||
//todo javadoc
|
||||
public int getLongestRoadLenth() {
|
||||
return longestRoadLenth;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is recursive and adds all roads which belongs to a specific players and stringing together to a HashSet.
|
||||
* The length of the HashSet represents the length of the longest Road the player has.
|
||||
|
||||
Reference in New Issue
Block a user