Print emotes on the server side
thanks to @AlexIsTheGuy for brainstorming emote names
This commit is contained in:
parent
6283648964
commit
07eb3841d2
|
@ -7,6 +7,7 @@ require_relative 'models/game_info'
|
|||
require_relative 'models/start_info'
|
||||
require_relative 'models/cl_say'
|
||||
require_relative 'models/chat_message'
|
||||
require_relative 'models/cl_emoticon'
|
||||
|
||||
class GameServer
|
||||
attr_accessor :pred_game_tick, :ack_game_tick, :map
|
||||
|
@ -23,9 +24,9 @@ class GameServer
|
|||
)
|
||||
end
|
||||
|
||||
def on_emoticon(chunk, packet)
|
||||
# TODO: generate ClEmoticon using
|
||||
# twgen g ClEmoticon emoticon:int
|
||||
def on_emoticon(chunk, _packet)
|
||||
todo_rename_this = ClEmoticon.new(chunk.data[1..])
|
||||
p todo_rename_this
|
||||
end
|
||||
|
||||
def on_info(chunk, packet)
|
||||
|
|
63
lib/models/cl_emoticon.rb
Normal file
63
lib/models/cl_emoticon.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../packer'
|
||||
|
||||
##
|
||||
# ClEmoticon
|
||||
#
|
||||
# Client -> Server
|
||||
class ClEmoticon
|
||||
attr_accessor :emoticon, :name
|
||||
|
||||
def initialize(hash_or_raw)
|
||||
names = [
|
||||
'oop!', # 0
|
||||
'alert', # 1
|
||||
'heart', # 2
|
||||
'tear', # 3
|
||||
'...', # 4
|
||||
'music', # 5
|
||||
'sorry', # 6
|
||||
'ghost', # 7
|
||||
'annoyed', # 8
|
||||
'angry', # 9
|
||||
'devil', # 10
|
||||
'swearing', # 11
|
||||
'zzZ', # 12
|
||||
'WTF', # 13
|
||||
'happy', # 14
|
||||
'???' # 15
|
||||
]
|
||||
if hash_or_raw.instance_of?(Hash)
|
||||
init_hash(hash_or_raw)
|
||||
else
|
||||
init_raw(hash_or_raw)
|
||||
end
|
||||
@name = names[@emoticon]
|
||||
end
|
||||
|
||||
def init_raw(data)
|
||||
u = Unpacker.new(data)
|
||||
@emoticon = u.get_int
|
||||
end
|
||||
|
||||
def init_hash(attr)
|
||||
@emoticon = attr[:emoticon] || 0
|
||||
end
|
||||
|
||||
def to_h
|
||||
{
|
||||
emoticon: @emoticon
|
||||
}
|
||||
end
|
||||
|
||||
# basically to_network
|
||||
# int array the Client sends to the Server
|
||||
def to_a
|
||||
Packer.pack_int(@emoticon)
|
||||
end
|
||||
|
||||
def to_s
|
||||
to_h
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue