diff --git a/.idea/misc.xml b/.idea/misc.xml
index b573818..6bc01a8 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..797acea
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ch/zhaw/catan/City.java b/src/ch/zhaw/catan/City.java
new file mode 100644
index 0000000..ea6d41a
--- /dev/null
+++ b/src/ch/zhaw/catan/City.java
@@ -0,0 +1,8 @@
+package ch.zhaw.catan;
+
+public class City extends Structure {
+
+ public City(Config.Faction faction) {
+ super(faction);
+ }
+}
diff --git a/src/ch/zhaw/catan/Siedler.java b/src/ch/zhaw/catan/Siedler.java
index 7610db4..5d5deb6 100644
--- a/src/ch/zhaw/catan/Siedler.java
+++ b/src/ch/zhaw/catan/Siedler.java
@@ -4,12 +4,14 @@ import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
+import java.awt.*;
+
public class Siedler {
public static void main(String[] args) {
//Spiel erstellen
- SiedlerGame game = new SiedlerGame(0, 0);
+ SiedlerGame game = new SiedlerGame(3, 2);
//Spielfeld ausgeben
TextIO textIO = TextIoFactory.getTextIO();
@@ -18,5 +20,8 @@ public class Siedler {
+
+
+
}
}
diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java
index 361df74..30910f7 100644
--- a/src/ch/zhaw/catan/SiedlerBoard.java
+++ b/src/ch/zhaw/catan/SiedlerBoard.java
@@ -8,7 +8,7 @@ import java.awt.*;
import java.util.*;
import java.util.List;
-public class SiedlerBoard extends HexBoard {
+public class SiedlerBoard extends HexBoard {
Map lowerFieldLabel = new HashMap<>();
diff --git a/src/ch/zhaw/catan/SiedlerBoardTextView.java b/src/ch/zhaw/catan/SiedlerBoardTextView.java
index 11a4ed5..97f6401 100644
--- a/src/ch/zhaw/catan/SiedlerBoardTextView.java
+++ b/src/ch/zhaw/catan/SiedlerBoardTextView.java
@@ -6,7 +6,7 @@ import ch.zhaw.hexboard.Label;
import java.awt.*;
-public class SiedlerBoardTextView extends HexBoardTextView {
+public class SiedlerBoardTextView extends HexBoardTextView {
public SiedlerBoardTextView(SiedlerBoard board) {
super(board);
diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java
index fe9a1ca..a02c74d 100644
--- a/src/ch/zhaw/catan/SiedlerGame.java
+++ b/src/ch/zhaw/catan/SiedlerGame.java
@@ -7,10 +7,7 @@ import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
import java.awt.Point;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
@@ -26,7 +23,7 @@ public class SiedlerGame {
private SiedlerBoard board;
private ArrayList allPlayers;
- private int winPoints;
+ private int winPointsForWin;
private Bank bank;
private int activePlayer;
@@ -48,7 +45,7 @@ public class SiedlerGame {
allPlayers = new ArrayList<>();
createPlayer(numberOfPlayers);
activePlayer = 0;
- this.winPoints = winPoints;
+ this.winPointsForWin = winPoints;
}
private void createPlayer(int numberOfPlayers) {
@@ -292,9 +289,39 @@ public class SiedlerGame {
*/
public Faction getWinner() {
// TODO: Implement
+ HashMap winPoints = getWinPoints();
+ for(Faction faction : winPoints.keySet()){
+ if(winPoints.get(faction) >= winPointsForWin){
+ return faction;
+ }
+ }
return null;
}
+ private HashMap getWinPoints(){
+ HashMap winPoints = new HashMap<>();
+ List structures = board.getCorners();
+ for(Structure structure : structures) {
+
+ int newWinPoints = 0;
+ if(structure instanceof Settlement){
+ newWinPoints = 1;
+ } else if(structure instanceof City) {
+ newWinPoints = 2;
+ }
+
+ Faction faction = structure.getFaction();
+ if(winPoints.containsKey(faction)) {
+ winPoints.put(faction, winPoints.get(faction) + newWinPoints);
+ }
+ else {
+ winPoints.put(faction, newWinPoints);
+ }
+
+ }
+ return winPoints;
+ }
+
/**
* Places the thief on the specified field and steals a random resource card (if
diff --git a/src/ch/zhaw/catan/Structure.java b/src/ch/zhaw/catan/Structure.java
index 04add42..54e589f 100644
--- a/src/ch/zhaw/catan/Structure.java
+++ b/src/ch/zhaw/catan/Structure.java
@@ -10,4 +10,8 @@ public abstract class Structure {
public String toString() {
return faction.toString();
}
+
+ public Config.Faction getFaction() {
+ return faction;
+ }
}