completed method getFieldsForDiceValue in SiedlerBoard
This commit is contained in:
parent
6c36037444
commit
ad1227ac98
Binary file not shown.
Binary file not shown.
|
@ -5,10 +5,8 @@ import ch.zhaw.hexboard.HexBoard;
|
||||||
import ch.zhaw.hexboard.Label;
|
import ch.zhaw.hexboard.Label;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
||||||
|
|
||||||
|
@ -35,6 +33,21 @@ public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getDiceNumber(Point field) {
|
||||||
|
Label label = lowerFieldLabel.get(field);
|
||||||
|
return Integer.parseInt(label.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SiedlerBoardTextView getTextView () {
|
||||||
|
SiedlerBoardTextView view = new SiedlerBoardTextView(this);
|
||||||
|
for (Map.Entry<Point, Label> e : lowerFieldLabel.entrySet()) {
|
||||||
|
view.setLowerFieldLabel(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
private void placeFieldWithoutLabel(Land fieldType, Integer[][] fieldCoordinates) {
|
private void placeFieldWithoutLabel(Land fieldType, Integer[][] fieldCoordinates) {
|
||||||
for(Integer[] coordinates : fieldCoordinates) {
|
for(Integer[] coordinates : fieldCoordinates) {
|
||||||
addField(new Point(coordinates[0], coordinates[1]), fieldType);
|
addField(new Point(coordinates[0], coordinates[1]), fieldType);
|
||||||
|
@ -53,14 +66,10 @@ public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fields associated with the specified dice value.
|
* Returns the fields associated with the specified dice value.
|
||||||
*
|
*
|
||||||
|
@ -69,7 +78,13 @@ public class SiedlerBoard extends HexBoard<Land, String, String, String> {
|
||||||
*/
|
*/
|
||||||
public List<Point> getFieldsForDiceValue(int dice) {
|
public List<Point> getFieldsForDiceValue(int dice) {
|
||||||
//TODO: Implement.
|
//TODO: Implement.
|
||||||
return Collections.emptyList();
|
ArrayList<Point> fields = new ArrayList<>();
|
||||||
|
for(Point field : lowerFieldLabel.keySet()){
|
||||||
|
if(getDiceNumber(field) == dice){
|
||||||
|
fields.add(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,9 @@ package ch.zhaw.catan;
|
||||||
|
|
||||||
import ch.zhaw.catan.Config.Land;
|
import ch.zhaw.catan.Config.Land;
|
||||||
import ch.zhaw.hexboard.HexBoardTextView;
|
import ch.zhaw.hexboard.HexBoardTextView;
|
||||||
|
import ch.zhaw.hexboard.Label;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class SiedlerBoardTextView extends HexBoardTextView<Land, String, String, String> {
|
public class SiedlerBoardTextView extends HexBoardTextView<Land, String, String, String> {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue