Deleted Dummy Class and minor fixes in several classes and use of Config Value MINPLAYER
This commit is contained in:
parent
51defac6f3
commit
9983d3ea1d
|
@ -1,11 +1,10 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class Bank {
|
public class Bank {
|
||||||
private HashMap<Config.Resource, Integer> resources = new HashMap<>();
|
private final HashMap<Config.Resource, Integer> resources = new HashMap<>();
|
||||||
|
|
||||||
public Bank(){
|
public Bank(){
|
||||||
resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
|
resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Point;
|
||||||
|
|
||||||
public class City extends Settlement {
|
public class City extends Settlement {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import org.beryx.textio.TextIO;
|
//TODO:JavaDoc
|
||||||
|
|
||||||
public enum Command {
|
public enum Command {
|
||||||
NEXTPLAYER ("next player"), BUILDSETTLEMENT ("build settlement"), BUILDCITY("build city"),
|
NEXTPLAYER ("next player"), BUILDSETTLEMENT ("build settlement"), BUILDCITY("build city"),
|
||||||
BUILDROAD("build road"), TRADEWITHBANK("trade with bank"),QUIT("quit");
|
BUILDROAD("build road"), TRADEWITHBANK("trade with bank"),QUIT("quit");
|
||||||
|
|
||||||
private String commandWord;
|
private final String commandWord;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
package ch.zhaw.catan;
|
|
||||||
|
|
||||||
import ch.zhaw.catan.Config.Land;
|
|
||||||
import ch.zhaw.hexboard.Label;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.beryx.textio.TextIO;
|
|
||||||
import org.beryx.textio.TextIoFactory;
|
|
||||||
import org.beryx.textio.TextTerminal;
|
|
||||||
|
|
||||||
public class Dummy {
|
|
||||||
|
|
||||||
public enum Actions {
|
|
||||||
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), new Settlement(Config.Faction.RED,new Point(3, 3)));
|
|
||||||
board.setEdge(new Point(2, 0), new Point(3, 1), new Road(Config.Faction.BLUE,new Point(2, 0),new Point(2, 0)));
|
|
||||||
board.addFieldAnnotation(new Point(2, 2), new Point(3, 1), "AA");
|
|
||||||
|
|
||||||
Map<Point, Label> lowerFieldLabel = new HashMap<>();
|
|
||||||
lowerFieldLabel.put(new Point(2, 2), new Label('0', '9'));
|
|
||||||
SiedlerBoardTextView view = new SiedlerBoardTextView(board);
|
|
||||||
|
|
||||||
for (Map.Entry<Point, Label> e : lowerFieldLabel.entrySet()) {
|
|
||||||
view.setLowerFieldLabel(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean running = true;
|
|
||||||
while (running) {
|
|
||||||
switch (getEnumValue(textIO, Actions.class)) {
|
|
||||||
case SHOW:
|
|
||||||
textTerminal.println(view.toString());
|
|
||||||
break;
|
|
||||||
case QUIT:
|
|
||||||
running = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Internal error found - Command not implemented.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textIO.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends Enum<T>> T getEnumValue(TextIO textIO, Class<T> commands) {
|
|
||||||
return textIO.newEnumInputReader(commands).read("What would you like to do?");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new Dummy().run();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -76,7 +76,7 @@ public class Parser {
|
||||||
*/
|
*/
|
||||||
public HashMap<String, Integer> gameStart() {
|
public HashMap<String, Integer> gameStart() {
|
||||||
HashMap<String, Integer> gameStartValues = new HashMap<>();
|
HashMap<String, Integer> gameStartValues = new HashMap<>();
|
||||||
gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(2).withMaxVal(4).read("Number of players:"));
|
gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(Config.MIN_NUMBER_OF_PLAYERS).withMaxVal(4).read("Number of players:"));
|
||||||
gameStartValues.put("NumberOfWinPoints", textIO.newIntInputReader().withMinVal(5).withMaxVal(15).read("Winpoints needed for Victory:"));
|
gameStartValues.put("NumberOfWinPoints", textIO.newIntInputReader().withMinVal(5).withMaxVal(15).read("Winpoints needed for Victory:"));
|
||||||
return gameStartValues;
|
return gameStartValues;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New Class PLayer
|
* New Class PLayer
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ch.zhaw.catan;
|
package ch.zhaw.catan;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Point;
|
||||||
|
|
||||||
public class Road extends Structure {
|
public class Road extends Structure {
|
||||||
|
|
||||||
private Point start,end;
|
private final Point start,end;
|
||||||
|
|
||||||
|
|
||||||
public Road(Config.Faction faction,Point start,Point end) {
|
public Road(Config.Faction faction,Point start,Point end) {
|
||||||
|
|
Loading…
Reference in New Issue