createFixGamefield method finished and removed depreciated code
This commit is contained in:
parent
e27d9b38b2
commit
b30a019566
|
@ -13,25 +13,23 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
|
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
|
||||||
|
|
||||||
public void createFixGamefield(){
|
public void createFixGamefield(){
|
||||||
Integer[][] waterCoordinates = {{4,2},{6,2},{8,2},{10,2},{3,5},{11,5},{2,8},{12,8},{1,11},
|
Map<Point,Land> resourcePlacement = Config.getStandardLandPlacement();
|
||||||
{13,11},{2,14},{12,14},{3,17},{11,17},{4,20},{6,20},{8,20},{10,20}};
|
Map<Point, Integer> dicePlacement = Config.getStandardDiceNumberPlacement();
|
||||||
Integer[][] desertCoordinates = {{7,11}};
|
for (Map.Entry<Point,Land> resourceField : resourcePlacement.entrySet()) {
|
||||||
Integer[][] forestCoordinates = {{5,5,6},{10,8,10},{3,11,5},{8,14,3}};
|
addField(resourceField.getKey(),resourceField.getValue());
|
||||||
Integer[][] hillCoordinates = {{5,11,9},{5,17,8},{9,17,11}};
|
}
|
||||||
Integer[][] fieldCoordinates = {{4,8,2},{8,8,5},{11,11,9},{4,14,10}};
|
for (Map.Entry<Point,Integer> diceField : dicePlacement.entrySet()) {
|
||||||
Integer[][] pastureCoordinates = {{7,5,3},{9,5,8},{10,14,12},{7,17,4}};
|
String numberAsString = diceField.getValue().toString();
|
||||||
Integer[][] mountainCoordinates = {{6,8,4},{9,11,6},{6,14,11}};
|
char[] numbersInChar = numberAsString.toCharArray();
|
||||||
|
if (numberAsString.length() < 2) {
|
||||||
placeFieldWithoutLabel(Land.WATER, waterCoordinates);
|
lowerFieldLabel.put(diceField.getKey(), new Label('0', numbersInChar[0]));
|
||||||
placeFieldWithoutLabel(Land.DESERT, desertCoordinates);
|
}
|
||||||
placeFieldWithLabel(Land.FOREST, forestCoordinates);
|
else {
|
||||||
placeFieldWithLabel(Land.HILLS, hillCoordinates);
|
lowerFieldLabel.put(diceField.getKey(), new Label(numbersInChar[0],numbersInChar[1]));
|
||||||
placeFieldWithLabel(Land.FIELDS, fieldCoordinates);
|
|
||||||
placeFieldWithLabel(Land.PASTURE, pastureCoordinates);
|
|
||||||
placeFieldWithLabel(Land.MOUNTAIN, mountainCoordinates);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private int getDiceNumber(Point field) {
|
private int getDiceNumber(Point field) {
|
||||||
|
@ -48,23 +46,6 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
return view.toString();
|
return view.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeFieldWithoutLabel(Land fieldType, Integer[][] fieldCoordinates) {
|
|
||||||
for(Integer[] coordinates : fieldCoordinates) {
|
|
||||||
addField(new Point(coordinates[0], coordinates[1]), fieldType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void placeFieldWithLabel(Land fieldType, Integer[][] fieldInformation) {
|
|
||||||
for(Integer[] information : fieldInformation) {
|
|
||||||
addField(new Point(information[0], information[1]), fieldType);
|
|
||||||
char[] label = information[2].toString().toCharArray();
|
|
||||||
if (label.length == 1) {
|
|
||||||
lowerFieldLabel.put(new Point(information[0], information[1]), new ch.zhaw.hexboard.Label('0', label[0]));
|
|
||||||
} else {
|
|
||||||
lowerFieldLabel.put(new Point(information[0], information[1]), new Label(label[0], label[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: Add fields, constructors and methods as you see fit. Do NOT change the signature
|
//TODO: Add fields, constructors and methods as you see fit. Do NOT change the signature
|
||||||
// of the methods below.
|
// of the methods below.
|
||||||
|
@ -110,6 +91,6 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
else {
|
else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(Arrays.asList(lands));
|
return List.of(lands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue