class ScottKit::Game::Condition

Invoked from Instruction.execute()

Public Instance Methods

evaluate() click to toggle source
# File lib/scottkit/play.rb, line 375
def evaluate
  loc = @game.loc
  item = @game.items[@value]
  case @cond
  when  0 then raise "unexpected condition code 0"
  when  1 then item.loc == ROOM_CARRIED
  when  2 then item.loc == loc
  when  3 then item.loc == ROOM_CARRIED || item.loc == loc
  when  4 then loc == @value
  when  5 then item.loc != loc
  when  6 then item.loc != ROOM_CARRIED
  when  7 then loc != @value
  when  8 then @game.flags[@value]
  when  9 then !@game.flags[@value]
  when 10 then @game.ncarried != 0
  when 11 then @game.ncarried == 0
  when 12 then item.loc != ROOM_CARRIED && item.loc != loc
  when 13 then item.loc != ROOM_NOWHERE
  when 14 then item.loc == ROOM_NOWHERE
  when 15 then @game.counter <= @value
  when 16 then @game.counter > @value
  when 17 then item.loc == item.startloc
  when 18 then item.loc != item.startloc
    # From the description, it seems that perhaps "moved" should
    # be true if the object has EVER been moved; but the ScottFree
    # code implements it as I have done here.
  when 19 then @game.counter == @value
  else raise "unimplemented condition code #@cond"
  end
end
quote(*args) click to toggle source
# File lib/scottkit/decompile.rb, line 126
def quote(*args); @game.quote(*args); end
render() click to toggle source
# File lib/scottkit/decompile.rb, line 128
def render
  type = OPS[@cond][1]
  res = OPS[@cond][0]
  res += " " +
    quote(type == :room ? @game.roomname(@value) :
          type == :item ? @game.itemname(@value) :
          type == :number ? String(@value) : "ERROR") if
    type != :NONE
  res
end