updating JavaDoc in SiedlerBoard
This commit is contained in:
parent
2d5cfc5e9e
commit
b30f15e7c5
|
@ -4,14 +4,29 @@ import ch.zhaw.catan.Config.Land;
|
||||||
import ch.zhaw.hexboard.HexBoard;
|
import ch.zhaw.hexboard.HexBoard;
|
||||||
import ch.zhaw.hexboard.Label;
|
import ch.zhaw.hexboard.Label;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Point;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of HexBoard
|
||||||
|
* Saves the fields wich are set and handels Methods with specific Dice Numbers
|
||||||
|
*/
|
||||||
public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
|
|
||||||
Map<Point, Field> fields = new HashMap<>();
|
/**
|
||||||
|
* HashMap to save all Fields which are set yet.
|
||||||
|
* Key: Point with coordinates of the field
|
||||||
|
* Value: Field Object
|
||||||
|
*/
|
||||||
|
HashMap<Point, Field> fields = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create the predefined gamefield from Config.
|
||||||
|
*/
|
||||||
public void createFixGamefield(){
|
public void createFixGamefield(){
|
||||||
Map<Point,Land> resourcePlacement = Config.getStandardLandPlacement();
|
Map<Point,Land> resourcePlacement = Config.getStandardLandPlacement();
|
||||||
Map<Point, Integer> dicePlacement = Config.getStandardDiceNumberPlacement();
|
Map<Point, Integer> dicePlacement = Config.getStandardDiceNumberPlacement();
|
||||||
|
@ -30,13 +45,21 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the DiceNumber of a specific field.
|
||||||
|
* @param field Point with coordinates of the specific field
|
||||||
|
* @return the DiceNumber of the field.
|
||||||
|
*/
|
||||||
private int getDiceNumber(Point field) {
|
private int getDiceNumber(Point field) {
|
||||||
Label label = fields.get(field).getLabel();
|
Label label = fields.get(field).getLabel();
|
||||||
return Integer.parseInt(label.toString());
|
return Integer.parseInt(label.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create a SiedlerBoardTextView Object set the LowerFieldLabels with theirs Dicenumber.
|
||||||
|
* It is used to print the actual board in TextIO.
|
||||||
|
* @return String of actual board.
|
||||||
|
*/
|
||||||
public String getTextView () {
|
public String getTextView () {
|
||||||
SiedlerBoardTextView view = new SiedlerBoardTextView(this);
|
SiedlerBoardTextView view = new SiedlerBoardTextView(this);
|
||||||
for (Map.Entry<Point, Field> field : fields.entrySet()) {
|
for (Map.Entry<Point, Field> field : fields.entrySet()) {
|
||||||
|
@ -45,11 +68,6 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
return view.toString();
|
return view.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: Add fields, constructors and methods as you see fit. Do NOT change the signature
|
|
||||||
// of the methods below.
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fields associated with the specified dice value.
|
* Returns the fields associated with the specified dice value.
|
||||||
*
|
*
|
||||||
|
@ -66,14 +84,20 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the Resources which are payed to a specific faction for a specific field.
|
||||||
|
*
|
||||||
|
* @param point The Point with the Coordinates of the field, which should pay resources.
|
||||||
|
* @param faction The faction, which should get paied.
|
||||||
|
* @return a ArrayList with all resources, which will be paied to the specified faction.
|
||||||
|
*/
|
||||||
public ArrayList<Config.Resource> getResourcesforFaction(Point point, Config.Faction faction){
|
public ArrayList<Config.Resource> getResourcesforFaction(Point point, Config.Faction faction){
|
||||||
List <Settlement> possibleSettlementField = super.getCornersOfField(point);
|
List <Settlement> possibleSettlementField = super.getCornersOfField(point);
|
||||||
ArrayList<Config.Resource> resourcesToPlayer = new ArrayList<>();
|
ArrayList<Config.Resource> resourcesToPlayer = new ArrayList<>();
|
||||||
for (Structure structure : possibleSettlementField) {
|
for (Settlement settlement : possibleSettlementField) {
|
||||||
if (structure.getFaction() == faction) {
|
if (settlement.getFaction() == faction) {
|
||||||
resourcesToPlayer.add(fields.get(point).getResource());
|
resourcesToPlayer.add(fields.get(point).getResource());
|
||||||
if (structure instanceof City) {
|
if (settlement instanceof City) {
|
||||||
resourcesToPlayer.add(fields.get(point).getResource());
|
resourcesToPlayer.add(fields.get(point).getResource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue