Class: Wc3Protocol::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/wc3_protocol/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_msg:, raw_sender_info:) ⇒ Message

Returns a new instance of Message.



38
39
40
# File 'lib/wc3_protocol/message.rb', line 38

def initialize(raw_msg:, raw_sender_info:)
  _parse_message raw_msg, raw_sender_info
end

Instance Attribute Details

#game_computer_or_closed_slotsObject (readonly)

Returns the value of attribute game_computer_or_closed_slots.



32
33
34
# File 'lib/wc3_protocol/message.rb', line 32

def game_computer_or_closed_slots
  @game_computer_or_closed_slots
end

#game_filled_slotsObject (readonly)

Returns the value of attribute game_filled_slots.



34
35
36
# File 'lib/wc3_protocol/message.rb', line 34

def game_filled_slots
  @game_filled_slots
end

#game_flagsObject (readonly)

Returns the value of attribute game_flags.



29
30
31
# File 'lib/wc3_protocol/message.rb', line 29

def game_flags
  @game_flags
end

#game_idObject (readonly)

Returns the value of attribute game_id.



20
21
22
# File 'lib/wc3_protocol/message.rb', line 20

def game_id
  @game_id
end

#game_map_heightObject (readonly)

Returns the value of attribute game_map_height.



27
28
29
# File 'lib/wc3_protocol/message.rb', line 27

def game_map_height
  @game_map_height
end

#game_map_nameObject (readonly)

attr_reader :zero_flag



25
26
27
# File 'lib/wc3_protocol/message.rb', line 25

def game_map_name
  @game_map_name
end

#game_map_widthObject (readonly)

Returns the value of attribute game_map_width.



26
27
28
# File 'lib/wc3_protocol/message.rb', line 26

def game_map_width
  @game_map_width
end

#game_nameObject (readonly)

Returns the value of attribute game_name.



23
24
25
# File 'lib/wc3_protocol/message.rb', line 23

def game_name
  @game_name
end

#game_non_computer_slotsObject (readonly)

Returns the value of attribute game_non_computer_slots.



31
32
33
# File 'lib/wc3_protocol/message.rb', line 31

def game_non_computer_slots
  @game_non_computer_slots
end

#game_number_of_slotsObject (readonly)

Returns the value of attribute game_number_of_slots.



28
29
30
# File 'lib/wc3_protocol/message.rb', line 28

def game_number_of_slots
  @game_number_of_slots
end

#game_player_slotsObject (readonly)

Returns the value of attribute game_player_slots.



30
31
32
# File 'lib/wc3_protocol/message.rb', line 30

def game_player_slots
  @game_player_slots
end

#game_portObject (readonly)

attr_reader :unknown_byte



36
37
38
# File 'lib/wc3_protocol/message.rb', line 36

def game_port
  @game_port
end

#game_remaining_slotsObject (readonly)

Returns the value of attribute game_remaining_slots.



33
34
35
# File 'lib/wc3_protocol/message.rb', line 33

def game_remaining_slots
  @game_remaining_slots
end

#game_settingsObject (readonly)

Returns the value of attribute game_settings.



22
23
24
# File 'lib/wc3_protocol/message.rb', line 22

def game_settings
  @game_settings
end

#game_typeObject (readonly)

Returns the value of attribute game_type.



18
19
20
# File 'lib/wc3_protocol/message.rb', line 18

def game_type
  @game_type
end

#game_versionObject (readonly)

Returns the value of attribute game_version.



19
20
21
# File 'lib/wc3_protocol/message.rb', line 19

def game_version
  @game_version
end

#magic_byteObject (readonly)

Returns the value of attribute magic_byte.



15
16
17
# File 'lib/wc3_protocol/message.rb', line 15

def magic_byte
  @magic_byte
end

#op_codeObject (readonly)

Returns the value of attribute op_code.



16
17
18
# File 'lib/wc3_protocol/message.rb', line 16

def op_code
  @op_code
end

#packet_sizeObject (readonly)

Returns the value of attribute packet_size.



17
18
19
# File 'lib/wc3_protocol/message.rb', line 17

def packet_size
  @packet_size
end

#raw_bytesObject (readonly)

Returns the value of attribute raw_bytes.



12
13
14
# File 'lib/wc3_protocol/message.rb', line 12

def raw_bytes
  @raw_bytes
end

#raw_bytes_hexObject (readonly)

Returns the value of attribute raw_bytes_hex.



13
14
15
# File 'lib/wc3_protocol/message.rb', line 13

def raw_bytes_hex
  @raw_bytes_hex
end

#sender_address_familyObject (readonly)

Returns the value of attribute sender_address_family.



7
8
9
# File 'lib/wc3_protocol/message.rb', line 7

def sender_address_family
  @sender_address_family
end

#sender_hostnameObject (readonly)

Returns the value of attribute sender_hostname.



9
10
11
# File 'lib/wc3_protocol/message.rb', line 9

def sender_hostname
  @sender_hostname
end

#sender_ip_addressObject (readonly)

Returns the value of attribute sender_ip_address.



10
11
12
# File 'lib/wc3_protocol/message.rb', line 10

def sender_ip_address
  @sender_ip_address
end

#sender_portObject (readonly)

Returns the value of attribute sender_port.



8
9
10
# File 'lib/wc3_protocol/message.rb', line 8

def sender_port
  @sender_port
end

#tick_counts_msObject (readonly)

Returns the value of attribute tick_counts_ms.



21
22
23
# File 'lib/wc3_protocol/message.rb', line 21

def tick_counts_ms
  @tick_counts_ms
end

Instance Method Details

#battle_net?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/wc3_protocol/message.rb', line 46

def battle_net?
  @magic_byte == 'ff'
end

#lan?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/wc3_protocol/message.rb', line 42

def lan?
  !battle_net?
end