Module: RuneRb::Network::RS317::ActionClickMessage

Includes:
System::Log
Defined in:
app/network/protocol/rs317/incoming/action.rb

Overview

Since:

  • 0.9.3

Instance Method Summary collapse

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Instance Method Details

#parse(context) ⇒ Object

Parses the ActionClickMessage

Parameters:

Since:

  • 0.9.3


6
7
8
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
# File 'app/network/protocol/rs317/incoming/action.rb', line 6

def parse(context)
  case @header[:op_code]
  when 145 # First
    interface = read_short(false, :ADD)
    slot = read_short(false, :ADD)
    item_id = read_short(false, :ADD)

    # Equipping items.
    if context.add_item(RuneRb::Game::Item::Stack.new(item_id)) && interface == 1688
      context.unequip(slot)
      context.update(:equipment)
      context.update(:inventory)
    else
      @session.write_message(:sys_text, message: "You don't have enough space in your inventory to do this.")
    end
  when 117 # Second
    interface = read_short(false, :ADD, :LITTLE)
    item_id = read_short(false, :ADD, :LITTLE)
    slot = read_short(false, :STD, :LITTLE)
  when 43 # Third
    interface = read_short(false, :STD, :LITTLE)
    item_id = read_short(false, :ADD)
    slot = read_short(false, :ADD)
  when 129 # Fourth
    slot = read_short(false, :ADD)
    interface = read_short
    item_id = read_short(false, :ADD)
  when 135 # Fifth
    slot = read_short(false, :STD, :LITTLE)
    interface = read_short(false, :ADD)
    item_id = read_short(false, :STD, :LITTLE)
  end
  log_action_click(interface, slot, item_id)
end