mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Packet: QuantityDeltaUpdateMessage (#57)
This commit is contained in:
parent
0bed8ce5b8
commit
83264de081
|
|
@ -553,7 +553,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
case VanuModuleUpdateMessage => noDecoder(opcode)
|
||||
case FacilityBenefitShieldChargeRequestMessage => noDecoder(opcode)
|
||||
case ProximityTerminalUseMessage => noDecoder(opcode)
|
||||
case QuantityDeltaUpdateMessage => noDecoder(opcode)
|
||||
case QuantityDeltaUpdateMessage => game.QuantityDeltaUpdateMessage.decode
|
||||
case ChainLashMessage => noDecoder(opcode)
|
||||
case ZoneInfoMessage => noDecoder(opcode)
|
||||
case LongRangeProjectileInfoMessage => noDecoder(opcode)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
/**
|
||||
* Instructs client to update the quantity of an item based on a delta when sent server to client.
|
||||
*
|
||||
* See also [[QuantityUpdateMessage]]
|
||||
*
|
||||
* @param item_guid the item to update
|
||||
* @param quantity_delta the change in quantity of the item
|
||||
*/
|
||||
final case class QuantityDeltaUpdateMessage(item_guid : PlanetSideGUID,
|
||||
quantity_delta : Int)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = QuantityDeltaUpdateMessage
|
||||
def opcode = GamePacketOpcode.QuantityDeltaUpdateMessage
|
||||
def encode = QuantityDeltaUpdateMessage.encode(this)
|
||||
}
|
||||
|
||||
object QuantityDeltaUpdateMessage extends Marshallable[QuantityDeltaUpdateMessage] {
|
||||
implicit val codec : Codec[QuantityDeltaUpdateMessage] = (
|
||||
("item_guid" | PlanetSideGUID.codec) ::
|
||||
("quantity_delta" | int32L)
|
||||
).as[QuantityDeltaUpdateMessage]
|
||||
}
|
||||
|
|
@ -858,6 +858,27 @@ class GamePacketTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"QuantityDeltaUpdateMessage" should {
|
||||
val string = hex"C4 5300 FBFFFFFF"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case QuantityDeltaUpdateMessage(item_guid, quantity) =>
|
||||
item_guid mustEqual PlanetSideGUID(83)
|
||||
quantity mustEqual -5
|
||||
case default =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = QuantityDeltaUpdateMessage(PlanetSideGUID(83), -5)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
||||
"PingMsg" should {
|
||||
val packet = hex"1a 00000000 b0360000"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue