StickyNote.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. package cz.davza.studentadventure.Items;
  2. import cz.davza.studentadventure.base.ItemBase;
  3. import cz.davza.studentadventure.interfaces.IInteractable;
  4. import cz.davza.studentadventure.objects.CommandResult;
  5. import cz.davza.studentadventure.objects.GameData;
  6. /**
  7. * A sticky note left in a room, containing a readable message.
  8. *
  9. * <p>Interacting with the note prints its contents. Notes are not collectable
  10. * and stay in the room permanently. Max stack of 1 (each note is unique).</p>
  11. *
  12. * <p>Used throughout the world to hint at passwords, lore, and jokes.</p>
  13. */
  14. public class StickyNote extends ItemBase implements IInteractable {
  15. private final String note;
  16. /**
  17. * Creates a sticky note with the given message text.
  18. *
  19. * @param note the text written on the note
  20. */
  21. public StickyNote(String note) {
  22. super("Sticky Note", "A sticky note with scribbled text. You may be able to just read it", "sticky_note", 1);
  23. this.note = note;
  24. }
  25. /**
  26. * {@inheritDoc}
  27. * Prints the note's message to {@code System.out}.
  28. */
  29. @Override
  30. public CommandResult Interact(GameData context) {
  31. return CommandResult.success("You lean in to read the note. \n It reads: \n " + note + "\n");
  32. }
  33. }