Class: GameInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/messages/game_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr = {}) ⇒ GameInfo

Returns a new instance of GameInfo.



8
9
10
11
12
13
14
# File 'lib/messages/game_info.rb', line 8

def initialize(attr = {})
  @game_flags = attr[:game_flags] || 0
  @score_limit = attr[:score_limit] || 0
  @time_limit = attr[:time_limit] || 0
  @match_num = attr[:match_num] || 0
  @match_current = attr[:match_current] || 0
end

Instance Attribute Details

#game_flagsObject

Returns the value of attribute game_flags.



6
7
8
# File 'lib/messages/game_info.rb', line 6

def game_flags
  @game_flags
end

#match_currentObject

Returns the value of attribute match_current.



6
7
8
# File 'lib/messages/game_info.rb', line 6

def match_current
  @match_current
end

#match_numObject

Returns the value of attribute match_num.



6
7
8
# File 'lib/messages/game_info.rb', line 6

def match_num
  @match_num
end

#score_limitObject

Returns the value of attribute score_limit.



6
7
8
# File 'lib/messages/game_info.rb', line 6

def score_limit
  @score_limit
end

#time_limitObject

Returns the value of attribute time_limit.



6
7
8
# File 'lib/messages/game_info.rb', line 6

def time_limit
  @time_limit
end

Instance Method Details

#to_aObject

basically to_network int array the server sends to the client



18
19
20
21
22
23
24
# File 'lib/messages/game_info.rb', line 18

def to_a
  Packer.pack_int(@game_flags) +
    Packer.pack_int(@score_limit) +
    Packer.pack_int(@time_limit) +
    Packer.pack_int(@match_num) +
    Packer.pack_int(@match_current)
end