Class: RuneRb::Network::RS377::UpdateSlottedItemMessage

Inherits:
Message
  • Object
show all
Defined in:
app/network/protocol/rs377/outgoing/update_slotted.rb

Overview

Since:

  • 0.9.3

Constant Summary

Constants included from Constants

Constants::BIT_MASK_OUT, Constants::BYTE_MUTATIONS, Constants::BYTE_ORDERS, Constants::BYTE_SIZE, Constants::CONNECTION_TYPES, Constants::LOGIN_RESPONSES, Constants::MESSAGE_SIZES, Constants::PROTOCOL_TEMPLATES, Constants::RW_TYPES, Constants::SIDEBAR_INTERFACES

Instance Attribute Summary

Attributes inherited from Message

#header, #mode

Instance Method Summary collapse

Methods inherited from Message

compile_header, #inspect, #peek, validate

Methods included from System::Log

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

Constructor Details

#initialize(data) ⇒ UpdateSlottedItemMessage

Constructs a new UpdateSlottedItemMessage

Parameters:

  • data (Hash)

    data containing items, amounts and slots

Since:

  • 0.9.3


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/network/protocol/rs377/outgoing/update_slotted.rb', line 6

def initialize(data)
  super('w', { op_code: 134 }, :VARIABLE_SHORT)
  write_short(1688, :STD, :BIG) # EquipmentForm ID
  write_smart(data[:slot].to_i)

  id = data[:slot_data].is_a?(Integer) || data[:slot_data].nil? ? -1 : data[:slot_data].id
  amount = data[:slot_data].is_a?(Integer) || data[:slot_data].nil? ? 0 : data[:slot_data].size

  write_short(id + 1, :STD, :BIG)
  if amount > 254
    write_byte(0xFF, :STD)
    write_int(amount, :STD)
  else
    write_byte(amount, :STD)
  end
end