Sha256: e69ceeb751bcb03dae0956b49b3ee04ee254786eba6deb962798e1c5d06d2918

Contents?: true

Size: 656 Bytes

Versions: 3

Compression:

Stored size: 656 Bytes

Contents

# @gamefic.script standard/test

module Tester
  def test_procs
    @test_procs ||= Hash.new
  end

  def on_test name = :me, &block
    test_procs[name] = block
  end

  def run_test name, actor
    queue = []
    test_procs[name].call(actor, queue)
    actor.queue.concat queue
  end
end

class Gamefic::Plot
  include Tester
end

class Gamefic::Subplot
  include Tester
end

Gamefic.script do
  meta :test, Gamefic::Query::Text.new do |actor, name|
    sym = name.to_sym
    if test_procs[sym].nil?
      actor.tell "There's no test named '#{name}' in this game."
    else
      run_test sym, actor
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gamefic-standard-2.2.0 lib/gamefic-standard/test.rb
gamefic-standard-2.1.0 lib/gamefic-standard/test.rb
gamefic-standard-2.0.0 lib/gamefic-standard/test.rb