Sha256: a831846b2f8ce9b9146ad50235a5df9dd3c87fe0702085640e6cbf6a08a6e890

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

Gamefic.script do
  respond :leave, Use.parent do |actor, thing|
    actor.tell "There's no way out of #{the thing}."
  end

  respond :leave, Use.parent(Enterable, :enterable?) do |actor, thing|
    actor.tell "You leave #{the thing}."
    actor.parent = thing.parent
  end

  respond :leave, Use.parent(Supporter, :enterable?) do |actor, thing|
    actor.tell "You get off #{the thing}."
    actor.parent = thing.parent
  end

  respond :leave, Use.room do |actor, room|
    portals = room.children.that_are(Portal)
    if portals.length == 0
      actor.tell "You don't see any obvious exits."
    elsif portals.length == 1
      actor.perform :go, portals[0]
    else
      actor.tell "I don't know which way you want to go: #{portals.join_or}."
    end
  end

  respond :leave do |actor|
    actor.perform :leave, actor.parent
  end

  respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
    actor.perform :open, container
    actor.proceed if container.open?
  end

  interpret "exit", "leave"
  interpret "exit :supporter", "leave :supporter"
  interpret "get on :supporter", "enter :supporter"
  interpret "get off :supporter", "leave :supporter"
  interpret "get out :container", "leave :container"
  interpret "get out of :container", "leave :container"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamefic-standard-2.3.0 lib/gamefic-standard/actions/leave.rb