Class ChestInteractor

java.lang.Object
com.mg105.use_cases.ChestInteractor

public class ChestInteractor extends Object
A class that interacts with TreasureChests.

ChestInteractor can remove items from nearby unopened TreasureChests and add them to the inventory.

  • 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

      public TreasureChest compareLists(Point coordinates, List<TreasureChest> chests)
      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

      public TreasureChest 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.