Module: Gamefic::Plot::CommandMount
- Included in:
- Gamefic::Plot
- Defined in:
- lib/gamefic/plot/command_mount.rb
Instance Method Summary collapse
- #action(command, *queries, &proc) ⇒ Object
- #commandwords ⇒ Object
-
#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.
- #syntax(*args) ⇒ Object
- #xlate(*args) ⇒ Object
Instance Method Details
#action(command, *queries, &proc) ⇒ Object
26 27 28 |
# File 'lib/gamefic/plot/command_mount.rb', line 26 def action(command, *queries, &proc) Action.new(self, command, *queries, &proc) end |
#commandwords ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/gamefic/plot/command_mount.rb', line 78 def commandwords words = Array.new syntaxes.each { |s| word = s.first_word words.push(word) if !word.nil? } words.uniq end |
#interpret(command, translation) ⇒ Syntax
Create an alternate Syntax for an Action. The command and its translation can be parameterized.
68 69 70 |
# File 'lib/gamefic/plot/command_mount.rb', line 68 def interpret command, translation xlate 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.
21 22 23 24 25 |
# File 'lib/gamefic/plot/command_mount.rb', line 21 def (command, *queries, &proc) act = self.action(command, *queries, &proc) act. = true act 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).
51 52 53 |
# File 'lib/gamefic/plot/command_mount.rb', line 51 def respond(command, *queries, &proc) self.action(command, *queries, &proc) end |
#syntax(*args) ⇒ Object
71 72 73 |
# File 'lib/gamefic/plot/command_mount.rb', line 71 def syntax(*args) xlate(*args) end |