Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -15,15 +15,14 @@ public class Dummy {
|
||||
SHOW, QUIT
|
||||
}
|
||||
|
||||
|
||||
private void run() {
|
||||
TextIO textIO = TextIoFactory.getTextIO();
|
||||
TextTerminal<?> textTerminal = textIO.getTextTerminal();
|
||||
|
||||
SiedlerBoard board = new SiedlerBoard();
|
||||
board.addField(new Point(2, 2), Land.FOREST);
|
||||
board.setCorner(new Point(3, 3), "RR");
|
||||
board.setEdge(new Point(2, 0), new Point(3, 1), "r");
|
||||
board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED));
|
||||
board.setEdge(new Point(2, 0), new Point(3, 1), new Road(Config.Faction.BLUE));
|
||||
board.addFieldAnnotation(new Point(2, 2), new Point(3, 1), "AA");
|
||||
|
||||
Map<Point, Label> lowerFieldLabel = new HashMap<>();
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package ch.zhaw.catan;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* New Class PLayer
|
||||
* This class is here to add players to the game.
|
||||
* @author: Stefan Amador
|
||||
*/
|
||||
public class Player {
|
||||
|
||||
private String name;
|
||||
private Config.Faction faction;
|
||||
private HashMap<Config.Resource,Integer> resources;
|
||||
private int roadsToUse;
|
||||
private int settlementsToUse;
|
||||
|
||||
public Player (String name, Config.Faction faction){
|
||||
//Datenfelder
|
||||
this.name = name;
|
||||
this.faction = faction;
|
||||
roadsToUse = Config.Structure.ROAD.getStockPerPlayer();
|
||||
settlementsToUse = Config.Structure.SETTLEMENT.getStockPerPlayer();
|
||||
//Ressourcen initialisiern
|
||||
resources = new HashMap<>();
|
||||
for(Config.Resource resource : Config.Resource.values()) {
|
||||
resources.put(resource,0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns all the resources the player has at the moment
|
||||
* @return HashMap
|
||||
*/
|
||||
public HashMap<Config.Resource,Integer> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
|
||||
public boolean buildRoad() {
|
||||
if (roadsToUse > 0) {
|
||||
roadsToUse--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean buildSettlement() {
|
||||
if (settlementsToUse > 0) {
|
||||
settlementsToUse--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package ch.zhaw.catan;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Road {
|
||||
private HashMap<Config.Resource,Integer> buildCost;
|
||||
private Config.Faction faction;
|
||||
|
||||
public Road(Config.Faction faction) {
|
||||
this.faction = faction;
|
||||
buildCost = new HashMap<>();
|
||||
buildCost.put(Config.Resource.BRICK,1);
|
||||
buildCost.put(Config.Resource.LUMBER,1);
|
||||
}
|
||||
|
||||
public HashMap<Config.Resource,Integer> getBuildCost() {
|
||||
return buildCost;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package ch.zhaw.catan;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Settlement {
|
||||
private HashMap<Config.Resource,Integer> buildCost;
|
||||
private Config.Faction faction;
|
||||
|
||||
public Settlement(Config.Faction faction) {
|
||||
this.faction = faction;
|
||||
buildCost = new HashMap<>();
|
||||
buildCost.put(Config.Resource.LUMBER,1);
|
||||
buildCost.put(Config.Resource.BRICK,1);
|
||||
buildCost.put(Config.Resource.GRAIN,1);
|
||||
buildCost.put(Config.Resource.WOOL,1);
|
||||
}
|
||||
|
||||
public HashMap<Config.Resource,Integer> getBuildCost() {
|
||||
return buildCost;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,5 +16,7 @@ public class Siedler {
|
||||
TextTerminal<?> textTerminal = textIO.getTextTerminal();
|
||||
textTerminal.println(game.getBoard().getTextView());
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
||||
public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||
|
||||
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ public class SiedlerGame {
|
||||
static final int FOUR_TO_ONE_TRADE_OFFER = 4;
|
||||
static final int FOUR_TO_ONE_TRADE_WANT = 1;
|
||||
|
||||
SiedlerBoard board;
|
||||
private SiedlerBoard board;
|
||||
private Player[] allPlayers;
|
||||
private int winPoints;
|
||||
|
||||
/**
|
||||
* Constructs a SiedlerGame game state object.
|
||||
@@ -38,6 +40,8 @@ public class SiedlerGame {
|
||||
public SiedlerGame(int winPoints, int numberOfPlayers) {
|
||||
board = new SiedlerBoard();
|
||||
board.createFixGamefield();
|
||||
allPlayers = new Player[numberOfPlayers];
|
||||
this.winPoints = winPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +73,9 @@ public class SiedlerGame {
|
||||
*/
|
||||
public List<Faction> getPlayerFactions() {
|
||||
// TODO: Implement
|
||||
Faction[] factions = new Faction[allPlayers.length];
|
||||
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -212,7 +219,18 @@ public class SiedlerGame {
|
||||
* @return true, if the placement was successful
|
||||
*/
|
||||
public boolean buildRoad(Point roadStart, Point roadEnd) {
|
||||
// TODO: Implement
|
||||
//1. Check if Edge
|
||||
if(!board.hasEdge(roadStart,roadEnd)){
|
||||
// TODO: Error message
|
||||
}
|
||||
//2. Check if Edge is empty
|
||||
if(board.getEdge(roadStart,roadEnd) != null) {
|
||||
// TODO: Error message
|
||||
}
|
||||
//3. Can Player build road
|
||||
// TODO
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user