Gamefic::What

A Gamefic extension for expanding commands with an additional argument.

This extension is included in gamefic-standard.

Installation

Add the library to your Gamefic project's Gemfile:

gem 'gamefic-what'

Run bundle install.

Add the requirement to your project's code (typically in main.rb):

require 'gamefic-what'

Usage

Example code:

class MyPlot < Gamefic::Plot
  include Gamefic::What

  attr_seed :room, Gamefic::Entity, name: 'room'
  attr_seed :thing, Gamefic::Entity, name: 'thing'

  introduction do |actor|
    actor.parent = room
    thing.parent = room
  end

  respond :take, available do |actor, thing|
    thing.parent = actor
    actor.tell "You take #{thing}."
  end

  respond :take do |actor|
    actor.tell 'What do you want to take?'
    actor.cue AskForWhat, template: 'take __what__'
  end
end

Example gameplay:

> take
What do you want to take?
> the thing
You take the thing.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gamefic-what.