Class: StartInfo
- Inherits:
-
Object
- Object
- StartInfo
- Defined in:
- lib/messages/start_info.rb
Overview
StartInfo
Client -> Server
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#clan ⇒ Object
Returns the value of attribute clan.
-
#color_body ⇒ Object
Returns the value of attribute color_body.
-
#color_decoration ⇒ Object
Returns the value of attribute color_decoration.
-
#color_eyes ⇒ Object
Returns the value of attribute color_eyes.
-
#color_feet ⇒ Object
Returns the value of attribute color_feet.
-
#color_hands ⇒ Object
Returns the value of attribute color_hands.
-
#color_marking ⇒ Object
Returns the value of attribute color_marking.
-
#country ⇒ Object
Returns the value of attribute country.
-
#custom_color_body ⇒ Object
Returns the value of attribute custom_color_body.
-
#custom_color_decoration ⇒ Object
Returns the value of attribute custom_color_decoration.
-
#custom_color_eyes ⇒ Object
Returns the value of attribute custom_color_eyes.
-
#custom_color_feet ⇒ Object
Returns the value of attribute custom_color_feet.
-
#custom_color_hands ⇒ Object
Returns the value of attribute custom_color_hands.
-
#custom_color_marking ⇒ Object
Returns the value of attribute custom_color_marking.
-
#decoration ⇒ Object
Returns the value of attribute decoration.
-
#eyes ⇒ Object
Returns the value of attribute eyes.
-
#feet ⇒ Object
Returns the value of attribute feet.
-
#hands ⇒ Object
Returns the value of attribute hands.
-
#marking ⇒ Object
Returns the value of attribute marking.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #init_hash(attr) ⇒ Object
- #init_raw(data) ⇒ Object
-
#initialize(hash_or_raw) ⇒ StartInfo
constructor
A new instance of StartInfo.
-
#to_a ⇒ Object
basically to_network int array the client sends to the server.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash_or_raw) ⇒ StartInfo
Returns a new instance of StartInfo.
17 18 19 20 21 22 23 |
# File 'lib/messages/start_info.rb', line 17 def initialize(hash_or_raw) if hash_or_raw.instance_of?(Hash) init_hash(hash_or_raw) else init_raw(hash_or_raw) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def body @body end |
#clan ⇒ Object
Returns the value of attribute clan.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def clan @clan end |
#color_body ⇒ Object
Returns the value of attribute color_body.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_body @color_body end |
#color_decoration ⇒ Object
Returns the value of attribute color_decoration.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_decoration @color_decoration end |
#color_eyes ⇒ Object
Returns the value of attribute color_eyes.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_eyes @color_eyes end |
#color_feet ⇒ Object
Returns the value of attribute color_feet.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_feet @color_feet end |
#color_hands ⇒ Object
Returns the value of attribute color_hands.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_hands @color_hands end |
#color_marking ⇒ Object
Returns the value of attribute color_marking.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def color_marking @color_marking end |
#country ⇒ Object
Returns the value of attribute country.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def country @country end |
#custom_color_body ⇒ Object
Returns the value of attribute custom_color_body.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_body @custom_color_body end |
#custom_color_decoration ⇒ Object
Returns the value of attribute custom_color_decoration.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_decoration @custom_color_decoration end |
#custom_color_eyes ⇒ Object
Returns the value of attribute custom_color_eyes.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_eyes @custom_color_eyes end |
#custom_color_feet ⇒ Object
Returns the value of attribute custom_color_feet.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_feet @custom_color_feet end |
#custom_color_hands ⇒ Object
Returns the value of attribute custom_color_hands.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_hands @custom_color_hands end |
#custom_color_marking ⇒ Object
Returns the value of attribute custom_color_marking.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def custom_color_marking @custom_color_marking end |
#decoration ⇒ Object
Returns the value of attribute decoration.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def decoration @decoration end |
#eyes ⇒ Object
Returns the value of attribute eyes.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def eyes @eyes end |
#feet ⇒ Object
Returns the value of attribute feet.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def feet @feet end |
#hands ⇒ Object
Returns the value of attribute hands.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def hands @hands end |
#marking ⇒ Object
Returns the value of attribute marking.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def marking @marking end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/messages/start_info.rb', line 12 def name @name end |
Instance Method Details
#init_hash(attr) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/messages/start_info.rb', line 50 def init_hash(attr) @name = attr[:name] || 'ruby gamer' @clan = attr[:clan] || '' @country = attr[:country] || -1 @body = attr[:body] || 'spiky' @marking = attr[:marking] || 'duodonny' @decoration = attr[:decoration] || '' @hands = attr[:hands] || 'standard' @feet = attr[:feet] || 'standard' @eyes = attr[:eyes] || 'standard' @custom_color_body = attr[:custom_color_body] || 0 @custom_color_marking = attr[:custom_color_marking] || 0 @custom_color_decoration = attr[:custom_color_decoration] || 0 @custom_color_hands = attr[:custom_color_hands] || 0 @custom_color_feet = attr[:custom_color_feet] || 0 @custom_color_eyes = attr[:custom_color_eyes] || 0 @color_body = attr[:color_body] || 0 @color_marking = attr[:color_marking] || 0 @color_decoration = attr[:color_decoration] || 0 @color_hands = attr[:color_hands] || 0 @color_feet = attr[:color_feet] || 0 @color_eyes = attr[:color_eyes] || 0 end |
#init_raw(data) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/messages/start_info.rb', line 25 def init_raw(data) u = Unpacker.new(data) @name = u.get_string @clan = u.get_string @country = u.get_int @body = u.get_string @marking = u.get_string @decoration = u.get_string @hands = u.get_string @feet = u.get_string @eyes = u.get_string @custom_color_body = u.get_int @custom_color_marking = u.get_int @custom_color_decoration = u.get_int @custom_color_hands = u.get_int @custom_color_feet = u.get_int @custom_color_eyes = u.get_int @color_body = u.get_int @color_marking = u.get_int @color_decoration = u.get_int @color_hands = u.get_int @color_feet = u.get_int @color_eyes = u.get_int end |
#to_a ⇒ Object
basically to_network int array the client sends to the server
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/messages/start_info.rb', line 102 def to_a Packer.pack_str(@name) + Packer.pack_str(@clan) + Packer.pack_int(@country) + Packer.pack_str(@body) + Packer.pack_str(@marking) + Packer.pack_str(@decoration) + Packer.pack_str(@hands) + Packer.pack_str(@feet) + Packer.pack_str(@eyes) + Packer.pack_int(@custom_color_body) + Packer.pack_int(@custom_color_marking) + Packer.pack_int(@custom_color_decoration) + Packer.pack_int(@custom_color_hands) + Packer.pack_int(@custom_color_feet) + Packer.pack_int(@custom_color_eyes) + Packer.pack_int(@color_body) + Packer.pack_int(@color_marking) + Packer.pack_int(@color_decoration) + Packer.pack_int(@color_hands) + Packer.pack_int(@color_feet) + Packer.pack_int(@color_eyes) end |
#to_h ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/messages/start_info.rb', line 74 def to_h { name: @name, clan: @clan, country: @country, body: @body, marking: @marking, decoration: @decoration, hands: @hands, feet: @feet, eyes: @eyes, custom_color_body: @custom_color_body, custom_color_marking: @custom_color_marking, custom_color_decoration: @custom_color_decoration, custom_color_hands: @custom_color_hands, custom_color_feet: @custom_color_feet, custom_color_eyes: @custom_color_eyes, color_body: @color_body, color_marking: @color_marking, color_decoration: @color_decoration, color_hands: @color_hands, color_feet: @color_feet, color_eyes: @color_eyes } end |
#to_s ⇒ Object
126 127 128 |
# File 'lib/messages/start_info.rb', line 126 def to_s to_h end |