Class ResourceSpecification
java.lang.Object
com.deco2800.game.areas.MapGenerator.ResourceSpecification
-
Constructor Summary
ConstructorsConstructorDescriptionResourceSpecification(String name, int width, int height, int minAmount, int maxAmount, int preferredDistance) Creates a new ResourceSpecification with desired placement information within the game -
Method Summary
Modifier and TypeMethodDescriptionvoidAssociates this ResourceSpecification with a tile of the map to be placed onbooleanReturns true if this ResourceSpecification is equal to the passed object For two ResourceSpecifications to be equal they must have the same: - Name - Width - Height - Amount - Preferred distance - PlacementsintReturns the amount of this resource to add to the gameintReturns the height of this resource (in tiles)intReturns the maximum amount of this resource that can be added to the gameintReturns the minimum amount of this resource that can be added to the gamegetName()Returns the name of the resourceGetter method to return all the tile locations that this resource has been placed atGetter method to return all the tile locations that this resource may be placed atintReturns the preferredDistance of this resource from the city centreintReturns how many more of this resource must be placed by the ResourceGeneratorintgetWidth()Returns the width of this resource (in tiles)inthashCode()voidEmpties the placements and potential placements lists, when Map must be re-generatedvoidRandomly sets a number of resources to add to the game based on maxAmount and minAmounttoString()Returns human-readable form of a ResourceSpecification used for testingvoidupdatePotentialPlacements(List<Coordinate> newPotentialPlacements) Sets a new list of potential placements for this resource on the map
-
Constructor Details
-
ResourceSpecification
public ResourceSpecification(String name, int width, int height, int minAmount, int maxAmount, int preferredDistance) Creates a new ResourceSpecification with desired placement information within the game- Parameters:
name- Name of the resourcewidth- tile side length of resourceheight- tile height of resourceminAmount- Minimum amount of this resource the game should addmaxAmount- Maximum amount of this resource the game should addpreferredDistance- Preferred proximity to the city (smaller -> closer)- Requires:
- minAmount is less than maxAmount
-
-
Method Details
-
getPlacements
Getter method to return all the tile locations that this resource has been placed at- Returns:
- the placements list of coordinates for this resource
-
getPotentialPlacements
Getter method to return all the tile locations that this resource may be placed at- Returns:
-
getWidth
public int getWidth()Returns the width of this resource (in tiles)- Returns:
- Width of resource
-
getHeight
public int getHeight()Returns the height of this resource (in tiles)- Returns:
- Height of resource
-
getAmount
public int getAmount()Returns the amount of this resource to add to the game- Returns:
- amount of this resource to add
-
getMaxAmount
public int getMaxAmount()Returns the maximum amount of this resource that can be added to the game- Returns:
- maximum amount of resource that may be added
-
getMinAmount
public int getMinAmount()Returns the minimum amount of this resource that can be added to the game- Returns:
- minimum amount of the resource that may be added
-
setNewAmount
public void setNewAmount()Randomly sets a number of resources to add to the game based on maxAmount and minAmount -
getPreferredDistance
public int getPreferredDistance()Returns the preferredDistance of this resource from the city centre- Returns:
- preferredDistance
-
getName
Returns the name of the resource- Returns:
- name of the resource
-
addPlacement
Associates this ResourceSpecification with a tile of the map to be placed on- Parameters:
c- Coordinate of the tile to place this resource
-
updatePotentialPlacements
Sets a new list of potential placements for this resource on the map- Parameters:
newPotentialPlacements- the new places where this tile may be validly placed
-
resetPlacements
public void resetPlacements()Empties the placements and potential placements lists, when Map must be re-generated -
getRemainingPlacements
public int getRemainingPlacements()Returns how many more of this resource must be placed by the ResourceGenerator- Returns:
- how many more of this resource that must be placed
-
toString
Returns human-readable form of a ResourceSpecification used for testing -
equals
Returns true if this ResourceSpecification is equal to the passed object For two ResourceSpecifications to be equal they must have the same: - Name - Width - Height - Amount - Preferred distance - Placements -
hashCode
public int hashCode()
-