HelpCommand.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package cz.davza.studentadventure.commands;
  2. import cz.davza.studentadventure.annotations.CommandKeyword;
  3. import cz.davza.studentadventure.base.CommandBase;
  4. import cz.davza.studentadventure.objects.CommandResult;
  5. import cz.davza.studentadventure.objects.GameData;
  6. /**
  7. * Displays the full command reference for the game.
  8. *
  9. * <p>Usage: {@code help}</p>
  10. *
  11. * <p>Prints a static list of every command keyword and a short description of
  12. * what it does. Available in all rooms. No parameters are required.</p>
  13. */
  14. @CommandKeyword("help")
  15. public class HelpCommand extends CommandBase {
  16. /**
  17. * {@inheritDoc}
  18. * Returns the full command reference as a formatted string.
  19. */
  20. @Override
  21. public CommandResult Execute(GameData context) {
  22. return CommandResult.success(printHelp());
  23. }
  24. /**
  25. * Builds and returns the command reference text.
  26. *
  27. * @return a multi-line string listing all available commands and their usage
  28. */
  29. private String printHelp() {
  30. return """
  31. === COMMANDS ===
  32. walk <exit> - Move to another room
  33. pickup <item> <n> - Pick up n of an item
  34. drop <slot> - Drop item from inventory slot
  35. interact <item> - Interact with an item
  36. study <hours> - Study for n hours
  37. sleep - Sleep (bedroom and classroom only)
  38. steal - Steal money (study room only)
  39. buy <item> - Buy an item (shop only)
  40. consume <slot> - Consume an item from inventory
  41. takeexam - Take the final exam (exam room only)
  42. inventory - Show your inventory
  43. stats - Show your stats
  44. time - Show current game time
  45. describe - Describe the current scene
  46. quit - Give up
  47. studentId - Tells you your student ID (computer only)
  48. availablecommands - Tells you your currently available commands
  49. """;
  50. }
  51. }