Class: Overlook::Csgo::Demo::UserMessageMessageHandler
- Inherits:
-
Object
- Object
- Overlook::Csgo::Demo::UserMessageMessageHandler
- Defined in:
- lib/overlook/csgo/demo/user_message_message_handler.rb
Instance Method Summary collapse
- #handle(message) ⇒ Object
-
#initialize(parser) ⇒ UserMessageMessageHandler
constructor
A new instance of UserMessageMessageHandler.
Constructor Details
#initialize(parser) ⇒ UserMessageMessageHandler
Returns a new instance of UserMessageMessageHandler.
5 6 7 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 5 def initialize(parser) @parser = parser end |
Instance Method Details
#handle(message) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/overlook/csgo/demo/user_message_message_handler.rb', line 9 def handle() = ::Csgo::CSVCMsg_UserMessage.decode() case .msg_type when ::Csgo::ECstrike15UserMessages::CS_UM_XpUpdate = ::Csgo::CCSUsrMsg_XpUpdate.decode(.msg_data) community_id = Steam3Id.parse("[U:1:#{.data.account_id}]").to_i xp_update = { community_id.to_s => { xp: .data.current_xp, lvl: .data.current_level, progress: .data.xp_progress_data.map do |item| { category: item.xp_category, xp: item.xp_points } end } } @parser.emit(:xp_update, xp_update) when ::Csgo::ECstrike15UserMessages::CS_UM_ServerRankUpdate = ::Csgo::CCSUsrMsg_ServerRankUpdate.decode(.msg_data) .rank_update.each do |update| # The account_id is used in the 'modern' steam format. # [U:1:account_id] community_id = Steam3Id.parse("[U:1:#{update.account_id}]").to_i rank_update_payload = { rank_change: update.rank_change.to_i, wins: update.num_wins, community_id: community_id.to_s, rank: update.rank_new } @parser.emit(:rank_update, rank_update_payload) end end end |