package ch.zhaw.catan; import ch.zhaw.catan.Config.Faction; import ch.zhaw.catan.Config.Resource; import org.beryx.textio.TextIO; import org.beryx.textio.TextIoFactory; import org.beryx.textio.TextTerminal; import java.awt.Point; import java.util.Collections; import java.util.List; import java.util.Map; /** * This class performs all actions related to modifying the game state. * * TODO: (your documentation) * * @author TODO * */ public class SiedlerGame { static final int FOUR_TO_ONE_TRADE_OFFER = 4; static final int FOUR_TO_ONE_TRADE_WANT = 1; private SiedlerBoard board; private Player[] allPlayers; private int winPoints; /** * Constructs a SiedlerGame game state object. * * @param winPoints the number of points required to win the game * @param numberOfPlayers the number of players * * @throws IllegalArgumentException if winPoints is lower than * three or players is not between two and four */ public SiedlerGame(int winPoints, int numberOfPlayers) { board = new SiedlerBoard(); board.createFixGamefield(); allPlayers = new Player[numberOfPlayers]; this.winPoints = winPoints; } /** * Switches to the next player in the defined sequence of players. */ public void switchToNextPlayer() { // TODO: Implement } /** * Switches to the previous player in the defined sequence of players. */ public void switchToPreviousPlayer() { // TODO: Implement } /** * Returns the {@link Faction}s of the active players. * *
The order of the player's factions in the list must * correspond to the oder in which they play. * Hence, the player that sets the first settlement must be * at position 0 in the list etc. * * Important note: The list must contain the * factions of active players only.
* * @return the list with player's factions */ public ListThe placement does not cost any resource cards. If payout is * set to true, for each adjacent resource-producing field, a resource card of the * type of the resource produced by the field is taken from the bank (if available) and added to * the players' stock of resource cards.
* * @param position the position of the settlement * @param payout if true, the player gets one resource card per adjacent resource-producing field * @return true, if the placement was successful */ public boolean placeInitialSettlement(Point position, boolean payout) { // TODO: Implement return false; } /** * Places a road in the founder's phase (phase II) of the game. * The placement does not cost any resource cards. * * @param roadStart position of the start of the road * @param roadEnd position of the end of the road * @return true, if the placement was successful */ public boolean placeInitialRoad(Point roadStart, Point roadEnd) { // TODO: Implement return false; } /** * This method takes care of actions depending on the dice throw result. * * A key action is the payout of the resource cards to the players * according to the payout rules of the game. This includes the * "negative payout" in case a 7 is thrown and a player has more than * {@link Config#MAX_CARDS_IN_HAND_NO_DROP} resource cards. * * If a player does not get resource cards, the list for this players' * {@link Faction} is an empty list (not null)!. * ** The payout rules of the game take into account factors such as, the number * of resource cards currently available in the bank, settlement types * (settlement or city), and the number of players that should get resource * cards of a certain type (relevant if there are not enough left in the bank). *
* * @param dicethrow the resource cards that have been distributed to the players * @return the resource cards added to the stock of the different players */ public MapThe settlement can be built if: *
The city can be built if: *
The road can be built if: *