Class ResourceSpecification

java.lang.Object
com.deco2800.game.areas.MapGenerator.ResourceSpecification

public class ResourceSpecification extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceSpecification(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 Type
    Method
    Description
    void
    Associates this ResourceSpecification with a tile of the map to be placed on
    boolean
    equals(Object other)
    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
    int
    Returns the amount of this resource to add to the game
    int
    Returns the height of this resource (in tiles)
    int
    Returns the maximum amount of this resource that can be added to the game
    int
    Returns the minimum amount of this resource that can be added to the game
    Returns the name of the resource
    Getter method to return all the tile locations that this resource has been placed at
    Getter method to return all the tile locations that this resource may be placed at
    int
    Returns the preferredDistance of this resource from the city centre
    int
    Returns how many more of this resource must be placed by the ResourceGenerator
    int
    Returns the width of this resource (in tiles)
    int
     
    void
    Empties the placements and potential placements lists, when Map must be re-generated
    void
    Randomly sets a number of resources to add to the game based on maxAmount and minAmount
    Returns human-readable form of a ResourceSpecification used for testing
    void
    updatePotentialPlacements(List<Coordinate> newPotentialPlacements)
    Sets a new list of potential placements for this resource on the map

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 resource
      width - tile side length of resource
      height - tile height of resource
      minAmount - Minimum amount of this resource the game should add
      maxAmount - Maximum amount of this resource the game should add
      preferredDistance - Preferred proximity to the city (smaller -> closer)
      Requires:
      minAmount is less than maxAmount
  • Method Details

    • getPlacements

      public List<Coordinate> 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

      public List<Coordinate> 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

      public String getName()
      Returns the name of the resource
      Returns:
      name of the resource
    • addPlacement

      public void addPlacement(Coordinate c)
      Associates this ResourceSpecification with a tile of the map to be placed on
      Parameters:
      c - Coordinate of the tile to place this resource
    • updatePotentialPlacements

      public void updatePotentialPlacements(List<Coordinate> newPotentialPlacements)
      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

      public String toString()
      Returns human-readable form of a ResourceSpecification used for testing
      Overrides:
      toString in class Object
      Returns:
      human-readable string of a ResourceSpecification
    • equals

      public boolean equals(Object other)
      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
      Overrides:
      equals in class Object
      Parameters:
      other - the reference object with which to compare
      Returns:
      true if this scenario is the same as the other argument; false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object