ActionSaveGame.ts 1010 B

123456789101112131415161718192021222324252627282930
  1. /// <reference path="../Action.ts" />
  2. /// <reference path="../../../Elements/Modules/HyperlinkHandler.ts" />
  3. class ActionSaveGame extends Action {
  4. public requiresTurn = false;
  5. public requiresNoun = false;
  6. public requiresVisibility = false;
  7. public static check : Rulebook<ActionSaveGame> = new Rulebook("Check Saving");
  8. public static carry : Rulebook<ActionSaveGame> = new Rulebook("Carry out Saving");
  9. public getCommandText () {
  10. return "save to file";
  11. }
  12. }
  13. ActionSaveGame.carry.addRule(new Rule({
  14. name : "Save the game",
  15. code : runner => {
  16. SaveHandler.saveToFile();
  17. runner.noun.say.add("Saved.");
  18. }
  19. }));
  20. Elements.HyperlinkHandler.CommonActionsRulebook.addRule(new Rule({
  21. name : "Add Save Command Rule",
  22. firstPriority : Rule.PRIORITY_LOWEST,
  23. priority : Rule.PRIORITY_LOWEST,
  24. code : (rulebook : RulebookRunner<void>) => {
  25. Elements.HyperlinkHandler.addCommonAction("Save", new ActionSaveGame(WorldState.player));
  26. }
  27. }));