changes in Siedler Board. Usage of Field Class added.
This commit is contained in:
parent
7c913089b5
commit
b38e24b612
|
@ -1,11 +1,15 @@
|
|||
package ch.zhaw.catan;
|
||||
|
||||
import ch.zhaw.hexboard.Label;
|
||||
|
||||
public class Field {
|
||||
|
||||
private Config.Land land;
|
||||
private Label label;
|
||||
|
||||
public Field(Config.Land land){
|
||||
public Field(Config.Land land, Label label){
|
||||
this.land = land;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Config.Resource getResource(){
|
||||
|
@ -15,4 +19,8 @@ public class Field {
|
|||
public Config.Land getLand() {
|
||||
return land;
|
||||
}
|
||||
|
||||
public Label getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,38 +10,37 @@ import java.util.*;
|
|||
|
||||
public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||
|
||||
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
|
||||
Map<Point, Field> lowerFieldLabel = new HashMap<>();
|
||||
|
||||
public void createFixGamefield(){
|
||||
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();
|
||||
if(dicePlacement.get(resourceField.getKey()) != null){
|
||||
String numberAsString = dicePlacement.get(resourceField.getKey()).toString();
|
||||
char[] numbersInChar = numberAsString.toCharArray();
|
||||
if (numberAsString.length() < 2) {
|
||||
lowerFieldLabel.put(diceField.getKey(), new Label('0', numbersInChar[0]));
|
||||
lowerFieldLabel.put(resourceField.getKey(), new Field(resourceField.getValue(), new Label('0', numbersInChar[0])));
|
||||
}
|
||||
else {
|
||||
lowerFieldLabel.put(diceField.getKey(), new Label(numbersInChar[0],numbersInChar[1]));
|
||||
|
||||
lowerFieldLabel.put(resourceField.getKey(), new Field(resourceField.getValue(), new Label(numbersInChar[0],numbersInChar[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getDiceNumber(Point field) {
|
||||
Label label = lowerFieldLabel.get(field);
|
||||
Label label = lowerFieldLabel.get(field).getLabel();
|
||||
return Integer.parseInt(label.toString());
|
||||
}
|
||||
|
||||
|
||||
public String getTextView () {
|
||||
SiedlerBoardTextView view = new SiedlerBoardTextView(this);
|
||||
for (Map.Entry<Point, Label> e : lowerFieldLabel.entrySet()) {
|
||||
view.setLowerFieldLabel(e.getKey(), e.getValue());
|
||||
for (Map.Entry<Point, Field> e : lowerFieldLabel.entrySet()) {
|
||||
view.setLowerFieldLabel(e.getKey(), e.getValue().getLabel());
|
||||
}
|
||||
return view.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue