Package com.mg105.use_cases
Class ChestInteractor
java.lang.Object
com.mg105.use_cases.ChestInteractor
A class that interacts with TreasureChests.
ChestInteractor can remove items from nearby unopened TreasureChests and add them to the inventory.
-
Constructor Summary
ConstructorDescriptionChestInteractor
(@NotNull GameState gameState, @NotNull InventoryInteractor interactor, @NotNull RoomUpdaterInterface updater) Creates a ChestInteractor to interact with chests in a GameState. -
Method Summary
Modifier and TypeMethodDescriptioncompareLists
(Point coordinates, List<TreasureChest> chests) Checks if a given spot on the map contains a TreasureChest.void
Adds the item in an adjacent chest (if one exists) to the inventory.Checks if a chest is adjacent to the player character.
-
Constructor Details
-
ChestInteractor
public ChestInteractor(@NotNull @NotNull GameState gameState, @NotNull @NotNull InventoryInteractor interactor, @NotNull @NotNull RoomUpdaterInterface updater) Creates a ChestInteractor to interact with chests in a GameState.- Parameters:
gameState
- the game state.interactor
- the inventory interactor.updater
- the room updater that will be called when the room changes.
-
-
Method Details
-
compareLists
Checks if a given spot on the map contains a TreasureChest.- Parameters:
coordinates
- the coordinates of a specific spot in the Room.chests
- the list of chests in the current Room.- Returns:
- the TreasureChest if chest is found. Otherwise, return null.
-
verifyChest
Checks if a chest is adjacent to the player character.- Returns:
- the TreasureChest if chest is found. Otherwise, return null.
-
getChestItem
public void getChestItem()Adds the item in an adjacent chest (if one exists) to the inventory.
-