initial work on ZoneLockInfoMessage and tests

This commit is contained in:
FateJH 2017-01-28 22:59:16 -05:00
parent 50bf69fc91
commit b1bf1ac054
3 changed files with 55 additions and 1 deletions

View file

@ -582,7 +582,7 @@ object GamePacketOpcode extends Enumeration {
case 0xdc => noDecoder(SquadMainTerminalResponseMessage)
case 0xdd => noDecoder(SquadOrderMessage)
case 0xde => noDecoder(SquadOrderResponse)
case 0xdf => noDecoder(ZoneLockInfoMessage)
case 0xdf => game.ZoneLockInfoMessage.decode
// OPCODES 0xe0-ef
case 0xe0 => noDecoder(SquadBindInfoMessage)

View file

@ -0,0 +1,32 @@
// Copyright (c) 2016 PSForever.net to present
package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
import scodec.Codec
import scodec.codecs._
/**
* Change the "Empire Status" text in the Interstellar Map zone description for the specified zone.
* The information in the Empire Incentives window also displays the changed information.<br>
* @param zone the zone id
* @param lock_status `true` displays "Locked;"
* `false` displays the queue availability for the avatar's empire
* @param unk na;
* usually `true`
*/
final case class ZoneLockInfoMessage(zone : PlanetSideGUID,
lock_status : Boolean,
unk : Boolean)
extends PlanetSideGamePacket {
type Packet = ZoneLockInfoMessage
def opcode = GamePacketOpcode.ZoneLockInfoMessage
def encode = ZoneLockInfoMessage.encode(this)
}
object ZoneLockInfoMessage extends Marshallable[ZoneLockInfoMessage] {
implicit val codec : Codec[ZoneLockInfoMessage] = (
("zone" | PlanetSideGUID.codec) ::
("lock_status" | bool) ::
("unk" | bool)
).as[ZoneLockInfoMessage]
}

View file

@ -1462,6 +1462,28 @@ class GamePacketTest extends Specification {
}
}
"ZoneLockInfoMesage" should {
val string = hex"DF 1B 00 40"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case ZoneLockInfoMessage(zone, locked, unk) =>
zone mustEqual PlanetSideGUID(27)
locked mustEqual false
unk mustEqual true
case default =>
ko
}
}
"encode" in {
val msg = ZoneLockInfoMessage(PlanetSideGUID(27), false, true)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}
"BattleExperienceMessage" should {
val string = hex"B4 8A0A E7030000 00"