Class: Openra::Replays::Order

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/openra/replays/order.rb

Overview

Constant Summary collapse

HEX_FE =
?\xFE.dup.force_encoding('ASCII-8BIT').freeze
HEX_FF =
?\xFF.dup.force_encoding('ASCII-8BIT').freeze
IS_STANDARD_ORDER =
-> { order_type == HEX_FF }
IS_IMMEDIATE_ORDER =
-> { order_type == HEX_FE }
HAS_TARGET =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x01) == 0x01 }
HAS_EXTRA_ACTORS =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x02) == 0x02 }
TARGET_IS_ACTOR =
-> { instance_exec(&HAS_TARGET) && target_type == 1 }
TARGET_IS_TERRAIN =
-> { instance_exec(&HAS_TARGET) && target_type == 2 }
TARGET_IS_FROZEN_ACTOR =
-> { instance_exec(&HAS_TARGET) && target_type == 3 }
TARGET_IS_CELL =
-> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 0x40) == 0x40 }
TARGET_NOT_CELL =
-> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 0x40) != 0x40 }
HAS_SUBJECT =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x80) == 0x80 }
HAS_TARGET_STRING =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x04) == 0x04 }
HAS_EXTRA_LOCATION =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x10) == 0x10 }
HAS_EXTRA_DATA =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x20) == 0x20 }
IS_GROUPED =

IS_QUEUED = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x08) == 0x08 }

-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x100) == 0x100 }

Instance Method Summary collapse

Instance Method Details

#immediate?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/openra/replays/order.rb', line 69

def immediate?
  type == :immediate
end

#queued?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/openra/replays/order.rb', line 73

def queued?
  flags & 8 == 8
end

#standard?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/openra/replays/order.rb', line 65

def standard?
  type == :standard
end

#targetObject



52
53
54
# File 'lib/openra/replays/order.rb', line 52

def target
  standard? ? standard_order_target : immediate_order_target
end

#typeObject



56
57
58
59
60
61
62
63
# File 'lib/openra/replays/order.rb', line 56

def type
  case order_type
  when HEX_FF
    :standard
  when HEX_FE
    :immediate
  end
end