createFixGamefield method finished and removed depreciated code

This commit is contained in:
Leonardo Brandenberger 2021-11-28 01:14:34 +01:00
parent e27d9b38b2
commit b30a019566
1 changed files with 16 additions and 35 deletions

View File

@ -13,24 +13,22 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
public void createFixGamefield(){
Integer[][] waterCoordinates = {{4,2},{6,2},{8,2},{10,2},{3,5},{11,5},{2,8},{12,8},{1,11},
{13,11},{2,14},{12,14},{3,17},{11,17},{4,20},{6,20},{8,20},{10,20}};
Integer[][] desertCoordinates = {{7,11}};
Integer[][] forestCoordinates = {{5,5,6},{10,8,10},{3,11,5},{8,14,3}};
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}};
Integer[][] pastureCoordinates = {{7,5,3},{9,5,8},{10,14,12},{7,17,4}};
Integer[][] mountainCoordinates = {{6,8,4},{9,11,6},{6,14,11}};
placeFieldWithoutLabel(Land.WATER, waterCoordinates);
placeFieldWithoutLabel(Land.DESERT, desertCoordinates);
placeFieldWithLabel(Land.FOREST, forestCoordinates);
placeFieldWithLabel(Land.HILLS, hillCoordinates);
placeFieldWithLabel(Land.FIELDS, fieldCoordinates);
placeFieldWithLabel(Land.PASTURE, pastureCoordinates);
placeFieldWithLabel(Land.MOUNTAIN, mountainCoordinates);
Map<Point,Land> resourcePlacement = Config.getStandardLandPlacement();
Map<Point, Integer> dicePlacement = Config.getStandardDiceNumberPlacement();
for (Map.Entry<Point,Land> resourceField : resourcePlacement.entrySet()) {
addField(resourceField.getKey(),resourceField.getValue());
}
for (Map.Entry<Point,Integer> diceField : dicePlacement.entrySet()) {
String numberAsString = diceField.getValue().toString();
char[] numbersInChar = numberAsString.toCharArray();
if (numberAsString.length() < 2) {
lowerFieldLabel.put(diceField.getKey(), new Label('0', numbersInChar[0]));
}
else {
lowerFieldLabel.put(diceField.getKey(), new Label(numbersInChar[0],numbersInChar[1]));
}
}
}
@ -48,23 +46,6 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
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
// of the methods below.
@ -110,6 +91,6 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
else {
return Collections.emptyList();
}
return Collections.unmodifiableList(Arrays.asList(lands));
return List.of(lands);
}
}