SiedlerGame throwDice method implemented (for 7 not yet implemented) and method getResourcesforFaction implemented in SiedlerBoard
This commit is contained in:
parent
8b2b9e2882
commit
7129435fea
|
@ -26,7 +26,7 @@ public class Parser {
|
|||
}
|
||||
|
||||
public void displayPlayerInfo(HashMap<Config.Resource, Integer> currentPlayerResource, int winpoints){
|
||||
textTerminal.println("You are currently holding" + winpoints + " winpoints.");
|
||||
textTerminal.println("You are currently holding " + winpoints + " winpoints.");
|
||||
textTerminal.println("You own the follwing resources:");
|
||||
for(Config.Resource resource : currentPlayerResource.keySet()){
|
||||
textTerminal.println(resource.name() + ":" + currentPlayerResource.get(resource));
|
||||
|
|
|
@ -66,6 +66,21 @@ public class SiedlerBoard extends HexBoard<Land, Settlement, Road, String> {
|
|||
return fields;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Config.Resource> getResourcesforFaction(Point point, Config.Faction faction){
|
||||
List <Settlement> possibleSettlementField = super.getCornersOfField(point);
|
||||
ArrayList<Config.Resource> resourcesToPlayer = new ArrayList<>();
|
||||
for (Structure structure : possibleSettlementField) {
|
||||
if (structure.getFaction() == faction) {
|
||||
resourcesToPlayer.add(fields.get(point).getResource());
|
||||
if (structure instanceof City) {
|
||||
resourcesToPlayer.add(fields.get(point).getResource());
|
||||
}
|
||||
}
|
||||
}
|
||||
return resourcesToPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Land}s adjacent to the specified corner.
|
||||
*
|
||||
|
|
|
@ -198,8 +198,19 @@ public class SiedlerGame {
|
|||
* @return the resource cards added to the stock of the different players
|
||||
*/
|
||||
public Map<Faction, List<Resource>> throwDice(int dicethrow) {
|
||||
// TODO: Implement
|
||||
return null;
|
||||
Map<Faction,List<Resource>> returnMap= new HashMap<>();
|
||||
List<Point> diceValueFields = board.getFieldsForDiceValue(dicethrow);
|
||||
for (Player player : allPlayers) {
|
||||
returnMap.put(player.getFaction(), new ArrayList());
|
||||
for (Point field : diceValueFields) {
|
||||
List<Resource> resources= board.getResourcesforFaction(field,player.getFaction());
|
||||
for (Config.Resource resource : resources){
|
||||
returnMap.get(player.getFaction()).add(resource);
|
||||
player.addResource(resource,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue