Package org.progettoedids.labyrinth
Class Labyrinth.Builder
java.lang.Object
org.progettoedids.labyrinth.Labyrinth.Builder
- Enclosing class:
Labyrinth
It's the class responsible for Building a fully configured Labyrinth in a valid state.
It can be obtained using the Labyrinth method newBuilder() and then needs to be properly configured in order for the Labyrinth to be built. A "properly configured" Labyrinth.Builder must verify the following conditions: - It has a name set - It has a difficulty set - It has a random number generator seed set - It has its dimensions set - A number of Room(s) all located at different Position(s) must be added. Such a number must match Dimensions.getWidth()*Dimensions.getHeight() of the Dimensions set - One and only one Player has been added
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an Entity to the Room located at the supplied PositionvoidAdds a Room to the Room matrix at the specified Positionbuild()Builds and returns the Labyrinth based on the state set by calling the set-/add- method families of the Builder.getName()voidsetDifficulty(Difficulty difficulty) Sets the Difficulty enumerator of the Labyrinth If the Difficulty was already set it's overwritten with the new one.voidsetDimensions(Dimensions dimensions) Sets the Dimensions of the Labyrinth If the Dimensions object was already set it's overwritten with the new one.voidSets the name of the Labyrinth.voidsetRandomGeneratorSeed(long randomGeneratorSeed)
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
setName
Sets the name of the Labyrinth. If the name was already set it's overwritten with the new one.- Parameters:
name- String with the name to set. Must not be null
-
setDifficulty
Sets the Difficulty enumerator of the Labyrinth If the Difficulty was already set it's overwritten with the new one.- Parameters:
difficulty- the Difficulty enumerator to set. Must not be null
-
setRandomGeneratorSeed
public void setRandomGeneratorSeed(long randomGeneratorSeed) -
setDimensions
Sets the Dimensions of the Labyrinth If the Dimensions object was already set it's overwritten with the new one.- Parameters:
dimensions- the Dimensions object to set. Must not be null
-
addRoom
-
addEntity
-
getName
-
getDifficulty
-
getRandomGeneratorSeed
-
getDimensions
-
build
Builds and returns the Labyrinth based on the state set by calling the set-/add- method families of the Builder.- Returns:
- a configured and legal Labyrinth
-