Minor Grammar and Cameltow fixes
This commit is contained in:
@@ -2,7 +2,8 @@ package ch.zhaw.catan;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
//TODO Java Doc bearbeiten
|
||||
//TODO Java Doc
|
||||
|
||||
/**
|
||||
* New Class PLayer
|
||||
* This class is here in order to maintain the resources of the players, the amount of structures that they can build,
|
||||
@@ -20,14 +21,14 @@ public class Player {
|
||||
* @param faction this is the faction of the player.
|
||||
*/
|
||||
public Player(Config.Faction faction) {
|
||||
//Datafields
|
||||
//Data fields
|
||||
this.faction = faction;
|
||||
//Available Structures initialize
|
||||
//Initialize available structures
|
||||
structureToUse = new HashMap<>();
|
||||
structureToUse.put(Config.Structure.ROAD, Config.Structure.ROAD.getStockPerPlayer());
|
||||
structureToUse.put(Config.Structure.SETTLEMENT, Config.Structure.SETTLEMENT.getStockPerPlayer());
|
||||
structureToUse.put(Config.Structure.CITY, Config.Structure.CITY.getStockPerPlayer());
|
||||
//Resources initialize
|
||||
//Initialize resources
|
||||
resources = new HashMap<>();
|
||||
for (Config.Resource resource : Config.Resource.values()) {
|
||||
resources.put(resource, 0);
|
||||
@@ -73,18 +74,18 @@ public class Player {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method substracts a specific resource from resourcess but check first if player has enough resources.
|
||||
* This method subtracts a specific resource from the player's resources. but check first if player has the specific resources.
|
||||
*
|
||||
* @param resource to substract
|
||||
* @param numberToSubstract how much to substract
|
||||
* @return true if resource has been substracted false if player has not enough resources
|
||||
* @param resource to subtract
|
||||
* @param numberToSubtract how much to subtract
|
||||
* @return true if resource has been subtracted false if player has not enough resources
|
||||
*/
|
||||
public boolean substractResource(Config.Resource resource, int numberToSubstract) {
|
||||
int inPossesion = resources.get(resource);
|
||||
if (inPossesion - numberToSubstract < 0) {
|
||||
public boolean subtractResource(Config.Resource resource, int numberToSubtract) {
|
||||
int inPossession = resources.get(resource);
|
||||
if (inPossession - numberToSubtract < 0) {
|
||||
return false;
|
||||
}
|
||||
resources.put(resource, inPossesion - numberToSubstract);
|
||||
resources.put(resource, inPossession - numberToSubtract);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,6 +94,7 @@ public class Player {
|
||||
* and resources to build one more. If the player is able to build, this method subtracts the building cost from the resources
|
||||
* in possession by the player.
|
||||
* It reduces the amount of the specific structure a player can build by 1.
|
||||
*
|
||||
* @return true if the structure can be created false if the structure can't be created.
|
||||
*/
|
||||
public boolean build(Config.Structure structure) {
|
||||
|
||||
Reference in New Issue
Block a user