Class: Frostbitten::Player

Inherits:
Hashie::Trash
  • Object
show all
Defined in:
lib/frostbitten/player.rb

Overview

Class to repesent a player object returned by server

Class Method Summary collapse

Class Method Details

.players_from_list(list, index) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/frostbitten/player.rb', line 7

def players_from_list(list,index)
	key_count = list.slice!(index).to_i
	keys = list.slice!(index,key_count)
	player_count = list.slice!(index).to_i

	return [].tap do |players|
		{}.tap do |player|
			if player_count > 0
				list.slice!(index,player_count*key_count).each_slice(key_count) do |player_values|
					player_values.each_with_index { |value,index| player[keys[index]] = value }
					players << Player.new(player)
				end
			end
		end
	end
end