Module: Gamefic::Plot::CommandMount
- Defined in:
- lib/gamefic/plot/command_mount.rb
Instance Method Summary collapse
- #action(command, *queries, &proc) ⇒ Object deprecated Deprecated.
-
#actions ⇒ Array<Action>
Get an Array of all Actions defined in the Plot.
-
#disambiguate {|, | ... } ⇒ Object
Declare a dismabiguation response for actions.
-
#interpret(command, translation) ⇒ Syntax
Create an alternate Syntax for an Action.
-
#meta(command, *queries) {|| ... } ⇒ Object
Create a Meta Action that responds to a command.
-
#respond(command, *queries) {|| ... } ⇒ Object
Create an Action that responds to a command.
-
#validate {|| ... } ⇒ Object
Validate an order before a character can execute its command.
-
#verbs(to_s: false) ⇒ Array<Symbol|String>
Get an Array of available verbs.
- #xlate(command, translation) ⇒ Object deprecated Deprecated.
Instance Method Details
#action(command, *queries, &proc) ⇒ Object
52 53 54 |
# File 'lib/gamefic/plot/command_mount.rb', line 52 def action(command, *queries, &proc) respond command, *queries, &proc end |
#actions ⇒ Array<Action>
Get an Array of all Actions defined in the Plot.
116 117 118 |
# File 'lib/gamefic/plot/command_mount.rb', line 116 def actions playbook.actions end |
#disambiguate {|, | ... } ⇒ Object
Declare a dismabiguation response for actions. The disambigurator is executed when an action expects an argument to reference a specific entity but its query matched more than one. For example, “red” might refer to either a red key or a red book.
If a disambiguator is not defined, the playbook will use its default implementation.
71 72 73 |
# File 'lib/gamefic/plot/command_mount.rb', line 71 def disambiguate &block playbook.disambiguate &block end |
#interpret(command, translation) ⇒ Syntax
Create an alternate Syntax for an Action. The command and its translation can be parameterized.
96 97 98 |
# File 'lib/gamefic/plot/command_mount.rb', line 96 def interpret command, translation playbook.interpret command, translation end |
#meta(command, *queries) {|| ... } ⇒ Object
Create a Meta Action that responds to a command. Meta Actions are very similar to standard Actions, except the Plot understands them to be commands that operate above and/or outside of the actual game world. Examples of Meta Actions are commands that report the player’s current score, save and restore saved games, or list the game’s credits.
47 48 49 |
# File 'lib/gamefic/plot/command_mount.rb', line 47 def (command, *queries, &proc) playbook. command, *queries, &proc end |
#respond(command, *queries) {|| ... } ⇒ Object
Create an Action that responds to a command. An Action uses the command argument to identify the imperative verb that triggers the action. It can also accept queries to tokenize the remainder of the input and filter for particular entities or properties. The block argument contains the code to be executed when the input matches all of the Action’s criteria (i.e., verb and queries).
28 29 30 |
# File 'lib/gamefic/plot/command_mount.rb', line 28 def respond(command, *queries, &proc) playbook.respond(command, *queries, &proc) end |
#validate {|| ... } ⇒ Object
Validate an order before a character can execute its command.
78 79 80 |
# File 'lib/gamefic/plot/command_mount.rb', line 78 def validate &block playbook.validate &block end |
#verbs(to_s: false) ⇒ Array<Symbol|String>
Get an Array of available verbs. If the to_s parameter is true, convert Symbols to Strings.
109 110 111 |
# File 'lib/gamefic/plot/command_mount.rb', line 109 def verbs to_s: false to_s ? playbook.verbs.map { |v| v.to_s } : playbook.verbs end |
#xlate(command, translation) ⇒ Object
101 102 103 |
# File 'lib/gamefic/plot/command_mount.rb', line 101 def xlate command, translation interpret command, translation end |