Create interface goals with 4 sub-goals checking that a player has fulfilled
closes: #7 (closed)
What are the key features of this change
The Goal interface has a method isFulfilled
. This method can be called on a player to check if the player's attributes have achieved a certain goal. Each goal that implements this interface has a constructor which sets the value to check the player with. When the isFulfilled
method is called, it returns some boolean value representing if the player has the goal fulfilled. The isFulfilled
method can be called several times on the same player.
Actions added:
-
HealthGoal: Uses the player's
getHealth
method to retrieve the player's health. -
ScoreGoal: Uses the player's
getScore
method to retrieve the player's score. -
GoldGoal: Uses the player's
getGold
method to retrieve the player's gold. - InventoryAddGoal: Adds a non-null and non-blank String to the players inventory. Uses the addToInventory method
Tests for all goals have been added and are seperated into two files. One for the first three which uses integer checking and a second for testing inventory. Player tests were also modified as score can now be negative.
Checklist
-
Javadoc -
Relevant tests have been created -
Build tool test passed -
Class version is updated where relevant
Edited by Carl Gützkow