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 =

NEED TO LEARN HOW TO READ FLAGS AND TARGET TYPE

-> { order_type == HEX_FF }
IS_IMMEDIATE_ORDER =
-> { order_type == HEX_FE }
HAS_TARGET =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 1) == 1 }
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 & 64) == 64 }
TARGET_NOT_CELL =
-> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 64) != 64 }
HAS_SUBJECT =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 128) == 128 }
HAS_TARGET_STRING =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 4) == 4 }
HAS_EXTRA_LOCATION =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 16) == 16 }
HAS_EXTRA_DATA =
-> { instance_exec(&IS_STANDARD_ORDER) && (flags & 32) == 32 }

Instance Method Summary collapse

Instance Method Details

#immediate?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/openra/replays/order.rb', line 62

def immediate?
  type == :immediate
end

#queued?Boolean

Returns:

  • (Boolean)


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

def queued?
  flags & 8 == 8
end

#standard?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/openra/replays/order.rb', line 58

def standard?
  type == :standard
end

#targetObject



45
46
47
# File 'lib/openra/replays/order.rb', line 45

def target
  standard? ? standard_order_target : immediate_order_target
end

#typeObject



49
50
51
52
53
54
55
56
# File 'lib/openra/replays/order.rb', line 49

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