mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-12 19:31:04 +00:00
ObjectCreateMessage Alterations, Class Object Adjustments (#243)
* power outage failure resulting in the destruction of the original ocm-fixes branch; the git branch refs were corrupted during commit, but the up-to-date changed files remained intact * eliminating the need for CommonFieldData2 and CommonFieldData2WithPlacement * in the middle of integrating CommonFieldData into DetailedLockerContainerData (but not standard LockerContainerData); added field for final boolean in WeaponData * adding faction affinity to Equipment (to match functionality; not becuase I know what ends ...) * in the middle of integrating CommonFieldData into DetailedCommandDetonaterData * applying faction affinity to objects at time of terminal production (but to what ends?); required BoomerTrigger and AmmoBox to always report as NEUTRAL internally * completed the transition from using the old class-based order terminal system to the page-based order terminal system; unused terminal classes have been eliminated * more closely aligned TelepadDeployableData and InternalTelepadDeployableData * modifying TelepadDeployableData make it generic and eliminate the need for InternalTelepadDeployableData after fixing a packet converter to utilize DroppedItemData * modified Terminal operation to branch further outwards from Terminal.Request to the TerminalDefinition's Request method; modified tests to reflect update * loosening up matrix terminal definition limitations * modified ProximityTerminal to support a custom defintition class * rendered the message passing system for Terminals general (Any) in the full scale so it can be specific in instance cases * refactored and moved both EquipmentSlot and ExoSuitDefinition * (re)load Favorites each time player (re)spawns
This commit is contained in:
parent
5fc9e191fe
commit
337cfbe5d2
174 changed files with 6281 additions and 5477 deletions
84
common/src/test/scala/CosmeticsTest.scala
Normal file
84
common/src/test/scala/CosmeticsTest.scala
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// Copyright (c) 2019 PSForever
|
||||
import net.psforever.packet.game.objectcreate.{Cosmetics, PersonalStyle}
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
class CosmeticsTest extends Specification {
|
||||
"Cosmetics" should {
|
||||
"construct" in {
|
||||
Cosmetics()
|
||||
Cosmetics(3)
|
||||
Cosmetics(PersonalStyle.NoHelmet)
|
||||
Cosmetics(Set(PersonalStyle.NoHelmet))
|
||||
Cosmetics(true, false, false, false, false)
|
||||
ok
|
||||
}
|
||||
|
||||
"translate into a numeric value" in {
|
||||
Cosmetics().pstyles mustEqual 0
|
||||
Cosmetics(3).pstyles mustEqual 3
|
||||
Cosmetics(PersonalStyle.NoHelmet).pstyles mustEqual PersonalStyle.NoHelmet.id
|
||||
Cosmetics(Set(PersonalStyle.NoHelmet, PersonalStyle.Earpiece)).pstyles mustEqual PersonalStyle.NoHelmet.id + PersonalStyle.Earpiece.id
|
||||
Cosmetics(true, false, false, false, false).pstyles mustEqual PersonalStyle.NoHelmet.id
|
||||
}
|
||||
|
||||
"translate into a list of cosmetic style tokens" in {
|
||||
Cosmetics().Styles mustEqual Set()
|
||||
Cosmetics(3).Styles mustEqual Set(PersonalStyle.BrimmedCap, PersonalStyle.Earpiece)
|
||||
Cosmetics(PersonalStyle.NoHelmet).Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
Cosmetics(Set(PersonalStyle.NoHelmet)).Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
Cosmetics(true, false, false, false, false).Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
}
|
||||
|
||||
"report containing specific values only" in {
|
||||
val cos = Cosmetics(Set(PersonalStyle.NoHelmet, PersonalStyle.Earpiece))
|
||||
cos.contains(PersonalStyle.NoHelmet) mustEqual true
|
||||
cos.contains(PersonalStyle.Beret) mustEqual false
|
||||
}
|
||||
|
||||
"add values" in {
|
||||
val cos = Cosmetics()
|
||||
cos.Styles mustEqual Set()
|
||||
val cos1 = cos + PersonalStyle.NoHelmet
|
||||
cos1.Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
cos1.Styles mustNotEqual cos.Styles
|
||||
val cos2 = cos1 + PersonalStyle.Beret
|
||||
cos2.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret)
|
||||
cos2.Styles mustNotEqual cos.Styles
|
||||
cos2.Styles mustNotEqual cos1.Styles
|
||||
}
|
||||
|
||||
"can not add already included values" in {
|
||||
val cos = Cosmetics(Set(PersonalStyle.NoHelmet, PersonalStyle.Beret))
|
||||
cos.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret)
|
||||
val cos1 = cos + PersonalStyle.Beret
|
||||
cos1.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret)
|
||||
cos ne cos1 mustEqual true
|
||||
}
|
||||
|
||||
"remove values" in {
|
||||
val cos = Cosmetics(Set(PersonalStyle.NoHelmet, PersonalStyle.Beret))
|
||||
cos.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret)
|
||||
val cos1 = cos - PersonalStyle.NoHelmet
|
||||
cos1.Styles mustEqual Set(PersonalStyle.Beret)
|
||||
cos1.Styles mustNotEqual cos.Styles
|
||||
val cos2 = cos1 - PersonalStyle.Beret
|
||||
cos2.Styles mustEqual Set()
|
||||
cos2.Styles mustNotEqual cos.Styles
|
||||
cos2.Styles mustNotEqual cos1.Styles
|
||||
}
|
||||
|
||||
"can not remove un-included or already excluded values" in {
|
||||
val cos = Cosmetics(Set(PersonalStyle.NoHelmet, PersonalStyle.Beret))
|
||||
cos.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret)
|
||||
val cos1 = cos - PersonalStyle.Beret
|
||||
cos1.Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
|
||||
val cos2 = cos - PersonalStyle.Beret //again
|
||||
cos2.Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
|
||||
val cos3 = cos1 - PersonalStyle.Earpiece
|
||||
cos3.Styles mustEqual Set(PersonalStyle.NoHelmet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import scodec.bits._
|
||||
|
||||
class ObjectCreateBaseTest extends Specification {
|
||||
val packet217 = hex"17 F8 00 00 00 BC 8C 10 90 3B 45 C6 FA 94 00 9F F0 00 00 40 00 08 C0 44 00 69 00 66 00 66 00 45" //fake data
|
||||
val packet218 = hex"18 F8 00 00 00 BC 8C 10 90 3B 45 C6 FA 94 00 9F F0 00 00 40 00 08 C0 44 00 69 00 66 00 66 00 45" //fake data
|
||||
|
||||
"ObjectCreateDetailedMessage" should {
|
||||
"fail to decode" in {
|
||||
//an invalid bit representation will fail to turn into an object
|
||||
PacketCoding.DecodePacket(packet217).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 248
|
||||
cls mustEqual ObjectClass.avatar
|
||||
guid mustEqual PlanetSideGUID(2497)
|
||||
parent mustEqual None
|
||||
data.isDefined mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"fail to encode" in {
|
||||
//the lack of an object will fail to turn into a bad bitstream
|
||||
val msg = ObjectCreateMessage(0L, ObjectClass.avatar, PlanetSideGUID(2497), None, None)
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"ObjectCreateDetailedMessage" should {
|
||||
"fail to decode" in {
|
||||
//an invalid bit representation will fail to turn into an object
|
||||
PacketCoding.DecodePacket(packet218).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 248
|
||||
cls mustEqual ObjectClass.avatar
|
||||
guid mustEqual PlanetSideGUID(2497)
|
||||
parent mustEqual None
|
||||
data.isDefined mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"fail to encode" in {
|
||||
//the lack of an object will fail to turn into a bad bitstream
|
||||
val msg = ObjectCreateDetailedMessage(0L, ObjectClass.avatar, PlanetSideGUID(2497), None, None)
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"StreamBitSize" should {
|
||||
"have zero size by default" in {
|
||||
new StreamBitSize() {}.bitsize mustEqual 0L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class ACEDataTest extends Specification {
|
||||
val string_ace_held = hex"17 76000000 0406900650C80480000000"
|
||||
val string_ace_dropped = hex"17 AF000000 90024113B329C5D5A2D1200005B440000000"
|
||||
|
||||
"ACEData" should {
|
||||
"decode (held)" in {
|
||||
PacketCoding.DecodePacket(string_ace_held).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(3173)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3336)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[ACEData] mustEqual true
|
||||
val ace = data.get.asInstanceOf[ACEData]
|
||||
ace.unk1 mustEqual 4
|
||||
ace.unk2 mustEqual 8
|
||||
ace.unk3 mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (dropped)" in {
|
||||
PacketCoding.DecodePacket(string_ace_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 175
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(4388)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4708.461f
|
||||
drop.pos.coord.y mustEqual 5547.539f
|
||||
drop.pos.coord.z mustEqual 72.703125f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 194.0625f
|
||||
drop.obj.isInstanceOf[ACEData] mustEqual true
|
||||
val ace = drop.obj.asInstanceOf[ACEData]
|
||||
ace.unk1 mustEqual 8
|
||||
ace.unk2 mustEqual 8
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = ACEData(4, 8)
|
||||
val msg = ObjectCreateMessage(ObjectClass.ace, PlanetSideGUID(3173), ObjectCreateMessageParent(PlanetSideGUID(3336), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_ace_held
|
||||
}
|
||||
|
||||
"encode (dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4708.461f, 5547.539f, 72.703125f, 0f, 0f, 194.0625f),
|
||||
ACEData(8, 8)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.ace, PlanetSideGUID(4388), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_ace_dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,15 +19,24 @@ class AegisShieldGeneratorDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.deployable_shield_generator
|
||||
guid mustEqual PlanetSideGUID(2556)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[AegisShieldGeneratorData] mustEqual true
|
||||
val aegis = data.get.asInstanceOf[AegisShieldGeneratorData]
|
||||
aegis.deploy.pos.coord mustEqual Vector3(3571.2266f, 3278.0938f, 114.0f)
|
||||
aegis.deploy.pos.orient mustEqual Vector3(0, 0, 90)
|
||||
aegis.deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
aegis.deploy.unk mustEqual 2
|
||||
aegis.health mustEqual 255
|
||||
aegis.deploy.player_guid mustEqual PlanetSideGUID(2366)
|
||||
data match {
|
||||
case AegisShieldGeneratorData(basic, health) =>
|
||||
basic.pos.coord mustEqual Vector3(3571.2266f, 3278.0938f, 114.0f)
|
||||
basic.pos.orient mustEqual Vector3.z(90.0f)
|
||||
|
||||
basic.data.faction mustEqual PlanetSideEmpire.VS
|
||||
basic.data.bops mustEqual false
|
||||
basic.data.alternate mustEqual false
|
||||
basic.data.v1 mustEqual true
|
||||
basic.data.v2.isDefined mustEqual false
|
||||
basic.data.v3 mustEqual false
|
||||
basic.data.v5.isDefined mustEqual false
|
||||
basic.data.guid mustEqual PlanetSideGUID(2366)
|
||||
|
||||
health mustEqual 255
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -35,7 +44,7 @@ class AegisShieldGeneratorDataTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val obj = AegisShieldGeneratorData(
|
||||
CommonFieldData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(3571.2266f, 3278.0938f, 114.0f), Vector3(0, 0, 90)),
|
||||
PlanetSideEmpire.VS, 2, PlanetSideGUID(2366)
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class AmmoBoxDataTest extends Specification {
|
||||
val string_shotgunshell_dropped = hex"17 A5000000 F9A7D0D 5E269 BED5A F114 0000596000000"
|
||||
|
||||
"AmmoBoxData" should {
|
||||
"decode (shotgun shells, dropped)" in {
|
||||
PacketCoding.DecodePacket(string_shotgunshell_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.shotgun_shell
|
||||
guid mustEqual PlanetSideGUID(3453)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4684.7344f
|
||||
drop.pos.coord.y mustEqual 5547.4844f
|
||||
drop.pos.coord.z mustEqual 83.765625f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 199.6875f
|
||||
drop.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
val box = drop.obj.asInstanceOf[AmmoBoxData]
|
||||
box.unk mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (shotgun shells, dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4684.7344f, 5547.4844f, 83.765625f, 0f, 0f, 199.6875f),
|
||||
AmmoBoxData()
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.shotgun_shell, PlanetSideGUID(3453), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_shotgunshell_dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class BoomerTriggerDataTest extends Specification {
|
||||
val string_boomertrigger = hex"17 76000000 58084A8100E80C00000000" //reconstructed from an inventory entry
|
||||
|
||||
"BoomerTriggerData" should {
|
||||
"decode (held)" in {
|
||||
PacketCoding.DecodePacket(string_boomertrigger).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.boomer_trigger
|
||||
guid mustEqual PlanetSideGUID(3600)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4272)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[BoomerTriggerData] mustEqual true
|
||||
data.get.asInstanceOf[BoomerTriggerData].unk mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = BoomerTriggerData(0)
|
||||
val msg = ObjectCreateMessage(ObjectClass.boomer_trigger, PlanetSideGUID(3600), ObjectCreateMessageParent(PlanetSideGUID(4272), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_boomertrigger
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,9 +19,8 @@ class CaptureFlagDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.capture_flag
|
||||
guid mustEqual PlanetSideGUID(4330)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[CaptureFlagData] mustEqual true
|
||||
val flag = data.get.asInstanceOf[CaptureFlagData]
|
||||
data.isInstanceOf[CaptureFlagData] mustEqual true
|
||||
val flag = data.asInstanceOf[CaptureFlagData]
|
||||
flag.pos.coord.x mustEqual 3912.0312f
|
||||
flag.pos.coord.y mustEqual 5169.4375f
|
||||
flag.pos.coord.z mustEqual 59.96875f
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class CharacterDataTest extends Specification {
|
|||
guid mustEqual PlanetSideGUID(3902)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case Some(PlayerData(Some(pos), basic, char, inv, hand)) =>
|
||||
case PlayerData(Some(pos), basic, char, inv, hand) =>
|
||||
pos.coord mustEqual Vector3(3674.8438f, 2726.789f, 91.15625f)
|
||||
pos.orient mustEqual Vector3(0f, 0f, 64.6875f)
|
||||
pos.vel.isDefined mustEqual true
|
||||
|
|
@ -40,13 +40,13 @@ class CharacterDataTest extends Specification {
|
|||
a.app.sex mustEqual CharacterGender.Male
|
||||
a.app.head mustEqual 5
|
||||
a.app.voice mustEqual CharacterVoice.Voice5
|
||||
a.black_ops mustEqual false
|
||||
a.jammered mustEqual false
|
||||
a.data.bops mustEqual false
|
||||
a.data.v1 mustEqual false
|
||||
a.data.v2.isEmpty mustEqual true
|
||||
a.data.v3 mustEqual false
|
||||
a.data.v4.isEmpty mustEqual true
|
||||
a.data.v5.isEmpty mustEqual true
|
||||
a.exosuit mustEqual ExoSuitType.Reinforced
|
||||
a.unk1 mustEqual false
|
||||
a.unk2 mustEqual None
|
||||
a.unk3 mustEqual None
|
||||
a.unk4 mustEqual 0
|
||||
a.unk5 mustEqual 0
|
||||
a.unk6 mustEqual 30777081L
|
||||
a.unk7 mustEqual 1
|
||||
|
|
@ -63,7 +63,7 @@ class CharacterDataTest extends Specification {
|
|||
b.grenade_state mustEqual GrenadeState.None
|
||||
b.is_cloaking mustEqual false
|
||||
b.charging_pose mustEqual false
|
||||
b.on_zipline mustEqual None
|
||||
b.on_zipline.isEmpty mustEqual true
|
||||
b.unk0 mustEqual 316554L
|
||||
b.unk1 mustEqual false
|
||||
b.unk2 mustEqual false
|
||||
|
|
@ -87,12 +87,12 @@ class CharacterDataTest extends Specification {
|
|||
char.command_rank mustEqual 5
|
||||
char.implant_effects.length mustEqual 1
|
||||
char.implant_effects.head mustEqual ImplantEffects.NoEffects
|
||||
char.cosmetics.isDefined mustEqual true
|
||||
char.cosmetics.get.no_helmet mustEqual true
|
||||
char.cosmetics.get.beret mustEqual true
|
||||
char.cosmetics.get.sunglasses mustEqual true
|
||||
char.cosmetics.get.earpiece mustEqual true
|
||||
char.cosmetics.get.brimmed_cap mustEqual false
|
||||
char.cosmetics match {
|
||||
case Some(c : Cosmetics) =>
|
||||
c.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret, PersonalStyle.Sunglasses, PersonalStyle.Earpiece)
|
||||
case None =>
|
||||
ko
|
||||
}
|
||||
char.unk mustEqual 7
|
||||
//short test of inventory items
|
||||
inv.isDefined mustEqual true
|
||||
|
|
@ -149,9 +149,9 @@ class CharacterDataTest extends Specification {
|
|||
len mustEqual 1795
|
||||
cls mustEqual ObjectClass.avatar
|
||||
guid mustEqual PlanetSideGUID(3902)
|
||||
parent mustEqual Some(ObjectCreateMessageParent(PlanetSideGUID(1234), 0))
|
||||
parent.contains(ObjectCreateMessageParent(PlanetSideGUID(1234), 0)) mustEqual true
|
||||
data match {
|
||||
case Some(PlayerData(None, basic, char, inv, hand)) =>
|
||||
case PlayerData(None, basic, _, _, _) =>
|
||||
basic match {
|
||||
case CharacterAppearanceData(a, b, ribbons) =>
|
||||
a.app.name mustEqual "ScrawnyRonnie"
|
||||
|
|
@ -159,13 +159,13 @@ class CharacterDataTest extends Specification {
|
|||
a.app.sex mustEqual CharacterGender.Male
|
||||
a.app.head mustEqual 5
|
||||
a.app.voice mustEqual CharacterVoice.Voice5
|
||||
a.black_ops mustEqual false
|
||||
a.jammered mustEqual false
|
||||
a.data.bops mustEqual false
|
||||
a.data.v1 mustEqual false
|
||||
a.data.v2.isEmpty mustEqual true
|
||||
a.data.v3 mustEqual false
|
||||
a.data.v4.isEmpty mustEqual true
|
||||
a.data.v5.isEmpty mustEqual true
|
||||
a.exosuit mustEqual ExoSuitType.Reinforced
|
||||
a.unk1 mustEqual false
|
||||
a.unk2 mustEqual None
|
||||
a.unk3 mustEqual None
|
||||
a.unk4 mustEqual 0
|
||||
a.unk5 mustEqual 0
|
||||
a.unk6 mustEqual 192L
|
||||
a.unk7 mustEqual 0
|
||||
|
|
@ -182,7 +182,7 @@ class CharacterDataTest extends Specification {
|
|||
b.grenade_state mustEqual GrenadeState.None
|
||||
b.is_cloaking mustEqual false
|
||||
b.charging_pose mustEqual false
|
||||
b.on_zipline mustEqual None
|
||||
b.on_zipline.isEmpty mustEqual true
|
||||
b.unk0 mustEqual 26L
|
||||
b.unk1 mustEqual false
|
||||
b.unk2 mustEqual false
|
||||
|
|
@ -216,7 +216,7 @@ class CharacterDataTest extends Specification {
|
|||
guid mustEqual PlanetSideGUID(3380)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case Some(PlayerData(Some(pos), basic, char, None, hand)) =>
|
||||
case PlayerData(Some(pos), basic, char, None, hand) =>
|
||||
pos.coord mustEqual Vector3(4629.8906f, 6316.4453f, 54.734375f)
|
||||
pos.orient mustEqual Vector3(0, 0, 126.5625f)
|
||||
pos.vel.isDefined mustEqual false
|
||||
|
|
@ -228,13 +228,13 @@ class CharacterDataTest extends Specification {
|
|||
a.app.sex mustEqual CharacterGender.Male
|
||||
a.app.head mustEqual 10
|
||||
a.app.voice mustEqual CharacterVoice.Voice2
|
||||
a.black_ops mustEqual false
|
||||
a.jammered mustEqual false
|
||||
a.data.bops mustEqual false
|
||||
a.data.v1 mustEqual false
|
||||
a.data.v2.isEmpty mustEqual true
|
||||
a.data.v3 mustEqual false
|
||||
a.data.v4.isEmpty mustEqual true
|
||||
a.data.v5.isEmpty mustEqual true
|
||||
a.exosuit mustEqual ExoSuitType.MAX
|
||||
a.unk1 mustEqual false
|
||||
a.unk2 mustEqual None
|
||||
a.unk3 mustEqual None
|
||||
a.unk4 mustEqual 0
|
||||
a.unk5 mustEqual 1
|
||||
a.unk6 mustEqual 0L
|
||||
a.unk7 mustEqual 0
|
||||
|
|
@ -251,7 +251,7 @@ class CharacterDataTest extends Specification {
|
|||
b.grenade_state mustEqual GrenadeState.None
|
||||
b.is_cloaking mustEqual false
|
||||
b.charging_pose mustEqual false
|
||||
b.on_zipline mustEqual None
|
||||
b.on_zipline.isEmpty mustEqual true
|
||||
b.unk0 mustEqual 529687L
|
||||
b.unk1 mustEqual false
|
||||
b.unk2 mustEqual false
|
||||
|
|
@ -275,12 +275,12 @@ class CharacterDataTest extends Specification {
|
|||
char.uniform_upgrade mustEqual UniformStyle.ThirdUpgrade
|
||||
char.command_rank mustEqual 2
|
||||
char.implant_effects.isEmpty mustEqual true
|
||||
char.cosmetics.isDefined mustEqual true
|
||||
char.cosmetics.get.no_helmet mustEqual true
|
||||
char.cosmetics.get.beret mustEqual true
|
||||
char.cosmetics.get.sunglasses mustEqual true
|
||||
char.cosmetics.get.earpiece mustEqual true
|
||||
char.cosmetics.get.brimmed_cap mustEqual false
|
||||
char.cosmetics match {
|
||||
case Some(c : Cosmetics) =>
|
||||
c.Styles mustEqual Set(PersonalStyle.NoHelmet, PersonalStyle.Beret, PersonalStyle.Sunglasses, PersonalStyle.Earpiece)
|
||||
case None =>
|
||||
ko
|
||||
}
|
||||
char.unk mustEqual 1
|
||||
|
||||
hand mustEqual DrawnSlot.Pistol1
|
||||
|
|
@ -306,14 +306,18 @@ class CharacterDataTest extends Specification {
|
|||
5,
|
||||
CharacterVoice.Voice5
|
||||
),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
ExoSuitType.Reinforced,
|
||||
None,
|
||||
0,
|
||||
0,
|
||||
30777081L,
|
||||
1,
|
||||
|
|
@ -341,7 +345,7 @@ class CharacterDataTest extends Specification {
|
|||
None
|
||||
)
|
||||
|
||||
val app : (Int)=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
val app : Int=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
a, b,
|
||||
RibbonBars(
|
||||
MeritCommendation.MarkovVeteran,
|
||||
|
|
@ -359,11 +363,11 @@ class CharacterDataTest extends Specification {
|
|||
Some(Cosmetics(true, true, true, true, false))
|
||||
)
|
||||
val inv = InventoryData(
|
||||
InventoryItemData(ObjectClass.plasma_grenade, PlanetSideGUID(3662), 0, WeaponData(0, 0, ObjectClass.plasma_grenade_ammo, PlanetSideGUID(3751), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.bank, PlanetSideGUID(3908), 1, WeaponData(0, 0, 1, ObjectClass.armor_canister, PlanetSideGUID(4143), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.mini_chaingun, PlanetSideGUID(4164), 2, WeaponData(0, 0, ObjectClass.bullet_9mm, PlanetSideGUID(3728), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.phoenix, PlanetSideGUID(3603), 3, WeaponData(0, 0, ObjectClass.phoenix_missile, PlanetSideGUID(3056), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.chainblade, PlanetSideGUID(4088), 4, WeaponData(0, 0, 1, ObjectClass.melee_ammo, PlanetSideGUID(3279), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.plasma_grenade, PlanetSideGUID(3662), 0, WeaponData(0, 0, ObjectClass.plasma_grenade_ammo, PlanetSideGUID(3751), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.bank, PlanetSideGUID(3908), 1, WeaponData(0, 0, 1, ObjectClass.armor_canister, PlanetSideGUID(4143), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.mini_chaingun, PlanetSideGUID(4164), 2, WeaponData(0, 0, ObjectClass.bullet_9mm, PlanetSideGUID(3728), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.phoenix, PlanetSideGUID(3603), 3, WeaponData(0, 0, ObjectClass.phoenix_missile, PlanetSideGUID(3056), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.chainblade, PlanetSideGUID(4088), 4, WeaponData(0, 0, 1, ObjectClass.melee_ammo, PlanetSideGUID(3279), 0, CommonFieldData()(false))) ::
|
||||
Nil
|
||||
)
|
||||
val obj = PlayerData(pos, app, char, inv, DrawnSlot.Rifle1)
|
||||
|
|
@ -382,14 +386,18 @@ class CharacterDataTest extends Specification {
|
|||
5,
|
||||
CharacterVoice.Voice5
|
||||
),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
ExoSuitType.Reinforced,
|
||||
None,
|
||||
0,
|
||||
0,
|
||||
192L,
|
||||
0,
|
||||
|
|
@ -417,7 +425,7 @@ class CharacterDataTest extends Specification {
|
|||
None
|
||||
)
|
||||
|
||||
val app : (Int)=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
val app : Int=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
a, b,
|
||||
RibbonBars(
|
||||
MeritCommendation.MarkovVeteran,
|
||||
|
|
@ -434,11 +442,11 @@ class CharacterDataTest extends Specification {
|
|||
Some(Cosmetics(true, true, true, true, false))
|
||||
)
|
||||
val inv = InventoryData(
|
||||
InventoryItemData(ObjectClass.plasma_grenade, PlanetSideGUID(3662), 0, WeaponData(0, 0, ObjectClass.plasma_grenade_ammo, PlanetSideGUID(3751), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.bank, PlanetSideGUID(3908), 1, WeaponData(0, 0, 1, ObjectClass.armor_canister, PlanetSideGUID(4143), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.mini_chaingun, PlanetSideGUID(4164), 2, WeaponData(0, 0, ObjectClass.bullet_9mm, PlanetSideGUID(3728), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.phoenix, PlanetSideGUID(3603), 3, WeaponData(0, 0, ObjectClass.phoenix_missile, PlanetSideGUID(3056), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.chainblade, PlanetSideGUID(4088), 4, WeaponData(0, 0, 1, ObjectClass.melee_ammo, PlanetSideGUID(3279), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.plasma_grenade, PlanetSideGUID(3662), 0, WeaponData(0, 0, ObjectClass.plasma_grenade_ammo, PlanetSideGUID(3751), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.bank, PlanetSideGUID(3908), 1, WeaponData(0, 0, 1, ObjectClass.armor_canister, PlanetSideGUID(4143), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.mini_chaingun, PlanetSideGUID(4164), 2, WeaponData(0, 0, ObjectClass.bullet_9mm, PlanetSideGUID(3728), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.phoenix, PlanetSideGUID(3603), 3, WeaponData(0, 0, ObjectClass.phoenix_missile, PlanetSideGUID(3056), 0, CommonFieldData()(false))) ::
|
||||
InventoryItemData(ObjectClass.chainblade, PlanetSideGUID(4088), 4, WeaponData(0, 0, 1, ObjectClass.melee_ammo, PlanetSideGUID(3279), 0, CommonFieldData()(false))) ::
|
||||
Nil
|
||||
)
|
||||
val obj = PlayerData(app, char, inv, DrawnSlot.Rifle1)
|
||||
|
|
@ -461,14 +469,18 @@ class CharacterDataTest extends Specification {
|
|||
10,
|
||||
CharacterVoice.Voice2
|
||||
),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.VS,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
ExoSuitType.MAX,
|
||||
None,
|
||||
0,
|
||||
1,
|
||||
0L,
|
||||
0,
|
||||
|
|
@ -496,7 +508,7 @@ class CharacterDataTest extends Specification {
|
|||
None
|
||||
)
|
||||
|
||||
val app : (Int)=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
val app : Int=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
a, b,
|
||||
RibbonBars(
|
||||
MeritCommendation.Jacking2,
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class CommandDetonaterDataTest extends Specification {
|
||||
val string_detonater_held = hex"17 76000000 1A886A8421080400000000"
|
||||
val string_detonater_dropped = hex"17 AF000000 EA8620ED1549B4B6A741500001B000000000"
|
||||
|
||||
"CommandDetonaterData" should {
|
||||
"decode (held)" in {
|
||||
PacketCoding.DecodePacket(string_detonater_held).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.command_detonater
|
||||
guid mustEqual PlanetSideGUID(4162)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4149)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[CommandDetonaterData] mustEqual true
|
||||
val cud = data.get.asInstanceOf[CommandDetonaterData]
|
||||
cud.unk1 mustEqual 4
|
||||
cud.unk2 mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (dropped)" in {
|
||||
PacketCoding.DecodePacket(string_detonater_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 175
|
||||
cls mustEqual ObjectClass.command_detonater
|
||||
guid mustEqual PlanetSideGUID(3682)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4777.633f
|
||||
drop.pos.coord.y mustEqual 5485.4062f
|
||||
drop.pos.coord.z mustEqual 85.8125f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 14.0625f
|
||||
drop.obj.isInstanceOf[CommandDetonaterData] mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = CommandDetonaterData(4)
|
||||
val msg = ObjectCreateMessage(ObjectClass.command_detonater, PlanetSideGUID(4162), ObjectCreateMessageParent(PlanetSideGUID(4149), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_detonater_held
|
||||
}
|
||||
|
||||
"encode (dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4777.633f, 5485.4062f, 85.8125f, 0f, 0f, 14.0625f),
|
||||
CommandDetonaterData()
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.command_detonater, PlanetSideGUID(3682), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_detonater_dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,123 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
// Copyright (c) 2019 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable._
|
||||
import org.specs2.mutable.Specification
|
||||
import scodec.bits._
|
||||
|
||||
class CommonFieldDataTest extends Specification {
|
||||
"CommonFieldData" should {
|
||||
"construct" in {
|
||||
CommonFieldData(PlacementData(0f, 0f, 0f), PlanetSideEmpire.NC, true, 5) mustEqual
|
||||
CommonFieldData(PlacementData(0f, 0f, 0f), PlanetSideEmpire.NC, false, true, 5, false, PlanetSideGUID(0))
|
||||
object CommonFieldDataTest extends Specification {
|
||||
val string_shotgunshell_dropped = hex"17 A5000000 F9A7D0D 5E269 BED5A F114 0000596000000"
|
||||
val string_implant_interface = hex"17 6C000000 01014C93304818000000"
|
||||
val string_order_terminala = hex"17 A5000000 B2AF30EACF1889F7A3D1200007D2000000"
|
||||
|
||||
"AmmoBoxData" should {
|
||||
"decode (shotgun shells, dropped)" in {
|
||||
PacketCoding.DecodePacket(string_shotgunshell_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.shotgun_shell
|
||||
guid mustEqual PlanetSideGUID(3453)
|
||||
parent.isDefined mustEqual false
|
||||
data.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4684.7344f
|
||||
drop.pos.coord.y mustEqual 5547.4844f
|
||||
drop.pos.coord.z mustEqual 83.765625f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 199.6875f
|
||||
drop.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (shotgun shells, dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4684.7344f, 5547.4844f, 83.765625f, 0f, 0f, 199.6875f),
|
||||
CommonFieldData()(false)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.shotgun_shell, PlanetSideGUID(3453), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_shotgunshell_dropped
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
"TerminalData" should {
|
||||
"decode (implant interface)" in {
|
||||
PacketCoding.DecodePacket(string_implant_interface).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 108
|
||||
cls mustEqual 0x199
|
||||
guid mustEqual PlanetSideGUID(1075)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(514)
|
||||
parent.get.slot mustEqual 1
|
||||
data.isInstanceOf[CommonFieldData] mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (order terminal a)" in {
|
||||
PacketCoding.DecodePacket(string_order_terminala).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.order_terminala
|
||||
guid mustEqual PlanetSideGUID(3827)
|
||||
parent.isDefined mustEqual false
|
||||
data.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4579.3438f
|
||||
drop.pos.coord.y mustEqual 5615.0703f
|
||||
drop.pos.coord.z mustEqual 72.953125f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 98.4375f
|
||||
drop.obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
drop.obj.asInstanceOf[CommonFieldData].faction mustEqual PlanetSideEmpire.NC
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (implant interface)" in {
|
||||
val obj = CommonFieldData(PlanetSideEmpire.VS)(false)
|
||||
val msg = ObjectCreateMessage(0x199, PlanetSideGUID(1075), ObjectCreateMessageParent(PlanetSideGUID(514), 1), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_implant_interface
|
||||
}
|
||||
|
||||
"encode (order terminal a)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4579.3438f, 5615.0703f, 72.953125f, 0f, 0f, 98.4375f),
|
||||
CommonFieldData(PlanetSideEmpire.NC)(false)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.order_terminala, PlanetSideGUID(3827), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_order_terminala
|
||||
}
|
||||
|
||||
"InternalSlot" in {
|
||||
TerminalData(ObjectClass.order_terminala, PlanetSideGUID(1), 1, CommonFieldData(PlanetSideEmpire.NC)(false)) mustEqual
|
||||
InternalSlot(ObjectClass.order_terminala, PlanetSideGUID(1), 1, CommonFieldData(PlanetSideEmpire.NC)(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class CommonFieldDataWithPlacementTest extends Specification {
|
||||
val string_boomer = hex"17 A5000000 CA0000F1630938D5A8F1400003F0031100"
|
||||
|
||||
"Boomer" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_boomer).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.boomer
|
||||
guid mustEqual PlanetSideGUID(3840)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case CommonFieldDataWithPlacement(pos, com) =>
|
||||
pos.coord mustEqual Vector3(4704.172f, 5546.4375f, 82.234375f)
|
||||
pos.orient mustEqual Vector3.z(272.8125f)
|
||||
com match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(8290)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(4704.172f, 5546.4375f, 82.234375f), Vector3.z(272.8125f)),
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, Some(false), None, PlanetSideGUID(8290))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.boomer, PlanetSideGUID(3840), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_boomer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class CommonTerminalDataTest extends Specification {
|
||||
val string_implant_interface = hex"17 6C000000 01014C93304818000000"
|
||||
val string_order_terminala = hex"17 A5000000 B2AF30EACF1889F7A3D1200007D2000000"
|
||||
|
||||
"CommonTerminalData" should {
|
||||
"decode (implant interface)" in {
|
||||
PacketCoding.DecodePacket(string_implant_interface).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 108
|
||||
cls mustEqual 0x199
|
||||
guid mustEqual PlanetSideGUID(1075)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(514)
|
||||
parent.get.slot mustEqual 1
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
data.get.asInstanceOf[CommonTerminalData].faction mustEqual PlanetSideEmpire.VS
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (order terminal a)" in {
|
||||
PacketCoding.DecodePacket(string_order_terminala).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.order_terminala
|
||||
guid mustEqual PlanetSideGUID(3827)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4579.3438f
|
||||
drop.pos.coord.y mustEqual 5615.0703f
|
||||
drop.pos.coord.z mustEqual 72.953125f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 98.4375f
|
||||
drop.obj.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
val term = drop.obj.asInstanceOf[CommonTerminalData]
|
||||
term.faction mustEqual PlanetSideEmpire.NC
|
||||
term.unk mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (implant interface)" in {
|
||||
val obj = CommonTerminalData(PlanetSideEmpire.VS)
|
||||
val msg = ObjectCreateMessage(0x199, PlanetSideGUID(1075), ObjectCreateMessageParent(PlanetSideGUID(514), 1), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_implant_interface
|
||||
}
|
||||
|
||||
"encode (order terminal a)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4579.3438f, 5615.0703f, 72.953125f, 0f, 0f, 98.4375f),
|
||||
CommonTerminalData(PlanetSideEmpire.NC)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.order_terminala, PlanetSideGUID(3827), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_order_terminala
|
||||
}
|
||||
|
||||
"InternalSlot" in {
|
||||
CommonTerminalData(ObjectClass.order_terminala, PlanetSideGUID(1), 1, CommonTerminalData(PlanetSideEmpire.NC)) mustEqual
|
||||
InternalSlot(ObjectClass.order_terminala, PlanetSideGUID(1), 1, CommonTerminalData(PlanetSideEmpire.NC))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class ContainedTelepadDeployableDataTest extends Specification {
|
||||
val string = hex"178f0000004080f42b00182cb0202000100000"
|
||||
|
||||
"ContainedTelepadDeployableData" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 143
|
||||
cls mustEqual 744
|
||||
guid mustEqual PlanetSideGUID(432)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(385)
|
||||
parent.get.slot mustEqual 2
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[ContainedTelepadDeployableData] mustEqual true
|
||||
data.get.asInstanceOf[ContainedTelepadDeployableData].unk mustEqual 101
|
||||
data.get.asInstanceOf[ContainedTelepadDeployableData].router_guid mustEqual PlanetSideGUID(385)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
"encode" in {
|
||||
val obj = ContainedTelepadDeployableData(101, PlanetSideGUID(385))
|
||||
val msg = ObjectCreateMessage(744, PlanetSideGUID(432), ObjectCreateMessageParent(PlanetSideGUID(385), 2), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
}
|
||||
249
common/src/test/scala/game/objectcreate/HandheldDataTest.scala
Normal file
249
common/src/test/scala/game/objectcreate/HandheldDataTest.scala
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class HandheldDataTest extends Specification {
|
||||
val string_ace_held = hex"17 76000000 0406900650C80480000000"
|
||||
val string_ace_dropped = hex"17 AF000000 90024113B329C5D5A2D1200005B440000000"
|
||||
|
||||
"ACE" should {
|
||||
"decode (held)" in {
|
||||
PacketCoding.DecodePacket(string_ace_held).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(3173)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3336)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid)) =>
|
||||
faction mustEqual PlanetSideEmpire.NC
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (dropped)" in {
|
||||
PacketCoding.DecodePacket(string_ace_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 175
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(4388)
|
||||
parent.isDefined mustEqual false
|
||||
data.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
data match {
|
||||
case DroppedItemData(pos, HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid))) =>
|
||||
pos.coord mustEqual Vector3(4708.461f, 5547.539f, 72.703125f)
|
||||
pos.orient mustEqual Vector3.z(194.0625f)
|
||||
|
||||
faction mustEqual PlanetSideEmpire.VS
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = HandheldData(CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, None, None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateMessage(ObjectClass.ace, PlanetSideGUID(3173), ObjectCreateMessageParent(PlanetSideGUID(3336), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_ace_held
|
||||
}
|
||||
|
||||
"encode (dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4708.461f, 5547.539f, 72.703125f, 0f, 0f, 194.0625f),
|
||||
HandheldData(CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, None, None, PlanetSideGUID(0)))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.ace, PlanetSideGUID(4388), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_ace_dropped
|
||||
}
|
||||
}
|
||||
|
||||
val string_telepad = hex"17 86000000 5700 f3a a201 80 0302020000000"
|
||||
|
||||
"Telepad" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_telepad).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 134
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(418)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(430)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid)) =>
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.contains(385) mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = HandheldData(CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, None, Some(385), PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateMessage(ObjectClass.router_telepad, PlanetSideGUID(418), ObjectCreateMessageParent(PlanetSideGUID(430), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_telepad
|
||||
}
|
||||
}
|
||||
|
||||
val string_boomertrigger = hex"17 76000000 58084A8100E80C00000000" //reconstructed from an inventory entry
|
||||
|
||||
"Boomer Trigger" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_boomertrigger).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.boomer_trigger
|
||||
guid mustEqual PlanetSideGUID(3600)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4272)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid)) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = HandheldData(CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, None, None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateMessage(ObjectClass.boomer_trigger, PlanetSideGUID(3600), ObjectCreateMessageParent(PlanetSideGUID(4272), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_boomertrigger
|
||||
}
|
||||
}
|
||||
|
||||
val string_detonater_held = hex"17 76000000 1A886A8421080400000000"
|
||||
val string_detonater_dropped = hex"17 AF000000 EA8620ED1549B4B6A741500001B000000000"
|
||||
|
||||
"Command Detonater" should {
|
||||
"decode (held)" in {
|
||||
PacketCoding.DecodePacket(string_detonater_held).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 118
|
||||
cls mustEqual ObjectClass.command_detonater
|
||||
guid mustEqual PlanetSideGUID(4162)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4149)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid)) =>
|
||||
faction mustEqual PlanetSideEmpire.NC
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (dropped)" in {
|
||||
PacketCoding.DecodePacket(string_detonater_dropped).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 175
|
||||
cls mustEqual ObjectClass.command_detonater
|
||||
guid mustEqual PlanetSideGUID(3682)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case DroppedItemData(pos, HandheldData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid))) =>
|
||||
pos.coord mustEqual Vector3(4777.633f, 5485.4062f, 85.8125f)
|
||||
pos.orient mustEqual Vector3.z(14.0625f)
|
||||
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = HandheldData(CommonFieldData(PlanetSideEmpire.NC, false, false, false, None, false, None, None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateMessage(ObjectClass.command_detonater, PlanetSideGUID(4162), ObjectCreateMessageParent(PlanetSideGUID(4149), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_detonater_held
|
||||
}
|
||||
|
||||
"encode (dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4777.633f, 5485.4062f, 85.8125f, 0f, 0f, 14.0625f),
|
||||
HandheldData(CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, None, None, PlanetSideGUID(0)))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.command_detonater, PlanetSideGUID(3682), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_detonater_dropped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ package game.objectcreate
|
|||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -18,36 +19,43 @@ class LockerContainerDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.locker_container
|
||||
guid mustEqual PlanetSideGUID(3148)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[LockerContainerData] mustEqual true
|
||||
val locker = data.get.asInstanceOf[LockerContainerData]
|
||||
val contents = locker.inventory.contents
|
||||
contents.size mustEqual 3
|
||||
//0
|
||||
contents.head.objectClass mustEqual ObjectClass.nano_dispenser
|
||||
contents.head.guid mustEqual PlanetSideGUID(2935)
|
||||
contents.head.parentSlot mustEqual 0
|
||||
contents.head.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val dispenser = contents.head.obj.asInstanceOf[WeaponData]
|
||||
dispenser.unk1 mustEqual 0x6
|
||||
dispenser.unk2 mustEqual 0x0
|
||||
dispenser.ammo.head.objectClass mustEqual ObjectClass.armor_canister
|
||||
dispenser.ammo.head.guid mustEqual PlanetSideGUID(3426)
|
||||
dispenser.ammo.head.parentSlot mustEqual 0
|
||||
dispenser.ammo.head.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
dispenser.ammo.head.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0
|
||||
//1
|
||||
contents(1).objectClass mustEqual ObjectClass.armor_canister
|
||||
contents(1).guid mustEqual PlanetSideGUID(4090)
|
||||
contents(1).parentSlot mustEqual 45
|
||||
contents(1).obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
contents(1).obj.asInstanceOf[AmmoBoxData].unk mustEqual 0
|
||||
//2
|
||||
contents(2).objectClass mustEqual ObjectClass.armor_canister
|
||||
contents(2).guid mustEqual PlanetSideGUID(3326)
|
||||
contents(2).parentSlot mustEqual 78
|
||||
contents(2).obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
contents(2).obj.asInstanceOf[AmmoBoxData].unk mustEqual 0
|
||||
data.isInstanceOf[LockerContainerData] mustEqual true
|
||||
val locker = data.asInstanceOf[LockerContainerData]
|
||||
locker.inventory match {
|
||||
case Some(InventoryData(contents)) =>
|
||||
contents.size mustEqual 3
|
||||
//0
|
||||
contents.head.objectClass mustEqual ObjectClass.nano_dispenser
|
||||
contents.head.guid mustEqual PlanetSideGUID(2935)
|
||||
contents.head.parentSlot mustEqual 0
|
||||
contents.head.obj match {
|
||||
case WeaponData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid), _, _, _) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//1
|
||||
contents(1).objectClass mustEqual ObjectClass.armor_canister
|
||||
contents(1).guid mustEqual PlanetSideGUID(4090)
|
||||
contents(1).parentSlot mustEqual 45
|
||||
contents(1).obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
//2
|
||||
contents(2).objectClass mustEqual ObjectClass.armor_canister
|
||||
contents(2).guid mustEqual PlanetSideGUID(3326)
|
||||
contents(2).parentSlot mustEqual 78
|
||||
contents(2).obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
case None =>
|
||||
ko
|
||||
}
|
||||
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -55,12 +63,17 @@ class LockerContainerDataTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val obj = LockerContainerData(
|
||||
InventoryData(
|
||||
InventoryItemData(ObjectClass.nano_dispenser, PlanetSideGUID(2935), 0, WeaponData(0x6, 0x0, ObjectClass.armor_canister, PlanetSideGUID(3426), 0, AmmoBoxData())) ::
|
||||
InventoryItemData(ObjectClass.armor_canister, PlanetSideGUID(4090), 45, AmmoBoxData()) ::
|
||||
InventoryItemData(ObjectClass.armor_canister, PlanetSideGUID(3326), 78, AmmoBoxData()) ::
|
||||
Nil
|
||||
)
|
||||
InventoryData(List(
|
||||
InventoryItemData(ObjectClass.nano_dispenser, PlanetSideGUID(2935), 0,
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.armor_canister, PlanetSideGUID(3426), 0, CommonFieldData()(false)))
|
||||
)
|
||||
),
|
||||
InventoryItemData(ObjectClass.armor_canister, PlanetSideGUID(4090), 45, CommonFieldData()(false)),
|
||||
InventoryItemData(ObjectClass.armor_canister, PlanetSideGUID(3326), 78, CommonFieldData()(false))
|
||||
))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.locker_container, PlanetSideGUID(3148), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -19,31 +19,62 @@ class OneMannedFieldTurretDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.portable_manned_turret_vs
|
||||
guid mustEqual PlanetSideGUID(2916)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[OneMannedFieldTurretData] mustEqual true
|
||||
val omft = data.get.asInstanceOf[OneMannedFieldTurretData]
|
||||
omft.deploy.pos.coord mustEqual Vector3(3567.1406f, 2988.0078f, 71.84375f)
|
||||
omft.deploy.pos.orient mustEqual Vector3(0, 0, 185.625f)
|
||||
omft.deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
omft.deploy.unk1 mustEqual 2
|
||||
omft.deploy.owner_guid mustEqual PlanetSideGUID(2502)
|
||||
omft.health mustEqual 255
|
||||
omft.internals.isDefined mustEqual true
|
||||
val internals = omft.internals.get.contents
|
||||
internals.head.objectClass mustEqual ObjectClass.energy_gun_vs
|
||||
internals.head.guid mustEqual PlanetSideGUID(2615)
|
||||
internals.head.parentSlot mustEqual 1
|
||||
internals.head.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = internals.head.obj.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 0x6
|
||||
wep.unk2 mustEqual 0x8
|
||||
wep.fire_mode mustEqual 0
|
||||
val ammo = wep.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.energy_gun_ammo
|
||||
ammo.guid mustEqual PlanetSideGUID(2510)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 8
|
||||
data match {
|
||||
case OneMannedFieldTurretData(CommonFieldDataWithPlacement(pos, deploy), health, Some(InventoryData(inv))) =>
|
||||
pos.coord mustEqual Vector3(3567.1406f, 2988.0078f, 71.84375f)
|
||||
pos.orient mustEqual Vector3.z(185.625f)
|
||||
deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
deploy.bops mustEqual false
|
||||
deploy.alternate mustEqual false
|
||||
deploy.v1 mustEqual true
|
||||
deploy.v2.isEmpty mustEqual true
|
||||
deploy.v3 mustEqual false
|
||||
deploy.v4.contains(false) mustEqual true
|
||||
deploy.v5.isEmpty mustEqual true
|
||||
deploy.guid mustEqual PlanetSideGUID(2502)
|
||||
|
||||
health mustEqual 255
|
||||
|
||||
inv.head.objectClass mustEqual ObjectClass.energy_gun_vs
|
||||
inv.head.guid mustEqual PlanetSideGUID(2615)
|
||||
inv.head.parentSlot mustEqual 1
|
||||
inv.head.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.energy_gun_ammo
|
||||
ammo.guid mustEqual PlanetSideGUID(2510)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -51,52 +82,26 @@ class OneMannedFieldTurretDataTest extends Specification {
|
|||
|
||||
"encode (orion)" in {
|
||||
val obj = OneMannedFieldTurretData(
|
||||
SmallDeployableData(
|
||||
PlacementData(Vector3(3567.1406f, 2988.0078f, 71.84375f), Vector3(0, 0, 185.625f)),
|
||||
PlanetSideEmpire.VS, false, false, 2, false, false, PlanetSideGUID(2502)
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(3567.1406f, 2988.0078f, 71.84375f), Vector3.z(185.625f)),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(false), None, PlanetSideGUID(2502))
|
||||
),
|
||||
255,
|
||||
InventoryData(List(OneMannedFieldTurretData.orion(PlanetSideGUID(2615), 0x6, 0x8, PlanetSideGUID(2510), 8)))
|
||||
InventoryData(List(
|
||||
InternalSlot(ObjectClass.energy_gun_vs, PlanetSideGUID(2615), 1,
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.energy_gun_ammo, PlanetSideGUID(2510), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.portable_manned_turret_vs, PlanetSideGUID(2916), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_orion
|
||||
}
|
||||
|
||||
"avenger" in {
|
||||
OneMannedFieldTurretData.avenger(PlanetSideGUID(1), 2, 3, PlanetSideGUID(4), 5) mustEqual
|
||||
InternalSlot(ObjectClass.energy_gun_tr, PlanetSideGUID(1), 1,
|
||||
WeaponData(2, 3, ObjectClass.energy_gun_ammo, PlanetSideGUID(4), 0,
|
||||
AmmoBoxData(5)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"generic" in {
|
||||
OneMannedFieldTurretData.generic(PlanetSideGUID(1), 2, 3, PlanetSideGUID(4), 5) mustEqual
|
||||
InternalSlot(ObjectClass.energy_gun, PlanetSideGUID(1), 1,
|
||||
WeaponData(2, 3, ObjectClass.energy_gun_ammo, PlanetSideGUID(4), 0,
|
||||
AmmoBoxData(5)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"orion" in {
|
||||
OneMannedFieldTurretData.orion(PlanetSideGUID(1), 2, 3, PlanetSideGUID(4), 5) mustEqual
|
||||
InternalSlot(ObjectClass.energy_gun_vs, PlanetSideGUID(1), 1,
|
||||
WeaponData(2, 3, ObjectClass.energy_gun_ammo, PlanetSideGUID(4), 0,
|
||||
AmmoBoxData(5)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
"osprey" in {
|
||||
OneMannedFieldTurretData.osprey(PlanetSideGUID(1), 2, 3, PlanetSideGUID(4), 5) mustEqual
|
||||
InternalSlot(ObjectClass.energy_gun_nc, PlanetSideGUID(1), 1,
|
||||
WeaponData(2, 3, ObjectClass.energy_gun_ammo, PlanetSideGUID(4), 0,
|
||||
AmmoBoxData(5)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package game.objectcreate
|
|||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -21,12 +22,21 @@ class REKDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4174)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[REKData] mustEqual true
|
||||
val rek = data.get.asInstanceOf[REKData]
|
||||
rek.unk1 mustEqual 0
|
||||
rek.unk2 mustEqual 8
|
||||
rek.unk3 mustEqual 0
|
||||
data match {
|
||||
case REKData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid), unk) =>
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
unk mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -39,27 +49,32 @@ class REKDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.remote_electronics_kit
|
||||
guid mustEqual PlanetSideGUID(4355)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val dropped = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
dropped.pos.coord.x mustEqual 4675.039f
|
||||
dropped.pos.coord.y mustEqual 5506.953f
|
||||
dropped.pos.coord.z mustEqual 72.703125f
|
||||
dropped.pos.orient.x mustEqual 0f
|
||||
dropped.pos.orient.y mustEqual 0f
|
||||
dropped.pos.orient.z mustEqual 230.625f
|
||||
dropped.obj.isInstanceOf[REKData] mustEqual true
|
||||
val rek = dropped.obj.asInstanceOf[REKData]
|
||||
rek.unk1 mustEqual 8
|
||||
rek.unk2 mustEqual 0
|
||||
rek.unk3 mustEqual 3
|
||||
data match {
|
||||
case DroppedItemData(pos, REKData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid), unk)) =>
|
||||
pos.coord mustEqual Vector3(4675.039f, 5506.953f, 72.703125f)
|
||||
pos.orient mustEqual Vector3.z(230.625f)
|
||||
|
||||
faction mustEqual PlanetSideEmpire.VS
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
unk mustEqual 3
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (held)" in {
|
||||
val obj = REKData(0, 8)
|
||||
val obj = REKData(CommonFieldData(PlanetSideEmpire.TR, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateMessage(ObjectClass.remote_electronics_kit, PlanetSideGUID(3893), ObjectCreateMessageParent(PlanetSideGUID(4174), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_rek_held
|
||||
|
|
@ -68,7 +83,7 @@ class REKDataTest extends Specification {
|
|||
"encode (dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4675.039f, 5506.953f, 72.703125f, 0f, 0f, 230.625f),
|
||||
REKData(8, 0, 3)
|
||||
REKData(CommonFieldData(PlanetSideEmpire.VS, false, false, false, None, false, Some(false), None, PlanetSideGUID(0)), 3)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.remote_electronics_kit, PlanetSideGUID(4355), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class SmallDeployableDataTest extends Specification {
|
||||
val string_boomer = hex"17 A5000000 CA0000F1630938D5A8F1400003F0031100"
|
||||
|
||||
"SmallDeployableData" should {
|
||||
"decode (boomer)" in {
|
||||
PacketCoding.DecodePacket(string_boomer).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 165
|
||||
cls mustEqual ObjectClass.boomer
|
||||
guid mustEqual PlanetSideGUID(3840)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[SmallDeployableData] mustEqual true
|
||||
val boomer = data.get.asInstanceOf[SmallDeployableData]
|
||||
boomer.pos.coord.x mustEqual 4704.172f
|
||||
boomer.pos.coord.y mustEqual 5546.4375f
|
||||
boomer.pos.coord.z mustEqual 82.234375f
|
||||
boomer.pos.orient.x mustEqual 0f
|
||||
boomer.pos.orient.y mustEqual 0f
|
||||
boomer.pos.orient.z mustEqual 272.8125f
|
||||
boomer.unk1 mustEqual 0
|
||||
boomer.owner_guid mustEqual PlanetSideGUID(8290)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (boomer)" in {
|
||||
val obj = SmallDeployableData(
|
||||
PlacementData(Vector3(4704.172f, 5546.4375f, 82.234375f), Vector3.z(272.8125f)),
|
||||
PlanetSideEmpire.TR, false, false, 0, false, false, PlanetSideGUID(8290)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.boomer, PlanetSideGUID(3840), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_boomer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package game.objectcreate
|
|||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate.{SmallDeployableData, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
|
@ -20,17 +20,25 @@ class SmallTurretDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.spitfire_turret
|
||||
guid mustEqual PlanetSideGUID(4208)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[SmallTurretData] mustEqual true
|
||||
val turret = data.get.asInstanceOf[SmallTurretData]
|
||||
turret.deploy.pos.coord mustEqual Vector3(4577.7812f, 5624.828f, 72.046875f)
|
||||
turret.deploy.pos.orient mustEqual Vector3(0, 2.8125f, 264.375f)
|
||||
turret.deploy.faction mustEqual PlanetSideEmpire.NC
|
||||
turret.deploy.destroyed mustEqual true
|
||||
turret.deploy.unk1 mustEqual 2
|
||||
turret.deploy.owner_guid mustEqual PlanetSideGUID(7742)
|
||||
turret.health mustEqual 0
|
||||
turret.internals.isDefined mustEqual false
|
||||
data match {
|
||||
case SmallTurretData(CommonFieldDataWithPlacement(pos, deploy), health, None) =>
|
||||
pos.coord mustEqual Vector3(4577.7812f, 5624.828f, 72.046875f)
|
||||
pos.orient mustEqual Vector3(0, 2.8125f, 264.375f)
|
||||
|
||||
deploy.faction mustEqual PlanetSideEmpire.NC
|
||||
deploy.bops mustEqual false
|
||||
deploy.alternate mustEqual true
|
||||
deploy.v1 mustEqual true
|
||||
deploy.v2.isEmpty mustEqual true
|
||||
deploy.v3 mustEqual false
|
||||
deploy.v4.contains(false) mustEqual true
|
||||
deploy.v5.isEmpty mustEqual true
|
||||
deploy.guid mustEqual PlanetSideGUID(7742)
|
||||
|
||||
health mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -43,31 +51,64 @@ class SmallTurretDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.spitfire_turret
|
||||
guid mustEqual PlanetSideGUID(4265)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[SmallTurretData] mustEqual true
|
||||
val turret = data.get.asInstanceOf[SmallTurretData]
|
||||
turret.deploy.pos.coord mustEqual Vector3(4527.633f, 6271.3594f, 70.265625f)
|
||||
turret.deploy.pos.orient mustEqual Vector3(0, 0, 154.6875f)
|
||||
turret.deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
turret.deploy.unk1 mustEqual 2
|
||||
turret.deploy.owner_guid mustEqual PlanetSideGUID(8208)
|
||||
turret.health mustEqual 255
|
||||
turret.internals.isDefined mustEqual true
|
||||
val internals = turret.internals.get.contents
|
||||
internals.head.objectClass mustEqual ObjectClass.spitfire_weapon
|
||||
internals.head.guid mustEqual PlanetSideGUID(3064)
|
||||
internals.head.parentSlot mustEqual 0
|
||||
internals.head.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = internals.head.obj.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 0x6
|
||||
wep.unk2 mustEqual 0x8
|
||||
wep.fire_mode mustEqual 0
|
||||
val ammo = wep.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.spitfire_ammo
|
||||
ammo.guid mustEqual PlanetSideGUID(3694)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 8
|
||||
data match {
|
||||
case SmallTurretData(CommonFieldDataWithPlacement(pos, deploy), health, Some(InventoryData(inv))) =>
|
||||
pos.coord mustEqual Vector3(4527.633f, 6271.3594f, 70.265625f)
|
||||
pos.orient mustEqual Vector3.z(154.6875f)
|
||||
|
||||
deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
deploy.bops mustEqual false
|
||||
deploy.alternate mustEqual false
|
||||
deploy.v1 mustEqual true
|
||||
deploy.v2.isEmpty mustEqual true
|
||||
deploy.v3 mustEqual false
|
||||
deploy.v4.contains(true) mustEqual true
|
||||
deploy.v5.isEmpty mustEqual true
|
||||
deploy.guid mustEqual PlanetSideGUID(8208)
|
||||
|
||||
health mustEqual 255
|
||||
|
||||
inv.head.objectClass mustEqual ObjectClass.spitfire_weapon
|
||||
inv.head.guid mustEqual PlanetSideGUID(3064)
|
||||
inv.head.parentSlot mustEqual 0
|
||||
inv.head.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
inv.head.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.spitfire_ammo
|
||||
ammo.guid mustEqual PlanetSideGUID(3694)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -75,11 +116,11 @@ class SmallTurretDataTest extends Specification {
|
|||
|
||||
"encode (spitfire, short)" in {
|
||||
val obj = SmallTurretData(
|
||||
SmallDeployableData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(4577.7812f, 5624.828f, 72.046875f), Vector3(0, 2.8125f, 264.375f)),
|
||||
PlanetSideEmpire.NC, false, true, 2, false, false, PlanetSideGUID(7742)
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, true, true, None, false, Some(false), None, PlanetSideGUID(7742))
|
||||
),
|
||||
255 //sets to 0
|
||||
0
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.spitfire_turret, PlanetSideGUID(4208), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -88,12 +129,23 @@ class SmallTurretDataTest extends Specification {
|
|||
|
||||
"encode (spitfire)" in {
|
||||
val obj = SmallTurretData(
|
||||
SmallDeployableData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(4527.633f, 6271.3594f, 70.265625f), Vector3(0, 0, 154.6875f)),
|
||||
PlanetSideEmpire.VS, false, false, 2, false, true, PlanetSideGUID(8208)
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(true), None, PlanetSideGUID(8208))
|
||||
),
|
||||
255,
|
||||
InventoryData(List(SmallTurretData.spitfire(PlanetSideGUID(3064), 0x6, 0x8, PlanetSideGUID(3694), 8)))
|
||||
InventoryData(List(
|
||||
InternalSlot(ObjectClass.spitfire_weapon, PlanetSideGUID(3064), 0,
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.spitfire_ammo, PlanetSideGUID(3694), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, Some(false), None, PlanetSideGUID(0))
|
||||
))
|
||||
)
|
||||
)
|
||||
//SmallTurretData.spitfire(PlanetSideGUID(3064), 0x6, 0x8, PlanetSideGUID(3694), 8)
|
||||
))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.spitfire_turret, PlanetSideGUID(4265), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -19,14 +19,23 @@ class TRAPDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.tank_traps
|
||||
guid mustEqual PlanetSideGUID(2659)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[TRAPData] mustEqual true
|
||||
val trap = data.get.asInstanceOf[TRAPData]
|
||||
trap.deploy.pos.coord mustEqual Vector3(3572.4453f, 3277.9766f, 114.0f)
|
||||
trap.deploy.pos.orient mustEqual Vector3(0, 0, 90)
|
||||
trap.deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
trap.deploy.owner_guid mustEqual PlanetSideGUID(4748)
|
||||
trap.health mustEqual 255
|
||||
data match {
|
||||
case TRAPData(CommonFieldDataWithPlacement(pos, deploy), health) =>
|
||||
pos.coord mustEqual Vector3(3572.4453f, 3277.9766f, 114.0f)
|
||||
pos.orient mustEqual Vector3.z(90)
|
||||
deploy.faction mustEqual PlanetSideEmpire.VS
|
||||
deploy.bops mustEqual false
|
||||
deploy.alternate mustEqual false
|
||||
deploy.v1 mustEqual true
|
||||
deploy.v2.isEmpty mustEqual true
|
||||
deploy.v3 mustEqual false
|
||||
deploy.v4.contains(true) mustEqual true
|
||||
deploy.v5.isEmpty mustEqual true
|
||||
deploy.guid mustEqual PlanetSideGUID(4748)
|
||||
health mustEqual 255
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -34,9 +43,9 @@ class TRAPDataTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val obj = TRAPData(
|
||||
SmallDeployableData(
|
||||
PlacementData(3572.4453f, 3277.9766f, 114.0f, 0f, 0f, 90.0f),
|
||||
PlanetSideEmpire.VS, false, false, 2, false, true, PlanetSideGUID(4748)
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3(3572.4453f, 3277.9766f, 114.0f), Vector3.z(90)),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(true), None, PlanetSideGUID(4748))
|
||||
),
|
||||
255
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreate
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class TelepadDataTest extends Specification {
|
||||
val string = hex"17 86000000 5700 f3a a201 80 0302020000000"
|
||||
//TODO validate the unknown fields before router_guid for testing
|
||||
|
||||
"TelepadData" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 134
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(418)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(430)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[TelepadData] mustEqual true
|
||||
data.get.asInstanceOf[TelepadData].router_guid mustEqual Some(PlanetSideGUID(385))
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = TelepadData(0, PlanetSideGUID(385))
|
||||
val msg = ObjectCreateMessage(ObjectClass.router_telepad, PlanetSideGUID(418), ObjectCreateMessageParent(PlanetSideGUID(430), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,37 +20,57 @@ class TelepadDeployableDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.router_telepad_deployable
|
||||
guid mustEqual PlanetSideGUID(353)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[TelepadDeployableData] mustEqual true
|
||||
val teledata = data.get.asInstanceOf[TelepadDeployableData]
|
||||
teledata.pos.coord mustEqual Vector3(6559.961f, 1960.1172f, 13.640625f)
|
||||
teledata.pos.orient mustEqual Vector3.z(109.6875f)
|
||||
teledata.pos.vel.isDefined mustEqual false
|
||||
teledata.faction mustEqual PlanetSideEmpire.TR
|
||||
teledata.bops mustEqual false
|
||||
teledata.destroyed mustEqual false
|
||||
teledata.unk1 mustEqual 2
|
||||
teledata.unk2 mustEqual true
|
||||
teledata.router_guid mustEqual PlanetSideGUID(385)
|
||||
teledata.owner_guid mustEqual PlanetSideGUID(430)
|
||||
teledata.unk3 mustEqual 87
|
||||
teledata.unk4 mustEqual 12
|
||||
data match {
|
||||
case DroppedItemData(pos, telepad) =>
|
||||
pos.coord mustEqual Vector3(6559.961f, 1960.1172f, 13.640625f)
|
||||
pos.orient mustEqual Vector3.z(109.6875f)
|
||||
pos.vel.isDefined mustEqual false
|
||||
|
||||
telepad match {
|
||||
case TelepadDeployableData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid), u1, u2) =>
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.contains(385) mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(430)
|
||||
|
||||
u1 mustEqual 87
|
||||
u2 mustEqual 12
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = TelepadDeployableData(
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(
|
||||
Vector3(6559.961f, 1960.1172f, 13.640625f),
|
||||
Vector3.z(109.6875f)
|
||||
),
|
||||
PlanetSideEmpire.TR,
|
||||
false, false, 2, true,
|
||||
PlanetSideGUID(385),
|
||||
PlanetSideGUID(430),
|
||||
87, 12
|
||||
TelepadDeployableData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
Some(385),
|
||||
PlanetSideGUID(430)
|
||||
),
|
||||
87, 12
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.router_telepad_deployable, PlanetSideGUID(353), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package game.objectcreate
|
|||
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate.{ObjectClass, PlacementData, TrackedProjectileData}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -11,32 +12,45 @@ class TrackedProjectileDataTest extends Specification {
|
|||
val string_striker_projectile = hex"17 C5000000 A4B 009D 4C129 0CB0A 9814 00 F5 E3 040000666686400"
|
||||
|
||||
"TrackedProjectileData" should {
|
||||
"decode (striker projectile)" in {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_striker_projectile).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 197
|
||||
cls mustEqual ObjectClass.striker_missile_targeting_projectile
|
||||
guid mustEqual PlanetSideGUID(40192)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[TrackedProjectileData] mustEqual true
|
||||
val projectile = data.get.asInstanceOf[TrackedProjectileData]
|
||||
projectile.pos.coord.x mustEqual 4644.5938f
|
||||
projectile.pos.coord.y mustEqual 5472.0938f
|
||||
projectile.pos.coord.z mustEqual 82.375f
|
||||
projectile.pos.orient.x mustEqual 0f
|
||||
projectile.pos.orient.y mustEqual 30.9375f
|
||||
projectile.pos.orient.z mustEqual 171.5625f
|
||||
projectile.unk1 mustEqual 0
|
||||
projectile.unk2 mustEqual TrackedProjectileData.striker_missile_targetting_projectile_data
|
||||
data match {
|
||||
case TrackedProjectileData(CommonFieldDataWithPlacement(pos, deploy), unk2, unk3) =>
|
||||
pos.coord mustEqual Vector3(4644.5938f, 5472.0938f, 82.375f)
|
||||
pos.orient mustEqual Vector3(0, 30.9375f, 171.5625f)
|
||||
deploy.faction mustEqual PlanetSideEmpire.TR
|
||||
deploy.bops mustEqual false
|
||||
deploy.alternate mustEqual false
|
||||
deploy.v1 mustEqual true
|
||||
deploy.v2.isEmpty mustEqual true
|
||||
deploy.v3 mustEqual false
|
||||
deploy.v4.isEmpty mustEqual true
|
||||
deploy.v5.isEmpty mustEqual true
|
||||
deploy.guid mustEqual PlanetSideGUID(0)
|
||||
|
||||
unk2 mustEqual TrackedProjectile.Striker
|
||||
|
||||
unk3 mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (striker projectile)" in {
|
||||
val obj = TrackedProjectileData.striker(
|
||||
PlacementData(4644.5938f, 5472.0938f, 82.375f, 0f, 30.9375f, 171.5625f),
|
||||
"encode" in {
|
||||
val obj = TrackedProjectileData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(4644.5938f, 5472.0938f, 82.375f, 0f, 30.9375f, 171.5625f),
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
),
|
||||
TrackedProjectile.Striker,
|
||||
0
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.striker_missile_targeting_projectile, PlanetSideGUID(40192), obj)
|
||||
|
|
@ -46,25 +60,5 @@ class TrackedProjectileDataTest extends Specification {
|
|||
pkt.toBitVector.drop(133).take(7) mustEqual string_striker_projectile.toBitVector.drop(133).take(7)
|
||||
pkt.toBitVector.drop(141) mustEqual string_striker_projectile.toBitVector.drop(141)
|
||||
}
|
||||
|
||||
"hunter_seeker" in {
|
||||
TrackedProjectileData.hunter_seeker(PlacementData(0f, 0f, 0f), 0) mustEqual
|
||||
TrackedProjectileData(PlacementData(0f, 0f, 0f), 0, TrackedProjectileData.hunter_seeker_missile_projectile_data)
|
||||
}
|
||||
|
||||
"oicw" in {
|
||||
TrackedProjectileData.oicw(PlacementData(0f, 0f, 0f), 0) mustEqual
|
||||
TrackedProjectileData(PlacementData(0f, 0f, 0f), 0, TrackedProjectileData.oicw_projectile_data)
|
||||
}
|
||||
|
||||
"starfire" in {
|
||||
TrackedProjectileData.starfire(PlacementData(0f, 0f, 0f), 0) mustEqual
|
||||
TrackedProjectileData(PlacementData(0f, 0f, 0f), 0, TrackedProjectileData.starfire_projectile_data)
|
||||
}
|
||||
|
||||
"striker" in {
|
||||
TrackedProjectileData.striker(PlacementData(0f, 0f, 0f), 0) mustEqual
|
||||
TrackedProjectileData(PlacementData(0f, 0f, 0f), 0, TrackedProjectileData.striker_missile_targetting_projectile_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package game.objectcreate
|
|||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -23,18 +24,40 @@ class WeaponDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(4141)
|
||||
parent.get.slot mustEqual 3
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = data.get.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 4
|
||||
wep.unk2 mustEqual 8
|
||||
wep.fire_mode mustEqual 0
|
||||
wep.ammo.head.objectClass mustEqual ObjectClass.energy_cell
|
||||
wep.ammo.head.guid mustEqual PlanetSideGUID(3548)
|
||||
wep.ammo.head.parentSlot mustEqual 0
|
||||
wep.ammo.head.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
val ammo = wep.ammo.head.obj.asInstanceOf[AmmoBoxData]
|
||||
ammo.unk mustEqual 8
|
||||
data match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.VS
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.energy_cell
|
||||
ammo.guid mustEqual PlanetSideGUID(3548)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -49,26 +72,59 @@ class WeaponDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3092)
|
||||
parent.get.slot mustEqual 3
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = data.get.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 4
|
||||
wep.unk2 mustEqual 8
|
||||
wep.fire_mode mustEqual 0
|
||||
val ammo = wep.ammo
|
||||
ammo.size mustEqual 2
|
||||
//0
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(3918)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.head.obj.asInstanceOf[AmmoBoxData].unk mustEqual 8
|
||||
//1
|
||||
ammo(1).objectClass mustEqual ObjectClass.rocket
|
||||
ammo(1).guid mustEqual PlanetSideGUID(3941)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo(1).obj.asInstanceOf[AmmoBoxData].unk mustEqual 8
|
||||
data match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, ammo, _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.VS
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
//0
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(3918)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//1
|
||||
//1
|
||||
ammo(1).objectClass mustEqual ObjectClass.rocket
|
||||
ammo(1).guid mustEqual PlanetSideGUID(3941)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -81,26 +137,48 @@ class WeaponDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.lasher
|
||||
guid mustEqual PlanetSideGUID(3074)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
data.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4691.1953f
|
||||
drop.pos.coord.y mustEqual 5537.039f
|
||||
drop.pos.coord.z mustEqual 65.484375f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 0f
|
||||
drop.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = drop.obj.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 4
|
||||
wep.unk2 mustEqual 0
|
||||
wep.fire_mode mustEqual 0
|
||||
wep.ammo.head.objectClass mustEqual ObjectClass.energy_cell
|
||||
wep.ammo.head.guid mustEqual PlanetSideGUID(3268)
|
||||
wep.ammo.head.parentSlot mustEqual 0
|
||||
wep.ammo.head.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
val ammo = wep.ammo.head.obj.asInstanceOf[AmmoBoxData]
|
||||
ammo.unk mustEqual 0
|
||||
drop.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.VS
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual false
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.energy_cell
|
||||
ammo.guid mustEqual PlanetSideGUID(3268)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -113,41 +191,78 @@ class WeaponDataTest extends Specification {
|
|||
cls mustEqual ObjectClass.punisher
|
||||
guid mustEqual PlanetSideGUID(2978)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.get.asInstanceOf[DroppedItemData[_]]
|
||||
data.isInstanceOf[DroppedItemData[_]] mustEqual true
|
||||
val drop = data.asInstanceOf[DroppedItemData[_]]
|
||||
drop.pos.coord.x mustEqual 4789.133f
|
||||
drop.pos.coord.y mustEqual 5522.3125f
|
||||
drop.pos.coord.z mustEqual 72.3125f
|
||||
drop.pos.orient.x mustEqual 0f
|
||||
drop.pos.orient.y mustEqual 0f
|
||||
drop.pos.orient.z mustEqual 306.5625f
|
||||
drop.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val wep = drop.obj.asInstanceOf[WeaponData]
|
||||
wep.unk1 mustEqual 2
|
||||
wep.unk2 mustEqual 0
|
||||
wep.fire_mode mustEqual 0
|
||||
val ammo = wep.ammo
|
||||
ammo.size mustEqual 2
|
||||
//0
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(3528)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.head.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0
|
||||
//1
|
||||
ammo(1).objectClass mustEqual ObjectClass.rocket
|
||||
ammo(1).guid mustEqual PlanetSideGUID(3031)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo(1).obj.asInstanceOf[AmmoBoxData].unk mustEqual 0
|
||||
drop.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, ammo, _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NC
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual false
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
//0
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(3528)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//1
|
||||
//1
|
||||
ammo(1).objectClass mustEqual ObjectClass.rocket
|
||||
ammo(1).guid mustEqual PlanetSideGUID(3031)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (lasher, held)" in {
|
||||
val obj = WeaponData(4, 8, ObjectClass.energy_cell, PlanetSideGUID(3548), 0, AmmoBoxData(8))
|
||||
val obj = WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.energy_cell, PlanetSideGUID(3548), 0, CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)))
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.lasher, PlanetSideGUID(3033), ObjectCreateMessageParent(PlanetSideGUID(4141), 3), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_lasher_held
|
||||
|
|
@ -155,11 +270,14 @@ class WeaponDataTest extends Specification {
|
|||
|
||||
"encode (punisher, held)" in {
|
||||
val obj =
|
||||
WeaponData(4, 8, 0,
|
||||
AmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(3918), 0, AmmoBoxData(8)) ::
|
||||
AmmoBoxData(ObjectClass.rocket, PlanetSideGUID(3941), 1, AmmoBoxData(8)) ::
|
||||
Nil
|
||||
)(2)
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(
|
||||
AmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(3918), 0, CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)),
|
||||
AmmoBoxData(ObjectClass.rocket, PlanetSideGUID(3941), 1, CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false))
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.punisher, PlanetSideGUID(4147), ObjectCreateMessageParent(PlanetSideGUID(3092), 3), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_punisher_held
|
||||
|
|
@ -168,7 +286,11 @@ class WeaponDataTest extends Specification {
|
|||
"encode (lasher, dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4691.1953f, 5537.039f, 65.484375f, 0.0f, 0.0f, 0.0f),
|
||||
WeaponData(4, 0, ObjectClass.energy_cell, PlanetSideGUID(3268), 0, AmmoBoxData())
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, false, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.energy_cell, PlanetSideGUID(3268), 0, CommonFieldData()(false)))
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.lasher, PlanetSideGUID(3074), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -178,11 +300,14 @@ class WeaponDataTest extends Specification {
|
|||
"encode (punisher, dropped)" in {
|
||||
val obj = DroppedItemData(
|
||||
PlacementData(4789.133f, 5522.3125f, 72.3125f, 0f, 0f, 306.5625f),
|
||||
WeaponData(2, 0, 0,
|
||||
AmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(3528), 0, AmmoBoxData()) ::
|
||||
AmmoBoxData(ObjectClass.rocket, PlanetSideGUID(3031), 1, AmmoBoxData()) ::
|
||||
Nil
|
||||
)(2)
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, false, false, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(
|
||||
AmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(3528), 0, CommonFieldData()(false)),
|
||||
AmmoBoxData(ObjectClass.rocket, PlanetSideGUID(3031), 1, CommonFieldData()(false))
|
||||
)
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.punisher, PlanetSideGUID(2978), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreatedetailed
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedACEDataTest extends Specification {
|
||||
val string_ace = hex"18 87000000 1006 100 C70B 80 8800000200008"
|
||||
|
||||
"DetailedACEData" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_ace).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(3015)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3104)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DetailedACEData] mustEqual true
|
||||
data.get.asInstanceOf[DetailedACEData].unk mustEqual 8
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedACEData(8)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.ace, PlanetSideGUID(3015), ObjectCreateMessageParent(PlanetSideGUID(3104), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_ace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,7 @@ class DetailedAmmoBoxDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(75)
|
||||
parent.get.slot mustEqual 33
|
||||
data.isDefined mustEqual true
|
||||
data.get.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 50
|
||||
data.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 50
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -30,7 +29,8 @@ class DetailedAmmoBoxDataTest extends Specification {
|
|||
"encode (9mm)" in {
|
||||
val obj = DetailedAmmoBoxData(8, 50)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.bullet_9mm, PlanetSideGUID(1280), ObjectCreateMessageParent(PlanetSideGUID(75), 33), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val out = PacketCoding.EncodePacket(msg)
|
||||
val pkt = out.require.toByteVector
|
||||
|
||||
pkt mustEqual string_9mm
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreatedetailed
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedBoomerTriggerDataTest extends Specification {
|
||||
val string_boomer_trigger = hex"18 87000000 6304CA8760B 80 C800000200008"
|
||||
|
||||
"DetailedBoomerTriggerData" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_boomer_trigger).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.boomer_trigger
|
||||
guid mustEqual PlanetSideGUID(2934)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(2502)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DetailedBoomerTriggerData] mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedBoomerTriggerData()
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.boomer_trigger, PlanetSideGUID(2934), ObjectCreateMessageParent(PlanetSideGUID(2502), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_boomer_trigger
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,6 +5,7 @@ import org.specs2.mutable._
|
|||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedCommandDetonaterDataTest extends Specification {
|
||||
|
|
@ -20,15 +21,29 @@ class DetailedCommandDetonaterDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3530)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DetailedCommandDetonaterData] mustEqual true
|
||||
data match {
|
||||
case DetailedCommandDetonaterData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid)) =>
|
||||
faction mustEqual PlanetSideEmpire.VS
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
data.isInstanceOf[DetailedCommandDetonaterData] mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedCommandDetonaterData()
|
||||
val obj = DetailedCommandDetonaterData(CommonFieldData(PlanetSideEmpire.VS, false, false, false, None, false, None, None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.command_detonater, PlanetSideGUID(8308), ObjectCreateMessageParent(PlanetSideGUID(3530), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_detonater
|
||||
|
|
|
|||
|
|
@ -0,0 +1,172 @@
|
|||
// Copyright (c) 2019 PSForever
|
||||
package game.objectcreatedetailed
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedConstructionToolDataTest extends Specification {
|
||||
val string_ace = hex"18 87000000 1006 100 C70B 80 8800000200008"
|
||||
val string_boomer_trigger = hex"18 87000000 6304CA8760B 80 C800000200008"
|
||||
val string_telepad = hex"18 97000000 4f00 f3a e301 80 4a680400000200008"
|
||||
val string_telepad_short = hex"18 87000000 2a00 f3a 5d01 89 8000000200008"
|
||||
|
||||
"ACE (detailed)" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_ace).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.ace
|
||||
guid mustEqual PlanetSideGUID(3015)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(3104)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case DetailedConstructionToolData(cdata) =>
|
||||
cdata.faction mustEqual PlanetSideEmpire.VS
|
||||
cdata.bops mustEqual false
|
||||
cdata.alternate mustEqual false
|
||||
cdata.v1 mustEqual true
|
||||
cdata.v2.isEmpty mustEqual true
|
||||
cdata.v3 mustEqual false
|
||||
cdata.v4.isEmpty mustEqual true
|
||||
cdata.v5.isEmpty mustEqual true
|
||||
cdata.guid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.ace, PlanetSideGUID(3015), ObjectCreateMessageParent(PlanetSideGUID(3104), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_ace
|
||||
}
|
||||
}
|
||||
|
||||
"Boomer Trigger (detailed)" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_boomer_trigger).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.boomer_trigger
|
||||
guid mustEqual PlanetSideGUID(2934)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(2502)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case DetailedConstructionToolData(cdata) =>
|
||||
cdata.faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
cdata.bops mustEqual false
|
||||
cdata.alternate mustEqual false
|
||||
cdata.v1 mustEqual true
|
||||
cdata.v2.isEmpty mustEqual true
|
||||
cdata.v3 mustEqual false
|
||||
cdata.v4.isEmpty mustEqual true
|
||||
cdata.v5.isEmpty mustEqual true
|
||||
cdata.guid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.boomer_trigger, PlanetSideGUID(2934), ObjectCreateMessageParent(PlanetSideGUID(2502), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_boomer_trigger
|
||||
}
|
||||
}
|
||||
|
||||
"Telepad (detailed)" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_telepad).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 151
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(483)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(414)
|
||||
parent.get.slot mustEqual 0
|
||||
data match {
|
||||
case DetailedConstructionToolData(cdata) =>
|
||||
cdata.faction mustEqual PlanetSideEmpire.NC
|
||||
cdata.bops mustEqual false
|
||||
cdata.alternate mustEqual false
|
||||
cdata.v1 mustEqual true
|
||||
cdata.v2.isEmpty mustEqual true
|
||||
cdata.v3 mustEqual false
|
||||
cdata.v4.isEmpty mustEqual true
|
||||
cdata.v5.contains(564) mustEqual true
|
||||
cdata.guid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (short)" in {
|
||||
PacketCoding.DecodePacket(string_telepad_short).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(349)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(340)
|
||||
parent.get.slot mustEqual 9
|
||||
data match {
|
||||
case DetailedConstructionToolData(cdata) =>
|
||||
cdata.faction mustEqual PlanetSideEmpire.VS
|
||||
cdata.bops mustEqual false
|
||||
cdata.alternate mustEqual false
|
||||
cdata.v1 mustEqual false
|
||||
cdata.v2.isEmpty mustEqual true
|
||||
cdata.v3 mustEqual false
|
||||
cdata.v4.isEmpty mustEqual true
|
||||
cdata.v5.isEmpty mustEqual true
|
||||
cdata.guid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, None, Some(564), PlanetSideGUID(0))
|
||||
)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(483), ObjectCreateMessageParent(PlanetSideGUID(414), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_telepad
|
||||
}
|
||||
|
||||
"encode (short)" in {
|
||||
val obj = DetailedConstructionToolData(CommonFieldData(PlanetSideEmpire.VS))
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(349), ObjectCreateMessageParent(PlanetSideGUID(340), 9), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_telepad_short
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.specs2.mutable._
|
|||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedREKDataTest extends Specification {
|
||||
|
|
@ -20,16 +21,28 @@ class DetailedREKDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(75)
|
||||
parent.get.slot mustEqual 1
|
||||
data.isDefined mustEqual true
|
||||
data.get.asInstanceOf[DetailedREKData].unk1 mustEqual 4
|
||||
data.get.asInstanceOf[DetailedREKData].unk2 mustEqual 0
|
||||
data match {
|
||||
case DetailedREKData(CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid), unk) =>
|
||||
faction mustEqual PlanetSideEmpire.NC
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
unk mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedREKData(4)
|
||||
val obj = DetailedREKData(CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.remote_electronics_kit, PlanetSideGUID(1439), ObjectCreateMessageParent(PlanetSideGUID(75), 1), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game.objectcreatedetailed
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedTelepadDataTest extends Specification {
|
||||
val string = hex"18 97000000 4f00 f3a e301 80 4a680400000200008"
|
||||
val string_short = hex"18 87000000 2a00 f3a 5d01 89 8000000200008"
|
||||
//TODO validate the unknown fields before router_guid for testing
|
||||
|
||||
"DetailedTelepadData" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 151
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(483)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(414)
|
||||
parent.get.slot mustEqual 0
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DetailedTelepadData] mustEqual true
|
||||
data.get.asInstanceOf[DetailedTelepadData].router_guid mustEqual Some(PlanetSideGUID(564))
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (short)" in {
|
||||
PacketCoding.DecodePacket(string_short).require match {
|
||||
case ObjectCreateDetailedMessage(len, cls, guid, parent, data) =>
|
||||
len mustEqual 135
|
||||
cls mustEqual ObjectClass.router_telepad
|
||||
guid mustEqual PlanetSideGUID(349)
|
||||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(340)
|
||||
parent.get.slot mustEqual 9
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DetailedTelepadData] mustEqual true
|
||||
data.get.asInstanceOf[DetailedTelepadData].router_guid mustEqual None
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val obj = DetailedTelepadData(18, PlanetSideGUID(564))
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(483), ObjectCreateMessageParent(PlanetSideGUID(414), 0), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"encode (short)" in {
|
||||
val obj = DetailedTelepadData(32)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.router_telepad, PlanetSideGUID(349), ObjectCreateMessageParent(PlanetSideGUID(340), 9), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_short
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.specs2.mutable._
|
|||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateDetailedMessage, _}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import scodec.bits._
|
||||
|
||||
class DetailedWeaponDataTest extends Specification {
|
||||
|
|
@ -21,15 +22,33 @@ class DetailedWeaponDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(75)
|
||||
parent.get.slot mustEqual 2
|
||||
data.isDefined mustEqual true
|
||||
val obj_wep = data.get.asInstanceOf[DetailedWeaponData]
|
||||
obj_wep.unk1 mustEqual 2
|
||||
obj_wep.unk2 mustEqual 8
|
||||
val obj_ammo = obj_wep.ammo
|
||||
obj_ammo.head.objectClass mustEqual 28
|
||||
obj_ammo.head.guid mustEqual PlanetSideGUID(1286)
|
||||
obj_ammo.head.parentSlot mustEqual 0
|
||||
obj_ammo.head.obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 30
|
||||
data match {
|
||||
case DetailedWeaponData(cdata, fmode, ammo, _) =>
|
||||
cdata match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NC
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.size mustEqual 1
|
||||
ammo.head.objectClass mustEqual 28
|
||||
ammo.head.guid mustEqual PlanetSideGUID(1286)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 30
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -44,27 +63,48 @@ class DetailedWeaponDataTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(75)
|
||||
parent.get.slot mustEqual 2
|
||||
data.isDefined mustEqual true
|
||||
val obj_wep = data.get.asInstanceOf[DetailedWeaponData]
|
||||
obj_wep.unk1 mustEqual 0
|
||||
obj_wep.unk2 mustEqual 8
|
||||
val obj_ammo = obj_wep.ammo
|
||||
obj_ammo.size mustEqual 2
|
||||
obj_ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
obj_ammo.head.guid mustEqual PlanetSideGUID(1693)
|
||||
obj_ammo.head.parentSlot mustEqual 0
|
||||
obj_ammo.head.obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 30
|
||||
obj_ammo(1).objectClass mustEqual ObjectClass.jammer_cartridge
|
||||
obj_ammo(1).guid mustEqual PlanetSideGUID(1564)
|
||||
obj_ammo(1).parentSlot mustEqual 1
|
||||
obj_ammo(1).obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 1
|
||||
data match {
|
||||
case DetailedWeaponData(cdata, fmode, ammo, _) =>
|
||||
cdata match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.TR
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.isEmpty mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.size mustEqual 2
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_9mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(1693)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 30
|
||||
ammo(1).objectClass mustEqual ObjectClass.jammer_cartridge
|
||||
ammo(1).guid mustEqual PlanetSideGUID(1564)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj.asInstanceOf[DetailedAmmoBoxData].magazine mustEqual 1
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (gauss)" in {
|
||||
val obj = DetailedWeaponData(2, 8, ObjectClass.bullet_9mm, PlanetSideGUID(1286), 0, DetailedAmmoBoxData(8, 30))
|
||||
val obj = DetailedWeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(ObjectClass.bullet_9mm, PlanetSideGUID(1286), 0, DetailedAmmoBoxData(8, 30)))
|
||||
)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.gauss, PlanetSideGUID(1465), ObjectCreateMessageParent(PlanetSideGUID(75), 2), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
|
|
@ -72,11 +112,24 @@ class DetailedWeaponDataTest extends Specification {
|
|||
}
|
||||
|
||||
"encode (punisher)" in {
|
||||
val obj = DetailedWeaponData(0, 8, 0,
|
||||
DetailedAmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(1693), 0, DetailedAmmoBoxData(8, 30)) ::
|
||||
DetailedAmmoBoxData(ObjectClass.jammer_cartridge, PlanetSideGUID(1564), 1, DetailedAmmoBoxData(8, 1)) ::
|
||||
Nil
|
||||
)(2)
|
||||
val obj = DetailedWeaponData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
0,
|
||||
List(
|
||||
DetailedAmmoBoxData(ObjectClass.bullet_9mm, PlanetSideGUID(1693), 0, DetailedAmmoBoxData(8, 30)),
|
||||
DetailedAmmoBoxData(ObjectClass.jammer_cartridge, PlanetSideGUID(1564), 1, DetailedAmmoBoxData(8, 1))
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateDetailedMessage(ObjectClass.punisher, PlanetSideGUID(1703), ObjectCreateMessageParent(PlanetSideGUID(75), 2), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
package game.objectcreatevehicle
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -18,9 +18,8 @@ class DestroyedVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.ams_destroyed
|
||||
guid mustEqual PlanetSideGUID(4157)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DestroyedVehicleData] mustEqual true
|
||||
val dams = data.get.asInstanceOf[DestroyedVehicleData]
|
||||
data.isInstanceOf[DestroyedVehicleData] mustEqual true
|
||||
val dams = data.asInstanceOf[DestroyedVehicleData]
|
||||
dams.pos.coord.x mustEqual 3674.0f
|
||||
dams.pos.coord.y mustEqual 2726.789f
|
||||
dams.pos.coord.z mustEqual 91.15625f
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
package game.objectcreatevehicle
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
|
@ -22,28 +22,28 @@ class MountedVehiclesTest extends Specification {
|
|||
len mustEqual 1991
|
||||
cls mustEqual ObjectClass.mosquito
|
||||
guid mustEqual PlanetSideGUID(4308)
|
||||
parent mustEqual None
|
||||
parent.isEmpty mustEqual true
|
||||
data match {
|
||||
case Some(vdata : VehicleData) =>
|
||||
case vdata : VehicleData =>
|
||||
vdata.pos.coord mustEqual Vector3(4571.6875f, 5602.1875f, 93)
|
||||
vdata.pos.orient mustEqual Vector3(11.25f, 2.8125f, 92.8125f)
|
||||
vdata.pos.vel mustEqual Some(Vector3(31.71875f, 8.875f, -0.03125f))
|
||||
vdata.faction mustEqual PlanetSideEmpire.TR
|
||||
vdata.bops mustEqual false
|
||||
vdata.destroyed mustEqual false
|
||||
vdata.jammered mustEqual false
|
||||
vdata.owner_guid mustEqual PlanetSideGUID(3776)
|
||||
vdata.pos.vel.contains(Vector3(31.71875f, 8.875f, -0.03125f)) mustEqual true
|
||||
vdata.data.faction mustEqual PlanetSideEmpire.TR
|
||||
vdata.data.bops mustEqual false
|
||||
vdata.data.alternate mustEqual false
|
||||
vdata.data.v1 mustEqual false
|
||||
vdata.data.v3 mustEqual false
|
||||
vdata.data.v5.isEmpty mustEqual true
|
||||
vdata.data.guid mustEqual PlanetSideGUID(3776)
|
||||
vdata.health mustEqual 255
|
||||
vdata.no_mount_points mustEqual false
|
||||
vdata.driveState mustEqual DriveState.Mobile
|
||||
vdata.cloak mustEqual false
|
||||
vdata.unk1 mustEqual 0
|
||||
vdata.unk2 mustEqual false
|
||||
vdata.unk3 mustEqual false
|
||||
vdata.unk4 mustEqual false
|
||||
vdata.unk5 mustEqual false
|
||||
vdata.unk6 mustEqual false
|
||||
vdata.vehicle_format_data mustEqual Some(VariantVehicleData(7))
|
||||
vdata.vehicle_format_data.contains(VariantVehicleData(7)) mustEqual true
|
||||
vdata.inventory match {
|
||||
case Some(InventoryData(list)) =>
|
||||
list.head.objectClass mustEqual ObjectClass.avatar
|
||||
|
|
@ -54,13 +54,13 @@ class MountedVehiclesTest extends Specification {
|
|||
app match {
|
||||
case CharacterAppearanceData(a, b, ribbons) =>
|
||||
a.app mustEqual BasicCharacterData("ScrawnyRonnie", PlanetSideEmpire.TR, CharacterGender.Male, 5, CharacterVoice.Voice5)
|
||||
a.black_ops mustEqual false
|
||||
a.jammered mustEqual false
|
||||
a.data.bops mustEqual false
|
||||
a.data.v1 mustEqual false
|
||||
a.data.v2.isEmpty mustEqual true
|
||||
a.data.v3 mustEqual false
|
||||
a.data.v4.isEmpty mustEqual true
|
||||
a.data.v5.isEmpty mustEqual true
|
||||
a.exosuit mustEqual ExoSuitType.Agile
|
||||
a.unk1 mustEqual false
|
||||
a.unk2 mustEqual None
|
||||
a.unk3 mustEqual None
|
||||
a.unk4 mustEqual 0
|
||||
a.unk5 mustEqual 0
|
||||
a.unk6 mustEqual 30777081L
|
||||
a.unk7 mustEqual 1
|
||||
|
|
@ -77,7 +77,7 @@ class MountedVehiclesTest extends Specification {
|
|||
b.grenade_state mustEqual GrenadeState.None
|
||||
b.is_cloaking mustEqual false
|
||||
b.charging_pose mustEqual false
|
||||
b.on_zipline mustEqual None
|
||||
b.on_zipline.isEmpty mustEqual true
|
||||
b.unk0 mustEqual 316554L
|
||||
b.unk1 mustEqual false
|
||||
b.unk2 mustEqual false
|
||||
|
|
@ -99,7 +99,7 @@ class MountedVehiclesTest extends Specification {
|
|||
unk mustEqual 7
|
||||
cr mustEqual 5
|
||||
implants mustEqual Nil
|
||||
cosmetics mustEqual Some(Cosmetics(true, true, true, true, false))
|
||||
cosmetics.contains(Cosmetics(true, true, true, true, false)) mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -139,14 +139,18 @@ class MountedVehiclesTest extends Specification {
|
|||
5,
|
||||
CharacterVoice.Voice5
|
||||
),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
ExoSuitType.Agile,
|
||||
None,
|
||||
0,
|
||||
0,
|
||||
30777081L,
|
||||
1,
|
||||
|
|
@ -174,7 +178,7 @@ class MountedVehiclesTest extends Specification {
|
|||
None
|
||||
)
|
||||
|
||||
val app : (Int)=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
val app : Int=>CharacterAppearanceData = CharacterAppearanceData(
|
||||
a, b,
|
||||
RibbonBars(
|
||||
MeritCommendation.MarkovVeteran,
|
||||
|
|
@ -194,16 +198,16 @@ class MountedVehiclesTest extends Specification {
|
|||
val inv : InventoryData = InventoryData(
|
||||
List(
|
||||
InternalSlot(ObjectClass.medicalapplicator, PlanetSideGUID(4201), 0,
|
||||
WeaponData(0, 0, 0, List(InternalSlot(ObjectClass.health_canister, PlanetSideGUID(3472), 0, AmmoBoxData(0))))
|
||||
WeaponData(CommonFieldData(PlanetSideEmpire.TR), 0, List(InternalSlot(ObjectClass.health_canister, PlanetSideGUID(3472), 0, CommonFieldData()(false))))
|
||||
),
|
||||
InternalSlot(ObjectClass.bank, PlanetSideGUID(2952), 1,
|
||||
WeaponData(0, 0, 0, List(InternalSlot(ObjectClass.armor_canister, PlanetSideGUID(3758), 0, AmmoBoxData(0))))
|
||||
WeaponData(CommonFieldData(PlanetSideEmpire.TR), 0, List(InternalSlot(ObjectClass.armor_canister, PlanetSideGUID(3758), 0, CommonFieldData()(false))))
|
||||
),
|
||||
InternalSlot(ObjectClass.mini_chaingun, PlanetSideGUID(2929), 2,
|
||||
WeaponData(0, 0, 0, List(InternalSlot(ObjectClass.bullet_9mm, PlanetSideGUID(3292), 0, AmmoBoxData(0))))
|
||||
WeaponData(CommonFieldData(PlanetSideEmpire.TR), 0, List(InternalSlot(ObjectClass.bullet_9mm, PlanetSideGUID(3292), 0, CommonFieldData()(false))))
|
||||
),
|
||||
InternalSlot(ObjectClass.chainblade, PlanetSideGUID(3222), 4,
|
||||
WeaponData(0, 0, 0, List(InternalSlot(ObjectClass.melee_ammo, PlanetSideGUID(3100), 0, AmmoBoxData(0))))
|
||||
WeaponData(CommonFieldData(PlanetSideEmpire.TR), 0, List(InternalSlot(ObjectClass.melee_ammo, PlanetSideGUID(3100), 0, CommonFieldData()(false))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -214,11 +218,7 @@ class MountedVehiclesTest extends Specification {
|
|||
Vector3(11.25f, 2.8125f, 92.8125f),
|
||||
Some(Vector3(31.71875f, 8.875f, -0.03125f))
|
||||
),
|
||||
PlanetSideEmpire.TR,
|
||||
false, false,
|
||||
0,
|
||||
false, false,
|
||||
PlanetSideGUID(3776),
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, Some(false), None, PlanetSideGUID(3776)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
|
|
@ -230,7 +230,7 @@ class MountedVehiclesTest extends Specification {
|
|||
List(
|
||||
InternalSlot(ObjectClass.avatar, PlanetSideGUID(3776), 0, player),
|
||||
InternalSlot(ObjectClass.rotarychaingun_mosquito, PlanetSideGUID(3602), 1,
|
||||
WeaponData(6, 0, 0, List(InternalSlot(ObjectClass.bullet_12mm, PlanetSideGUID(3538), 0, AmmoBoxData(0))))
|
||||
WeaponData(CommonFieldData(), 0, List(InternalSlot(ObjectClass.bullet_12mm, PlanetSideGUID(3538), 0, CommonFieldData()(false))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
package game.objectcreatevehicle
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
|
@ -21,19 +21,25 @@ class NonstandardVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.droppod
|
||||
guid mustEqual PlanetSideGUID(3595)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[DroppodData] mustEqual true
|
||||
val droppod = data.get.asInstanceOf[DroppodData]
|
||||
droppod.basic.pos.coord.x mustEqual 5108.0f
|
||||
droppod.basic.pos.coord.y mustEqual 6164.0f
|
||||
droppod.basic.pos.coord.z mustEqual 1023.9844f
|
||||
droppod.basic.pos.orient.x mustEqual 0f
|
||||
droppod.basic.pos.orient.y mustEqual 0f
|
||||
droppod.basic.pos.orient.z mustEqual 90.0f
|
||||
droppod.basic.unk mustEqual 2
|
||||
droppod.basic.player_guid mustEqual PlanetSideGUID(0)
|
||||
droppod.burn mustEqual false
|
||||
droppod.health mustEqual 255
|
||||
data match {
|
||||
case DroppodData(basic, burn, health) =>
|
||||
basic.pos.coord mustEqual Vector3(5108.0f, 6164.0f, 1023.9844f)
|
||||
basic.pos.orient mustEqual Vector3.z(90.0f)
|
||||
|
||||
basic.data.faction mustEqual PlanetSideEmpire.VS
|
||||
basic.data.bops mustEqual false
|
||||
basic.data.alternate mustEqual false
|
||||
basic.data.v1 mustEqual true
|
||||
basic.data.v2.isDefined mustEqual false
|
||||
basic.data.v3 mustEqual false
|
||||
basic.data.v5.isDefined mustEqual false
|
||||
basic.data.guid mustEqual PlanetSideGUID(0)
|
||||
|
||||
burn mustEqual false
|
||||
health mustEqual 255
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -48,10 +54,9 @@ class NonstandardVehiclesTest extends Specification {
|
|||
parent.isDefined mustEqual true
|
||||
parent.get.guid mustEqual PlanetSideGUID(786)
|
||||
parent.get.slot mustEqual 3
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[OrbitalShuttleData] mustEqual true
|
||||
data.get.asInstanceOf[OrbitalShuttleData].faction mustEqual PlanetSideEmpire.VS
|
||||
data.get.asInstanceOf[OrbitalShuttleData].pos.isDefined mustEqual false
|
||||
data.isInstanceOf[OrbitalShuttleData] mustEqual true
|
||||
data.asInstanceOf[OrbitalShuttleData].faction mustEqual PlanetSideEmpire.VS
|
||||
data.asInstanceOf[OrbitalShuttleData].pos.isDefined mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -64,9 +69,8 @@ class NonstandardVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.orbital_shuttle
|
||||
guid mustEqual PlanetSideGUID(1127)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[OrbitalShuttleData] mustEqual true
|
||||
val shuttle = data.get.asInstanceOf[OrbitalShuttleData]
|
||||
data.isInstanceOf[OrbitalShuttleData] mustEqual true
|
||||
val shuttle = data.asInstanceOf[OrbitalShuttleData]
|
||||
shuttle.faction mustEqual PlanetSideEmpire.VS
|
||||
shuttle.pos.isDefined mustEqual true
|
||||
shuttle.pos.get.coord.x mustEqual 5610.0156f
|
||||
|
|
@ -82,10 +86,9 @@ class NonstandardVehiclesTest extends Specification {
|
|||
|
||||
"encode (droppod)" in {
|
||||
val obj = DroppodData(
|
||||
CommonFieldData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(5108.0f, 6164.0f, 1023.9844f, 0f, 0f, 90.0f),
|
||||
PlanetSideEmpire.VS,
|
||||
2
|
||||
CommonFieldData(PlanetSideEmpire.VS, 2)
|
||||
)
|
||||
)
|
||||
val msg = ObjectCreateMessage(ObjectClass.droppod, PlanetSideGUID(3595), obj)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
package game.objectcreatevehicle
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
|
@ -21,15 +21,14 @@ class NormalVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.fury
|
||||
guid mustEqual PlanetSideGUID(413)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val fury = data.get.asInstanceOf[VehicleData]
|
||||
data.isInstanceOf[VehicleData] mustEqual true
|
||||
val fury = data.asInstanceOf[VehicleData]
|
||||
fury.pos.coord mustEqual Vector3(6531.961f, 1872.1406f,24.734375f)
|
||||
fury.pos.orient mustEqual Vector3(0, 0, 357.1875f)
|
||||
fury.pos.vel mustEqual None
|
||||
fury.faction mustEqual PlanetSideEmpire.VS
|
||||
fury.unk1 mustEqual 2
|
||||
fury.owner_guid mustEqual PlanetSideGUID(0)
|
||||
fury.pos.vel.isEmpty mustEqual true
|
||||
fury.data.faction mustEqual PlanetSideEmpire.VS
|
||||
fury.data.v1 mustEqual true
|
||||
fury.data.guid mustEqual PlanetSideGUID(0)
|
||||
fury.health mustEqual 255
|
||||
//
|
||||
fury.inventory.isDefined mustEqual true
|
||||
|
|
@ -39,17 +38,40 @@ class NormalVehiclesTest extends Specification {
|
|||
mounting.guid mustEqual PlanetSideGUID(400)
|
||||
mounting.parentSlot mustEqual 1
|
||||
mounting.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val weapon = mounting.obj.asInstanceOf[WeaponData]
|
||||
weapon.unk1 mustEqual 0x6
|
||||
weapon.unk2 mustEqual 0x8
|
||||
weapon.fire_mode mustEqual 0
|
||||
weapon.ammo.size mustEqual 1
|
||||
val ammo = weapon.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.hellfire_ammo
|
||||
ammo.guid mustEqual PlanetSideGUID(432)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x8
|
||||
mounting.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, ammo, _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.head.objectClass mustEqual ObjectClass.hellfire_ammo
|
||||
ammo.head.guid mustEqual PlanetSideGUID(432)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -62,15 +84,14 @@ class NormalVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.lightning
|
||||
guid mustEqual PlanetSideGUID(90)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val lightning = data.get.asInstanceOf[VehicleData]
|
||||
data.isInstanceOf[VehicleData] mustEqual true
|
||||
val lightning = data.asInstanceOf[VehicleData]
|
||||
lightning.pos.coord mustEqual Vector3(3674.8438f, 2726.789f, 91.15625f)
|
||||
lightning.pos.orient mustEqual Vector3(0, 0, 90)
|
||||
lightning.pos.vel mustEqual None
|
||||
lightning.faction mustEqual PlanetSideEmpire.VS
|
||||
lightning.unk1 mustEqual 2
|
||||
lightning.owner_guid mustEqual PlanetSideGUID(0)
|
||||
lightning.pos.vel.isEmpty mustEqual true
|
||||
lightning.data.faction mustEqual PlanetSideEmpire.VS
|
||||
lightning.data.v1 mustEqual true
|
||||
lightning.data.guid mustEqual PlanetSideGUID(0)
|
||||
lightning.health mustEqual 255
|
||||
|
||||
lightning.inventory.isDefined mustEqual true
|
||||
|
|
@ -79,26 +100,59 @@ class NormalVehiclesTest extends Specification {
|
|||
mounting.objectClass mustEqual ObjectClass.lightning_weapon_system
|
||||
mounting.guid mustEqual PlanetSideGUID(91)
|
||||
mounting.parentSlot mustEqual 1
|
||||
mounting.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
val weapon = mounting.obj.asInstanceOf[WeaponData]
|
||||
weapon.unk1 mustEqual 0x4
|
||||
weapon.unk2 mustEqual 0x8
|
||||
weapon.fire_mode mustEqual 0
|
||||
weapon.ammo.size mustEqual 2
|
||||
//0
|
||||
var ammo = weapon.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_75mm
|
||||
ammo.guid mustEqual PlanetSideGUID(92)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x0
|
||||
//1
|
||||
ammo = weapon.ammo(1)
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_25mm
|
||||
ammo.guid mustEqual PlanetSideGUID(93)
|
||||
ammo.parentSlot mustEqual 1
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x0
|
||||
mounting.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, ammo, _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.VS
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
//0
|
||||
ammo.head.objectClass mustEqual ObjectClass.bullet_75mm
|
||||
ammo.head.guid mustEqual PlanetSideGUID(92)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//1
|
||||
ammo(1).objectClass mustEqual ObjectClass.bullet_25mm
|
||||
ammo(1).guid mustEqual PlanetSideGUID(93)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual false
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -111,62 +165,104 @@ class NormalVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.mediumtransport
|
||||
guid mustEqual PlanetSideGUID(387)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val deliverer = data.get.asInstanceOf[VehicleData]
|
||||
deliverer.pos.coord mustEqual Vector3(6531.961f, 1872.1406f, 24.734375f)
|
||||
deliverer.pos.orient mustEqual Vector3(0, 0, 357.1875f)
|
||||
deliverer.pos.vel mustEqual None
|
||||
deliverer.faction mustEqual PlanetSideEmpire.NC
|
||||
deliverer.owner_guid mustEqual PlanetSideGUID(0)
|
||||
deliverer.health mustEqual 255
|
||||
deliverer.driveState mustEqual DriveState.State7
|
||||
deliverer.jammered mustEqual false
|
||||
deliverer.destroyed mustEqual false
|
||||
deliverer.cloak mustEqual false
|
||||
deliverer.unk1 mustEqual 2
|
||||
deliverer.unk2 mustEqual false
|
||||
deliverer.unk3 mustEqual false
|
||||
deliverer.unk4 mustEqual false
|
||||
deliverer.unk5 mustEqual true
|
||||
deliverer.unk6 mustEqual false
|
||||
deliverer.vehicle_format_data mustEqual None
|
||||
deliverer.inventory.isDefined mustEqual true
|
||||
deliverer.inventory.get.contents.size mustEqual 2
|
||||
//0
|
||||
var mounting = deliverer.inventory.get.contents.head
|
||||
mounting.objectClass mustEqual ObjectClass.mediumtransport_weapon_systemA
|
||||
mounting.guid mustEqual PlanetSideGUID(383)
|
||||
mounting.parentSlot mustEqual 5
|
||||
mounting.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
var weapon = mounting.obj.asInstanceOf[WeaponData]
|
||||
weapon.unk1 mustEqual 0x6
|
||||
weapon.unk2 mustEqual 0x8
|
||||
weapon.fire_mode mustEqual 0
|
||||
weapon.ammo.size mustEqual 1
|
||||
var ammo = weapon.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_20mm
|
||||
ammo.guid mustEqual PlanetSideGUID(420)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x8
|
||||
//1
|
||||
mounting = deliverer.inventory.get.contents(1)
|
||||
mounting.objectClass mustEqual ObjectClass.mediumtransport_weapon_systemB
|
||||
mounting.guid mustEqual PlanetSideGUID(556)
|
||||
mounting.parentSlot mustEqual 6
|
||||
mounting.obj.isInstanceOf[WeaponData] mustEqual true
|
||||
weapon = mounting.obj.asInstanceOf[WeaponData]
|
||||
weapon.unk1 mustEqual 0x6
|
||||
weapon.unk2 mustEqual 0x8
|
||||
weapon.fire_mode mustEqual 0
|
||||
weapon.ammo.size mustEqual 1
|
||||
ammo = weapon.ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_20mm
|
||||
ammo.guid mustEqual PlanetSideGUID(575)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.isInstanceOf[AmmoBoxData] mustEqual true
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x8
|
||||
data match {
|
||||
case VehicleData(pos, vdata, unk3, health, unk4, _, driveState, unk5, unk6, _, format, Some(InventoryData(inv))) =>
|
||||
pos.coord mustEqual Vector3(6531.961f, 1872.1406f, 24.734375f)
|
||||
pos.orient mustEqual Vector3.z(357.1875f)
|
||||
|
||||
vdata.faction mustEqual PlanetSideEmpire.NC
|
||||
vdata.alternate mustEqual false
|
||||
vdata.v1 mustEqual true
|
||||
vdata.v3 mustEqual false
|
||||
vdata.v5.isEmpty mustEqual true
|
||||
vdata.guid mustEqual PlanetSideGUID(0)
|
||||
|
||||
health mustEqual 255
|
||||
driveState mustEqual DriveState.State7
|
||||
unk3 mustEqual false
|
||||
unk4 mustEqual false
|
||||
unk5 mustEqual true
|
||||
unk6 mustEqual false
|
||||
format.isEmpty mustEqual true
|
||||
//0
|
||||
inv.head.objectClass mustEqual ObjectClass.mediumtransport_weapon_systemA
|
||||
inv.head.guid mustEqual PlanetSideGUID(383)
|
||||
inv.head.parentSlot mustEqual 5
|
||||
inv.head.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_20mm
|
||||
ammo.guid mustEqual PlanetSideGUID(420)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//1
|
||||
inv(1).objectClass mustEqual ObjectClass.mediumtransport_weapon_systemB
|
||||
inv(1).guid mustEqual PlanetSideGUID(556)
|
||||
inv(1).parentSlot mustEqual 6
|
||||
inv(1).obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, List(ammo), _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
ammo.objectClass mustEqual ObjectClass.bullet_20mm
|
||||
ammo.guid mustEqual PlanetSideGUID(575)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -175,22 +271,26 @@ class NormalVehiclesTest extends Specification {
|
|||
"encode (fury)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(6531.961f, 1872.1406f, 24.734375f, 0f, 0f, 357.1875f),
|
||||
PlanetSideEmpire.VS,
|
||||
false, false,
|
||||
2,
|
||||
false, false,
|
||||
PlanetSideGUID(0),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
DriveState.Mobile,
|
||||
false, false, false,
|
||||
None,
|
||||
Some(InventoryData(
|
||||
Some(InventoryData(List(
|
||||
InventoryItemData(ObjectClass.fury_weapon_systema, PlanetSideGUID(400), 1,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.hellfire_ammo, PlanetSideGUID(432), 0, AmmoBoxData(0x8))
|
||||
) :: Nil
|
||||
))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(ObjectClass.hellfire_ammo, PlanetSideGUID(432), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)))
|
||||
)(VehicleFormat.Normal)
|
||||
val msg = ObjectCreateMessage(ObjectClass.fury, PlanetSideGUID(413), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -201,22 +301,25 @@ class NormalVehiclesTest extends Specification {
|
|||
"encode (lightning)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(3674.8438f, 2726.789f, 91.15625f, 0f, 0f, 90.0f),
|
||||
PlanetSideEmpire.VS,
|
||||
false, false,
|
||||
2,
|
||||
false, false,
|
||||
PlanetSideGUID(0),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
DriveState.Mobile,
|
||||
false, false, false,
|
||||
None,
|
||||
Some(InventoryData(
|
||||
Some(InventoryData(List(
|
||||
InventoryItemData(ObjectClass.lightning_weapon_system, PlanetSideGUID(91), 1,
|
||||
WeaponData(4, 8, 0, ObjectClass.bullet_75mm, PlanetSideGUID(92), 0, AmmoBoxData(), ObjectClass.bullet_25mm, PlanetSideGUID(93), 1, AmmoBoxData())
|
||||
) :: Nil
|
||||
))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.VS, 2),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(ObjectClass.bullet_75mm, PlanetSideGUID(92), 0, CommonFieldData()(false)),
|
||||
InternalSlot(ObjectClass.bullet_25mm, PlanetSideGUID(93), 1, CommonFieldData()(false))
|
||||
)
|
||||
)
|
||||
)
|
||||
)))
|
||||
)(VehicleFormat.Normal)
|
||||
val msg = ObjectCreateMessage(ObjectClass.lightning, PlanetSideGUID(90), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
@ -227,25 +330,37 @@ class NormalVehiclesTest extends Specification {
|
|||
"encode (medium transport)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(6531.961f, 1872.1406f, 24.734375f, 0f, 0f, 357.1875f),
|
||||
PlanetSideEmpire.NC,
|
||||
false, false,
|
||||
2,
|
||||
false, false,
|
||||
PlanetSideGUID(0),
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
DriveState.State7,
|
||||
true, false, false,
|
||||
None,
|
||||
Some(InventoryData(
|
||||
Some(InventoryData(List(
|
||||
InventoryItemData(ObjectClass.mediumtransport_weapon_systemA, PlanetSideGUID(383), 5,
|
||||
WeaponData(6, 8, ObjectClass.bullet_20mm, PlanetSideGUID(420), 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.mediumtransport_weapon_systemB, PlanetSideGUID(556), 6,
|
||||
WeaponData(6, 8, ObjectClass.bullet_20mm, PlanetSideGUID(575), 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(ObjectClass.bullet_20mm, PlanetSideGUID(420), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
InventoryItemData(ObjectClass.mediumtransport_weapon_systemB, PlanetSideGUID(556), 6,
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(ObjectClass.bullet_20mm, PlanetSideGUID(575), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)))
|
||||
)(VehicleFormat.Normal)
|
||||
val msg = ObjectCreateMessage(ObjectClass.mediumtransport, PlanetSideGUID(387), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
package game.objectcreatevehicle
|
||||
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
|
@ -22,20 +22,19 @@ class UtilityVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.ant
|
||||
guid mustEqual PlanetSideGUID(380)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val ant = data.get.asInstanceOf[VehicleData]
|
||||
data.isInstanceOf[VehicleData] mustEqual true
|
||||
val ant = data.asInstanceOf[VehicleData]
|
||||
ant.pos.coord mustEqual Vector3(3674.8438f, 2726.789f, 91.15625f)
|
||||
ant.pos.orient mustEqual Vector3(0, 0, 90)
|
||||
ant.faction mustEqual PlanetSideEmpire.VS
|
||||
ant.owner_guid mustEqual PlanetSideGUID(0)
|
||||
ant.data.faction mustEqual PlanetSideEmpire.VS
|
||||
ant.data.alternate mustEqual false
|
||||
ant.data.v1 mustEqual true
|
||||
ant.data.v3 mustEqual false
|
||||
ant.data.v5.isEmpty mustEqual true
|
||||
ant.data.guid mustEqual PlanetSideGUID(0)
|
||||
ant.driveState mustEqual DriveState.Mobile
|
||||
ant.health mustEqual 255
|
||||
ant.jammered mustEqual false
|
||||
ant.destroyed mustEqual false
|
||||
ant.cloak mustEqual false
|
||||
ant.unk1 mustEqual 2
|
||||
ant.unk2 mustEqual false
|
||||
ant.unk3 mustEqual false
|
||||
ant.unk4 mustEqual false
|
||||
ant.unk5 mustEqual false
|
||||
|
|
@ -52,22 +51,21 @@ class UtilityVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.ams
|
||||
guid mustEqual PlanetSideGUID(4157)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val ams = data.get.asInstanceOf[VehicleData]
|
||||
data.isInstanceOf[VehicleData] mustEqual true
|
||||
val ams = data.asInstanceOf[VehicleData]
|
||||
ams.pos.coord mustEqual Vector3(3674, 2726.789f, 91.15625f)
|
||||
ams.pos.orient mustEqual Vector3(0, 0, 90)
|
||||
ams.pos.vel mustEqual None
|
||||
ams.faction mustEqual PlanetSideEmpire.VS
|
||||
ams.owner_guid mustEqual PlanetSideGUID(2885)
|
||||
ams.data.faction mustEqual PlanetSideEmpire.VS
|
||||
ams.data.alternate mustEqual false
|
||||
ams.data.v1 mustEqual false
|
||||
ams.data.v3 mustEqual false
|
||||
ams.data.v5.isEmpty mustEqual true
|
||||
ams.data.guid mustEqual PlanetSideGUID(2885)
|
||||
ams.driveState mustEqual DriveState.Deployed
|
||||
ams.vehicle_format_data mustEqual Some(UtilityVehicleData(60))
|
||||
ams.health mustEqual 236
|
||||
ams.jammered mustEqual false
|
||||
ams.destroyed mustEqual false
|
||||
ams.cloak mustEqual true
|
||||
ams.unk1 mustEqual 0
|
||||
ams.unk2 mustEqual false
|
||||
ams.unk3 mustEqual false
|
||||
ams.unk4 mustEqual false
|
||||
ams.unk5 mustEqual false
|
||||
|
|
@ -78,19 +76,19 @@ class UtilityVehiclesTest extends Specification {
|
|||
inv.head.objectClass mustEqual ObjectClass.matrix_terminalc
|
||||
inv.head.guid mustEqual PlanetSideGUID(3663)
|
||||
inv.head.parentSlot mustEqual 1
|
||||
inv.head.obj.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
inv.head.obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
inv(1).objectClass mustEqual ObjectClass.ams_respawn_tube
|
||||
inv(1).guid mustEqual PlanetSideGUID(3638)
|
||||
inv(1).parentSlot mustEqual 2
|
||||
inv(1).obj.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
inv(1).obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
inv(2).objectClass mustEqual ObjectClass.order_terminala
|
||||
inv(2).guid mustEqual PlanetSideGUID(3827)
|
||||
inv(2).parentSlot mustEqual 3
|
||||
inv(2).obj.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
inv(2).obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
inv(3).objectClass mustEqual ObjectClass.order_terminalb
|
||||
inv(3).guid mustEqual PlanetSideGUID(3556)
|
||||
inv(3).parentSlot mustEqual 4
|
||||
inv(3).obj.isInstanceOf[CommonTerminalData] mustEqual true
|
||||
inv(3).obj.isInstanceOf[CommonFieldData] mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -99,11 +97,7 @@ class UtilityVehiclesTest extends Specification {
|
|||
"encode (ant)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(3674.8438f, 2726.789f, 91.15625f, 0f, 0f, 90.0f),
|
||||
PlanetSideEmpire.VS,
|
||||
false, false,
|
||||
2,
|
||||
false, false,
|
||||
PlanetSideGUID(0),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
|
|
@ -121,11 +115,7 @@ class UtilityVehiclesTest extends Specification {
|
|||
"encode (ams)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(3674.0f, 2726.789f, 91.15625f, 0f, 0f, 90.0f),
|
||||
PlanetSideEmpire.VS,
|
||||
false, false,
|
||||
0,
|
||||
false, false,
|
||||
PlanetSideGUID(2885),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, false, None, false, Some(false), None, PlanetSideGUID(2885)),
|
||||
false,
|
||||
236,
|
||||
false, false,
|
||||
|
|
@ -133,10 +123,10 @@ class UtilityVehiclesTest extends Specification {
|
|||
false, true, true,
|
||||
Some(UtilityVehicleData(60)), //what does this mean?
|
||||
Some(InventoryData(List(
|
||||
InternalSlot(ObjectClass.matrix_terminalc, PlanetSideGUID(3663), 1, CommonTerminalData(PlanetSideEmpire.VS)),
|
||||
InternalSlot(ObjectClass.ams_respawn_tube, PlanetSideGUID(3638), 2, CommonTerminalData(PlanetSideEmpire.VS)),
|
||||
InternalSlot(ObjectClass.order_terminala, PlanetSideGUID(3827), 3, CommonTerminalData(PlanetSideEmpire.VS)),
|
||||
InternalSlot(ObjectClass.order_terminalb, PlanetSideGUID(3556), 4, CommonTerminalData(PlanetSideEmpire.VS))
|
||||
InternalSlot(ObjectClass.matrix_terminalc, PlanetSideGUID(3663), 1, CommonFieldData(PlanetSideEmpire.VS)(false)),
|
||||
InternalSlot(ObjectClass.ams_respawn_tube, PlanetSideGUID(3638), 2, CommonFieldData(PlanetSideEmpire.VS)(false)),
|
||||
InternalSlot(ObjectClass.order_terminala, PlanetSideGUID(3827), 3, CommonFieldData(PlanetSideEmpire.VS)(false)),
|
||||
InternalSlot(ObjectClass.order_terminalb, PlanetSideGUID(3556), 4, CommonFieldData(PlanetSideEmpire.VS)(false))
|
||||
)))
|
||||
)(VehicleFormat.Utility)
|
||||
val msg = ObjectCreateMessage(ObjectClass.ams, PlanetSideGUID(4157), obj)
|
||||
|
|
|
|||
|
|
@ -19,17 +19,16 @@ class VariantVehiclesTest extends Specification {
|
|||
cls mustEqual ObjectClass.switchblade
|
||||
guid mustEqual PlanetSideGUID(418)
|
||||
parent.isDefined mustEqual false
|
||||
data.isDefined mustEqual true
|
||||
data.get.isInstanceOf[VehicleData] mustEqual true
|
||||
val switchblade = data.get.asInstanceOf[VehicleData]
|
||||
data.isInstanceOf[VehicleData] mustEqual true
|
||||
val switchblade = data.asInstanceOf[VehicleData]
|
||||
switchblade.pos.coord.x mustEqual 6531.961f
|
||||
switchblade.pos.coord.y mustEqual 1872.1406f
|
||||
switchblade.pos.coord.z mustEqual 24.734375f
|
||||
switchblade.pos.orient.x mustEqual 0f
|
||||
switchblade.pos.orient.y mustEqual 0f
|
||||
switchblade.pos.orient.z mustEqual 357.1875f
|
||||
switchblade.faction mustEqual PlanetSideEmpire.VS
|
||||
switchblade.unk1 mustEqual 2
|
||||
switchblade.data.faction mustEqual PlanetSideEmpire.VS
|
||||
switchblade.data.v1 mustEqual true
|
||||
switchblade.health mustEqual 255
|
||||
switchblade.driveState mustEqual DriveState.Mobile
|
||||
switchblade.inventory.isDefined mustEqual true
|
||||
|
|
@ -39,21 +38,59 @@ class VariantVehiclesTest extends Specification {
|
|||
weapon.objectClass mustEqual ObjectClass.scythe
|
||||
weapon.guid mustEqual PlanetSideGUID(355)
|
||||
weapon.parentSlot mustEqual 1
|
||||
weapon.obj.asInstanceOf[WeaponData].unk1 mustEqual 0x6
|
||||
weapon.obj.asInstanceOf[WeaponData].unk2 mustEqual 0x8
|
||||
weapon.obj.asInstanceOf[WeaponData].ammo.size mustEqual 2
|
||||
//ammo-0
|
||||
var ammo = weapon.obj.asInstanceOf[WeaponData].ammo.head
|
||||
ammo.objectClass mustEqual ObjectClass.ancient_ammo_vehicle
|
||||
ammo.guid mustEqual PlanetSideGUID(366)
|
||||
ammo.parentSlot mustEqual 0
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x8
|
||||
//ammo-1
|
||||
ammo = weapon.obj.asInstanceOf[WeaponData].ammo(1)
|
||||
ammo.objectClass mustEqual ObjectClass.ancient_ammo_vehicle
|
||||
ammo.guid mustEqual PlanetSideGUID(385)
|
||||
ammo.parentSlot mustEqual 1
|
||||
ammo.obj.asInstanceOf[AmmoBoxData].unk mustEqual 0x8
|
||||
weapon.obj match {
|
||||
case WeaponData(CommonFieldData(wfaction, wbops, walternate, wv1, wv2, wv3, wv4, wv5, wfguid), fmode, ammo, _) =>
|
||||
wfaction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
wbops mustEqual false
|
||||
walternate mustEqual false
|
||||
wv1 mustEqual true
|
||||
wv2.isEmpty mustEqual true
|
||||
wv3 mustEqual false
|
||||
wv4.isEmpty mustEqual true
|
||||
wv5.isEmpty mustEqual true
|
||||
wfguid mustEqual PlanetSideGUID(0)
|
||||
|
||||
fmode mustEqual 0
|
||||
|
||||
//ammo-0
|
||||
ammo.head.objectClass mustEqual ObjectClass.ancient_ammo_vehicle
|
||||
ammo.head.guid mustEqual PlanetSideGUID(366)
|
||||
ammo.head.parentSlot mustEqual 0
|
||||
ammo.head.obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
//ammo-1
|
||||
ammo(1).objectClass mustEqual ObjectClass.ancient_ammo_vehicle
|
||||
ammo(1).guid mustEqual PlanetSideGUID(385)
|
||||
ammo(1).parentSlot mustEqual 1
|
||||
ammo(1).obj match {
|
||||
case CommonFieldData(faction, bops, alternate, v1, v2, v3, v4, v5, fguid) =>
|
||||
faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
bops mustEqual false
|
||||
alternate mustEqual false
|
||||
v1 mustEqual true
|
||||
v2.isEmpty mustEqual true
|
||||
v3 mustEqual false
|
||||
v4.contains(false) mustEqual true
|
||||
v5.isEmpty mustEqual true
|
||||
fguid mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -62,22 +99,25 @@ class VariantVehiclesTest extends Specification {
|
|||
"encode (switchblade)" in {
|
||||
val obj = VehicleData(
|
||||
PlacementData(6531.961f, 1872.1406f, 24.734375f, 0f, 0f, 357.1875f),
|
||||
PlanetSideEmpire.VS,
|
||||
false, false,
|
||||
2,
|
||||
false, false,
|
||||
PlanetSideGUID(0),
|
||||
CommonFieldData(PlanetSideEmpire.VS, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)),
|
||||
false,
|
||||
255,
|
||||
false, false,
|
||||
DriveState.Mobile,
|
||||
false, false, false,
|
||||
Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
Some(InventoryData(List(
|
||||
InventoryItemData(ObjectClass.scythe, PlanetSideGUID(355), 1,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.ancient_ammo_vehicle, PlanetSideGUID(366), 0, AmmoBoxData(0x8), ObjectClass.ancient_ammo_vehicle, PlanetSideGUID(385), 1, AmmoBoxData(0x8))
|
||||
) :: Nil
|
||||
))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(ObjectClass.ancient_ammo_vehicle, PlanetSideGUID(366), 0, CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false)),
|
||||
InternalSlot(ObjectClass.ancient_ammo_vehicle, PlanetSideGUID(385), 1, CommonFieldData(PlanetSideEmpire.NEUTRAL, 2)(false))
|
||||
)
|
||||
)
|
||||
)
|
||||
)))
|
||||
)(VehicleFormat.Variant)
|
||||
val msg = ObjectCreateMessage(ObjectClass.switchblade, PlanetSideGUID(418), obj)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import net.psforever.objects.equipment.EquipmentSize
|
||||
import net.psforever.objects.equipment.{EquipmentSize, EquipmentSlot}
|
||||
import net.psforever.objects.inventory.{Container, GridInventory, InventoryEquipmentSlot}
|
||||
import net.psforever.objects.{EquipmentSlot, GlobalDefinitions, OffhandEquipmentSlot, Tool}
|
||||
import net.psforever.objects.{GlobalDefinitions, OffhandEquipmentSlot, Tool}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import org.specs2.mutable._
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,36 @@ class ConverterTest extends Specification {
|
|||
val obj = AmmoBox(bullet_9mm)
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedAmmoBoxData(8, 50)
|
||||
pkt mustEqual DetailedAmmoBoxData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
obj.Capacity
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual AmmoBoxData()
|
||||
pkt mustEqual CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
Some(false),
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -45,13 +68,23 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedWeaponData(4,8, Ammo.shotgun_shell.id, PlanetSideGUID(90), 0, DetailedAmmoBoxData(8, 12))
|
||||
pkt mustEqual DetailedWeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(Ammo.shotgun_shell.id, PlanetSideGUID(90), 0, DetailedAmmoBoxData(8, 12)))
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual WeaponData(4,8, 0, Ammo.shotgun_shell.id, PlanetSideGUID(90), 0, AmmoBoxData())
|
||||
pkt mustEqual WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(Ammo.shotgun_shell.id, PlanetSideGUID(90), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -64,7 +97,9 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedWeaponData(4,8, 0,
|
||||
pkt mustEqual DetailedWeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(Ammo.bullet_9mm.id, PlanetSideGUID(90), 0, DetailedAmmoBoxData(8, 30)),
|
||||
InternalSlot(Ammo.rocket.id, PlanetSideGUID(91), 1, DetailedAmmoBoxData(8, 1))
|
||||
|
|
@ -75,10 +110,22 @@ class ConverterTest extends Specification {
|
|||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual WeaponData(4,8, 0,
|
||||
pkt mustEqual WeaponData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL, //TODO need faction affinity
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
0,
|
||||
List(
|
||||
InternalSlot(Ammo.bullet_9mm.id, PlanetSideGUID(90), 0, AmmoBoxData()),
|
||||
InternalSlot(Ammo.rocket.id, PlanetSideGUID(91), 1, AmmoBoxData())
|
||||
InternalSlot(Ammo.bullet_9mm.id, PlanetSideGUID(90), 0, CommonFieldData()(false)),
|
||||
InternalSlot(Ammo.rocket.id, PlanetSideGUID(91), 1, CommonFieldData()(false))
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
|
|
@ -100,7 +147,7 @@ class ConverterTest extends Specification {
|
|||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual AmmoBoxData()
|
||||
pkt mustEqual CommonFieldData()(false)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -112,14 +159,28 @@ class ConverterTest extends Specification {
|
|||
obj.GUID = PlanetSideGUID(90)
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedACEData(0)
|
||||
pkt mustEqual DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual ACEData(0,0)
|
||||
pkt mustEqual HandheldData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -135,13 +196,37 @@ class ConverterTest extends Specification {
|
|||
obj.GUID = PlanetSideGUID(90)
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedREKData(8)
|
||||
pkt mustEqual DetailedREKData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL, //TODO faction affinity
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
Some(false),
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual REKData(8,0)
|
||||
pkt mustEqual REKData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
Some(false),
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -154,13 +239,17 @@ class ConverterTest extends Specification {
|
|||
obj.GUID = PlanetSideGUID(90)
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedBoomerTriggerData()
|
||||
pkt mustEqual DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual BoomerTriggerData()
|
||||
pkt mustEqual HandheldData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, None, None, PlanetSideGUID(0))
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -173,14 +262,28 @@ class ConverterTest extends Specification {
|
|||
obj.Router = PlanetSideGUID(1001)
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual TelepadData(0, PlanetSideGUID(1001))
|
||||
pkt mustEqual HandheldData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.NEUTRAL,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
Some(1001),
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedTelepadData(0, PlanetSideGUID(1001))
|
||||
pkt mustEqual DetailedConstructionToolData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, Some(1001), PlanetSideGUID(0))
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -204,12 +307,19 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual SmallDeployableData(
|
||||
pkt mustEqual CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
0,
|
||||
false,
|
||||
false
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
Some(false),
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
|
|
@ -229,17 +339,20 @@ class ConverterTest extends Specification {
|
|||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual SmallTurretData(
|
||||
SmallDeployableData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
0,
|
||||
false,
|
||||
false
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, false, None, false, Some(true), None, PlanetSideGUID(0))
|
||||
),
|
||||
255,
|
||||
InventoryData(
|
||||
List(InternalSlot(ObjectClass.spitfire_weapon, PlanetSideGUID(91), 1,
|
||||
WeaponData(4, 8, ObjectClass.spitfire_ammo, PlanetSideGUID(92), 0, AmmoBoxData()))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(Ammo.spitfire_ammo.id, PlanetSideGUID(92), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -261,17 +374,20 @@ class ConverterTest extends Specification {
|
|||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual OneMannedFieldTurretData(
|
||||
SmallDeployableData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
0,
|
||||
false,
|
||||
false
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, true, None, false, Some(false), None, PlanetSideGUID(0))
|
||||
),
|
||||
255,
|
||||
InventoryData(
|
||||
List(InternalSlot(ObjectClass.energy_gun_tr, PlanetSideGUID(91), 1,
|
||||
WeaponData(4, 8, ObjectClass.energy_gun_ammo, PlanetSideGUID(92), 0, AmmoBoxData()))
|
||||
WeaponData(
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)),
|
||||
0,
|
||||
List(InternalSlot(Ammo.energy_gun_ammo.id, PlanetSideGUID(92), 0,
|
||||
CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, false, None, false, Some(false), None, PlanetSideGUID(0)))
|
||||
))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -291,12 +407,19 @@ class ConverterTest extends Specification {
|
|||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual TRAPData(
|
||||
SmallDeployableData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
0,
|
||||
false,
|
||||
false
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
Some(true),
|
||||
None,
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
),
|
||||
255
|
||||
)
|
||||
|
|
@ -316,7 +439,7 @@ class ConverterTest extends Specification {
|
|||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual AegisShieldGeneratorData(
|
||||
CommonFieldData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
0
|
||||
|
|
@ -339,15 +462,23 @@ class ConverterTest extends Specification {
|
|||
obj.Health = 1
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual TelepadDeployableData(
|
||||
pkt mustEqual DroppedItemData(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
destroyed = false,
|
||||
unk1 = 2, unk2 = true,
|
||||
router_guid = PlanetSideGUID(1001),
|
||||
owner_guid = PlanetSideGUID(5001),
|
||||
unk3 = 87, unk4 = 12
|
||||
TelepadDeployableData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
alternate = false,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
Some(1001),
|
||||
PlanetSideGUID(5001)
|
||||
),
|
||||
unk1 = 87,
|
||||
unk2 = 12
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
|
|
@ -363,15 +494,23 @@ class ConverterTest extends Specification {
|
|||
obj.Health = 0
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual TelepadDeployableData(
|
||||
pkt mustEqual DroppedItemData(
|
||||
PlacementData(Vector3.Zero, Vector3.Zero),
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
destroyed = true,
|
||||
unk1 = 2, unk2 = true,
|
||||
router_guid = PlanetSideGUID(1001),
|
||||
owner_guid = PlanetSideGUID(0),
|
||||
unk3 = 0, unk4 = 6
|
||||
TelepadDeployableData(
|
||||
CommonFieldData(
|
||||
PlanetSideEmpire.TR,
|
||||
bops = false,
|
||||
alternate = true,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
Some(1001),
|
||||
PlanetSideGUID(0)
|
||||
),
|
||||
unk1 = 0,
|
||||
unk2 = 6
|
||||
)
|
||||
)
|
||||
case _ =>
|
||||
ko
|
||||
|
|
@ -496,13 +635,13 @@ class ConverterTest extends Specification {
|
|||
val obj = LockerContainer()
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedLockerContainerData(8, None)
|
||||
pkt mustEqual DetailedLockerContainerData(CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, None, None, PlanetSideGUID(0)), None)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual LockerContainerData(InventoryData(List.empty))
|
||||
pkt mustEqual LockerContainerData(None)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -517,13 +656,13 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual DetailedLockerContainerData(8, InternalSlot(remote_electronics_kit.ObjectId, PlanetSideGUID(1), 0, DetailedREKData(8)) :: Nil)
|
||||
pkt mustEqual DetailedLockerContainerData(8, InternalSlot(remote_electronics_kit.ObjectId, PlanetSideGUID(1), 0, DetailedREKData(CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)))) :: Nil)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual LockerContainerData(InventoryData(InternalSlot(remote_electronics_kit.ObjectId, PlanetSideGUID(1), 0, REKData(8,0)) :: Nil))
|
||||
pkt mustEqual LockerContainerData(InventoryData(InternalSlot(remote_electronics_kit.ObjectId, PlanetSideGUID(1), 0, REKData(CommonFieldData(PlanetSideEmpire.NEUTRAL, false, false, true, None, false, Some(false), None, PlanetSideGUID(0)))) :: Nil))
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -543,7 +682,7 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual CommonTerminalData(PlanetSideEmpire.NEUTRAL)
|
||||
pkt mustEqual CommonFieldData(PlanetSideEmpire.NEUTRAL)(false)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -563,7 +702,7 @@ class ConverterTest extends Specification {
|
|||
|
||||
obj.Definition.Packet.ConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
pkt mustEqual CommonTerminalData(PlanetSideEmpire.NEUTRAL)
|
||||
pkt mustEqual CommonFieldData(PlanetSideEmpire.NEUTRAL)(false)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import net.psforever.objects.{EquipmentSlot, OffhandEquipmentSlot, Tool}
|
||||
import net.psforever.objects.equipment.EquipmentSize
|
||||
import net.psforever.objects.{OffhandEquipmentSlot, Tool}
|
||||
import net.psforever.objects.equipment.{EquipmentSize, EquipmentSlot}
|
||||
import net.psforever.objects.GlobalDefinitions.{beamer, repeater, suppressor}
|
||||
import org.specs2.mutable._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.definition.{ExoSuitDefinition, SpecialExoSuitDefinition}
|
||||
import net.psforever.objects.equipment._
|
||||
import net.psforever.objects.inventory.InventoryTile
|
||||
import net.psforever.types.ExoSuitType
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package objects
|
|||
|
||||
import net.psforever.objects.GlobalDefinitions._
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.definition.{ImplantDefinition, SimpleItemDefinition}
|
||||
import net.psforever.objects.definition.{ImplantDefinition, SimpleItemDefinition, SpecialExoSuitDefinition}
|
||||
import net.psforever.objects.equipment.EquipmentSize
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.packet.game.objectcreate.{Cosmetics, PersonalStyle}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable._
|
||||
|
||||
|
|
@ -521,6 +522,115 @@ class PlayerTest extends Specification {
|
|||
obj.UsingSpecial != test mustEqual true
|
||||
}
|
||||
|
||||
"start with a nonexistent cosmetic state" in {
|
||||
TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5).PersonalStyleFeatures.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"will not gain cosmetic state if player does not have a certain amount of BEP" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
val (a1, b1) = obj.AddToPersonalStyle(PersonalStyle.Beret)
|
||||
a1.isEmpty mustEqual true
|
||||
b1.isEmpty mustEqual true
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
|
||||
avatar.BEP = 2286231 //BR24
|
||||
val (a2, b2) = obj.AddToPersonalStyle(PersonalStyle.Beret)
|
||||
a2.isEmpty mustEqual true
|
||||
b2 match {
|
||||
case Some(c : Cosmetics) =>
|
||||
c.Styles mustEqual Set(PersonalStyle.Beret)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual false
|
||||
}
|
||||
|
||||
"will lose cosmetic state" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
avatar.BEP = 2286231 //BR24
|
||||
obj.AddToPersonalStyle(PersonalStyle.Beret)
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Beret))) mustEqual true
|
||||
val (a2, b2) = obj.RemoveFromPersonalStyle(PersonalStyle.Beret)
|
||||
a2 match {
|
||||
case Some(c : Cosmetics) =>
|
||||
c.Styles mustEqual Set(PersonalStyle.Beret)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
b2 match {
|
||||
case Some(c : Cosmetics) =>
|
||||
c.Styles mustEqual Set.empty
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"will not lose cosmetic state if the player doesn't have any cosmetic state to begin with" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
val (a1, b1) = obj.RemoveFromPersonalStyle(PersonalStyle.Beret)
|
||||
a1.isEmpty mustEqual true
|
||||
b1.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"toggle helmet" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
avatar.BEP = 2286231
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
obj.ToggleHelmet
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.NoHelmet))) mustEqual true
|
||||
obj.ToggleHelmet
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics()) mustEqual true
|
||||
obj.ToggleHelmet
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.NoHelmet))) mustEqual true
|
||||
}
|
||||
|
||||
"toggle suglasses" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
avatar.BEP = 2286231
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
obj.ToggleShades
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Sunglasses))) mustEqual true
|
||||
obj.ToggleShades
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics()) mustEqual true
|
||||
obj.ToggleShades
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Sunglasses))) mustEqual true
|
||||
}
|
||||
|
||||
"toggle earpiece" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
avatar.BEP = 2286231
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
obj.ToggleEarpiece
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Earpiece))) mustEqual true
|
||||
obj.ToggleEarpiece
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics()) mustEqual true
|
||||
obj.ToggleEarpiece
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Earpiece))) mustEqual true
|
||||
}
|
||||
|
||||
"toggle between brimmed cap and beret" in {
|
||||
val avatar = Avatar("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
val obj = Player(avatar)
|
||||
avatar.BEP = 2286231
|
||||
obj.PersonalStyleFeatures.isEmpty mustEqual true
|
||||
obj.ToggleHat
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.BrimmedCap))) mustEqual true
|
||||
obj.ToggleHat
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.Beret))) mustEqual true
|
||||
obj.ToggleHat
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics()) mustEqual true
|
||||
obj.ToggleHat
|
||||
obj.PersonalStyleFeatures.contains(Cosmetics(Set(PersonalStyle.BrimmedCap))) mustEqual true
|
||||
}
|
||||
|
||||
"toString" in {
|
||||
val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
obj.toString mustEqual "TR Chord 0/100 0/50"
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class UtilityTest extends Specification {
|
|||
obj().Owner = veh //hack
|
||||
obj().GUID = PlanetSideGUID(1)
|
||||
|
||||
val msg = obj().asInstanceOf[Terminal].Buy(
|
||||
val msg = obj().asInstanceOf[Terminal].Request(
|
||||
Player(Avatar("TestCharacter", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)),
|
||||
ItemTransactionMessage(PlanetSideGUID(853), TransactionType.Buy, 0, "router_telepad", 0, PlanetSideGUID(0))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class AirVehicleTerminalTest extends Specification {
|
||||
"Air_Vehicle_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a reaver ('lightgunship')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.weapons mustEqual Nil
|
||||
reply2.inventory.length mustEqual 6
|
||||
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('reaver')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "reaver", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class CertTerminalTest extends Specification {
|
||||
"Cert_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.cert_terminal)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.cert_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can learn a certification ('medium_assault')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Learn, 0, "medium_assault", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.LearnCertification(CertificationType.MediumAssault)
|
||||
}
|
||||
|
||||
"player can not learn a fake certification ('juggling')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Learn, 0, "juggling", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can forget a certification ('medium_assault')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "medium_assault", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.SellCertification(CertificationType.MediumAssault)
|
||||
}
|
||||
|
||||
"player can not forget a fake certification ('juggling')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "juggling", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class DropshipVehicleTerminalTest extends Specification {
|
||||
"Dropship_Vehicle_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a galaxy ('dropship')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "dropship", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.dropship
|
||||
reply2.weapons mustEqual Nil
|
||||
reply2.inventory.length mustEqual 12
|
||||
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(6).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(7).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(8).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(9).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(10).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(11).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('galaxy')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "galaxy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class GroundVehicleTerminalTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a harasser ('two_man_assault_buggy')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.weapons mustEqual Nil
|
||||
reply2.inventory.length mustEqual 6
|
||||
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class ImplantTerminalInterfaceTest extends Specification {
|
||||
"Implant_Terminal_Interface" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.implant_terminal_interface)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.implant_terminal_interface)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can learn an implant ('darklight_vision')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "darklight_vision", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.LearnImplant] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.LearnImplant]
|
||||
reply2.implant mustEqual GlobalDefinitions.darklight_vision
|
||||
}
|
||||
|
||||
"player can not learn a fake implant ('aimbot')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "aimbot", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can surrender an implant ('darklight_vision')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "darklight_vision", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.SellImplant] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.SellImplant]
|
||||
reply2.implant mustEqual GlobalDefinitions.darklight_vision
|
||||
}
|
||||
|
||||
"player can not surrender a fake implant ('aimbot')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.implant_terminal_interface)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "aimbot", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ class ImplantTerminalMechTest extends Specification {
|
|||
}
|
||||
}
|
||||
|
||||
"VehicleSpawnPad" should {
|
||||
"Implant_Terminal_Mech" should {
|
||||
"construct" in {
|
||||
val obj = ImplantTerminalMech(GlobalDefinitions.implant_terminal_mech)
|
||||
obj.Actor mustEqual ActorRef.noSender
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.terminals.{MatrixTerminalDefinition, Terminal}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
|
|
@ -10,59 +9,22 @@ import org.specs2.mutable.Specification
|
|||
|
||||
class MatrixTerminalTest extends Specification {
|
||||
"MatrixTerminal" should {
|
||||
"define (a)" in {
|
||||
"define" in {
|
||||
val a = new MatrixTerminalDefinition(517)
|
||||
a.ObjectId mustEqual 517
|
||||
a.Name mustEqual "matrix_terminala"
|
||||
}
|
||||
|
||||
"define (b)" in {
|
||||
val b = new MatrixTerminalDefinition(518)
|
||||
b.ObjectId mustEqual 518
|
||||
b.Name mustEqual "matrix_terminalb"
|
||||
"creation" in {
|
||||
Terminal(new MatrixTerminalDefinition(518))
|
||||
ok
|
||||
}
|
||||
|
||||
"define (c)" in {
|
||||
val b = new MatrixTerminalDefinition(519)
|
||||
b.ObjectId mustEqual 519
|
||||
b.Name mustEqual "matrix_terminalc"
|
||||
}
|
||||
|
||||
"define (d)" in {
|
||||
val b = new MatrixTerminalDefinition(812)
|
||||
b.ObjectId mustEqual 812
|
||||
b.Name mustEqual "spawn_terminal"
|
||||
}
|
||||
|
||||
"define (invalid)" in {
|
||||
var id : Int = (math.random * Int.MaxValue).toInt
|
||||
if(id == 517) {
|
||||
id += 3
|
||||
}
|
||||
else if(id == 518) {
|
||||
id += 2
|
||||
}
|
||||
else if(id == 519 | id == 812) {
|
||||
id += 1
|
||||
}
|
||||
|
||||
new MatrixTerminalDefinition(id) must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
||||
"Matrix_Terminal" should {
|
||||
val terminal = Terminal(GlobalDefinitions.matrix_terminalc)
|
||||
terminal.Owner = Vehicle(GlobalDefinitions.quadstealth)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can not buy (anything)" in {
|
||||
"invalid message" in {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "lite_armor", 0, PlanetSideGUID(0))
|
||||
|
||||
val terminal = Terminal(new MatrixTerminalDefinition(519))
|
||||
terminal.Owner = Vehicle(GlobalDefinitions.quadstealth)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.serverobject.terminals.{OrderTerminalABDefinition, Terminal}
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class OrderTerminalABTest extends Specification {
|
||||
"OrderTerminalAB" should {
|
||||
"define (a)" in {
|
||||
val a = new OrderTerminalABDefinition(613)
|
||||
a.ObjectId mustEqual 613
|
||||
a.Name mustEqual "order_terminala"
|
||||
}
|
||||
|
||||
"define (b)" in {
|
||||
val b = new OrderTerminalABDefinition(614)
|
||||
b.ObjectId mustEqual 614
|
||||
b.Name mustEqual "order_terminalb"
|
||||
}
|
||||
|
||||
"define (invalid)" in {
|
||||
var id : Int = (math.random * Int.MaxValue).toInt
|
||||
if(id == 613) {
|
||||
id += 2
|
||||
}
|
||||
else if(id == 614) {
|
||||
id += 1
|
||||
}
|
||||
|
||||
new OrderTerminalABDefinition(id) must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
||||
"Order_Terminal" should {
|
||||
val terminal = Terminal(GlobalDefinitions.order_terminala)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy different armor ('lite_armor')" in {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "lite_armor", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.BuyExosuit(ExoSuitType.Agile)
|
||||
}
|
||||
|
||||
"player can buy max armor ('trhev_antiaircraft')" in {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "trhev_antiaircraft", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
//TODO loudout tests
|
||||
|
||||
"player can not load max loadout" in {
|
||||
val avatar = Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)
|
||||
val player = Player(avatar)
|
||||
avatar.SaveLoadout(player, "test1", 0)
|
||||
player.ExoSuit = ExoSuitType.MAX
|
||||
avatar.SaveLoadout(player, "test2", 1)
|
||||
|
||||
val msg1 = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Loadout, 4, "", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg1) mustEqual Terminal.InfantryLoadout(ExoSuitType.Standard, 0, Nil, Nil)
|
||||
|
||||
val msg2 = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Loadout, 4, "", 1, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg2) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +1,95 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.objects.{AmmoBox, Avatar, GlobalDefinitions, Player, Tool}
|
||||
import net.psforever.objects._
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class OrderTerminalTest extends Specification {
|
||||
"Order_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.order_terminal)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
val avatar = Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)
|
||||
val player = Player(avatar)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.order_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
val building = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
building.Faction = PlanetSideEmpire.TR
|
||||
val infantryTerminal = Terminal(GlobalDefinitions.order_terminal)
|
||||
infantryTerminal.Owner = building
|
||||
|
||||
"General terminal behavior" should {
|
||||
"player can not buy equipment from the wrong page ('9mmbullet_AP', page 10)" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "9mmbullet_AP", 0, PlanetSideGUID(0))
|
||||
|
||||
infantryTerminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
|
||||
"Infantry Order Terminal" should {
|
||||
"player can buy a box of ammunition ('9mmbullet_AP')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "9mmbullet_AP", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
val reply = infantryTerminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyEquipment] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyEquipment]
|
||||
reply2.item.isInstanceOf[AmmoBox] mustEqual true
|
||||
reply2.item.asInstanceOf[AmmoBox].Definition mustEqual GlobalDefinitions.bullet_9mm_AP
|
||||
reply2.item.asInstanceOf[AmmoBox].Capacity mustEqual 50
|
||||
}
|
||||
|
||||
"player can buy a weapon ('suppressor')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "suppressor", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
val reply = infantryTerminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyEquipment] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyEquipment]
|
||||
reply2.item.isInstanceOf[Tool] mustEqual true
|
||||
reply2.item.asInstanceOf[Tool].Definition mustEqual GlobalDefinitions.suppressor
|
||||
}
|
||||
|
||||
"player can buy a box of vehicle ammunition ('105mmbullet')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 3, "105mmbullet", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
"player can buy different armor ('lite_armor')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "lite_armor", 0, PlanetSideGUID(0))
|
||||
|
||||
infantryTerminal.Request(player, msg) mustEqual Terminal.BuyExosuit(ExoSuitType.Agile)
|
||||
}
|
||||
|
||||
"player can buy a box of ammunition belonging to a special armor type ('dualcycler_ammo')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "dualcycler_ammo", 0, PlanetSideGUID(0))
|
||||
val reply = infantryTerminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyEquipment] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyEquipment]
|
||||
reply2.item.isInstanceOf[AmmoBox] mustEqual true
|
||||
reply2.item.asInstanceOf[AmmoBox].Definition mustEqual GlobalDefinitions.bullet_105mm
|
||||
reply2.item.asInstanceOf[AmmoBox].Capacity mustEqual 100
|
||||
reply2.item.asInstanceOf[AmmoBox].Definition mustEqual GlobalDefinitions.dualcycler_ammo
|
||||
}
|
||||
|
||||
"player can buy a support tool ('bank')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 2, "bank", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
val reply = infantryTerminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyEquipment] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyEquipment]
|
||||
reply2.item.isInstanceOf[Tool] mustEqual true
|
||||
reply2.item.asInstanceOf[Tool].Definition mustEqual GlobalDefinitions.bank
|
||||
}
|
||||
|
||||
"player can buy different armor ('lite_armor')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "lite_armor", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.BuyExosuit(ExoSuitType.Agile)
|
||||
"player can buy a box of vehicle ammunition ('105mmbullet')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 3, "105mmbullet", 0, PlanetSideGUID(0))
|
||||
val reply = infantryTerminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyEquipment] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyEquipment]
|
||||
reply2.item.isInstanceOf[AmmoBox] mustEqual true
|
||||
reply2.item.asInstanceOf[AmmoBox].Definition mustEqual GlobalDefinitions.bullet_105mm
|
||||
}
|
||||
|
||||
"player can not buy fake equipment ('sabot')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "sabot", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can not buy equipment from the wrong page ('9mmbullet_AP', page 1)" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "9mmbullet_AP", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
infantryTerminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can retrieve an infantry loadout" in {
|
||||
val avatar = Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)
|
||||
val player2 = Player(avatar)
|
||||
player2.ExoSuit = ExoSuitType.Agile
|
||||
player2.Slot(0).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
player2.Slot(6).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
avatar.SaveLoadout(player2, "test", 0)
|
||||
player.ExoSuit = ExoSuitType.Agile
|
||||
player.Slot(0).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
player.Slot(6).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
avatar.SaveLoadout(player, "test", 0)
|
||||
|
||||
val msg = terminal.Request(player2, ItemTransactionMessage(PlanetSideGUID(10), TransactionType.Loadout, 4, "", 0, PlanetSideGUID(0)))
|
||||
val msg = infantryTerminal.Request(player, ItemTransactionMessage(PlanetSideGUID(10), TransactionType.Loadout, 4, "", 0, PlanetSideGUID(0)))
|
||||
msg.isInstanceOf[Terminal.InfantryLoadout] mustEqual true
|
||||
val loadout = msg.asInstanceOf[Terminal.InfantryLoadout]
|
||||
loadout.exosuit mustEqual ExoSuitType.Agile
|
||||
|
|
@ -98,28 +101,120 @@ class OrderTerminalTest extends Specification {
|
|||
loadout.inventory.head.start mustEqual 6
|
||||
}
|
||||
|
||||
"player can not retrieve an infantry loadout from the wrong page" in {
|
||||
val avatar = Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)
|
||||
val player2 = Player(avatar)
|
||||
player2.ExoSuit = ExoSuitType.Agile
|
||||
player2.Slot(0).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
player2.Slot(6).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
avatar.SaveLoadout(player2, "test", 0)
|
||||
|
||||
val msg = terminal.Request(player2, ItemTransactionMessage(PlanetSideGUID(10), TransactionType.Loadout, 3, "", 0, PlanetSideGUID(0))) //page 3
|
||||
msg.isInstanceOf[Terminal.NoDeal] mustEqual true
|
||||
}
|
||||
|
||||
"player can not retrieve an infantry loadout from the wrong line" in {
|
||||
val avatar = Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)
|
||||
val player2 = Player(avatar)
|
||||
player2.ExoSuit = ExoSuitType.Agile
|
||||
player2.Slot(0).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
player2.Slot(6).Equipment = Tool(GlobalDefinitions.beamer)
|
||||
avatar.SaveLoadout(player2, "test", 0)
|
||||
|
||||
val msg = terminal.Request(player2, ItemTransactionMessage(PlanetSideGUID(10), TransactionType.Loadout, 4, "", 1, PlanetSideGUID(0)))
|
||||
val msg = infantryTerminal.Request(player, ItemTransactionMessage(PlanetSideGUID(10), TransactionType.Loadout, 4, "", 1, PlanetSideGUID(0)))
|
||||
msg.isInstanceOf[Terminal.NoDeal] mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"Vehicle Terminal" should {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Owner = building
|
||||
|
||||
"player can spawn a vehicle and its default trunk contents" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 46769, "quadassault", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) match {
|
||||
case Terminal.BuyVehicle(vehicle, weapons, trunk) =>
|
||||
vehicle.Definition mustEqual GlobalDefinitions.quadassault
|
||||
|
||||
weapons.size mustEqual 0 //note: vehicles never have custom weapons using the default loadout
|
||||
|
||||
trunk.size mustEqual 4
|
||||
trunk.head.obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
trunk(1).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
trunk(2).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
trunk(3).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"player can not spawn a fake vehicle ('harasser')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 46769, "harasser", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can retrieve a vehicle loadout" in {
|
||||
val fury = Vehicle(GlobalDefinitions.fury)
|
||||
fury.Slot(30).Equipment = AmmoBox(GlobalDefinitions.hellfire_ammo)
|
||||
avatar.SaveLoadout(fury, "test", 10)
|
||||
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Loadout, 4, "test", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) match {
|
||||
case Terminal.VehicleLoadout(definition, weapons, trunk) =>
|
||||
definition mustEqual GlobalDefinitions.fury
|
||||
|
||||
weapons.size mustEqual 1
|
||||
weapons.head.obj.Definition mustEqual GlobalDefinitions.fury_weapon_systema
|
||||
|
||||
trunk.size mustEqual 1
|
||||
trunk.head.obj.Definition mustEqual GlobalDefinitions.hellfire_ammo
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
"Certification Terminal" should {
|
||||
val terminal = Terminal(GlobalDefinitions.cert_terminal)
|
||||
terminal.Owner = building
|
||||
|
||||
"player can learn a certification ('medium_assault')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Learn, 0, "medium_assault", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.LearnCertification(CertificationType.MediumAssault)
|
||||
}
|
||||
|
||||
"player can not learn a fake certification ('juggling')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Learn, 0, "juggling", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can forget a certification ('medium_assault')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "medium_assault", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.SellCertification(CertificationType.MediumAssault)
|
||||
}
|
||||
|
||||
"player can not forget a fake certification ('juggling')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "juggling", 0, PlanetSideGUID(0))
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
|
||||
"Implant_Terminal_Interface" should {
|
||||
val terminal = Terminal(GlobalDefinitions.implant_terminal_interface)
|
||||
terminal.Owner = building
|
||||
|
||||
"player can learn an implant ('darklight_vision')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "darklight_vision", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.LearnImplant] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.LearnImplant]
|
||||
reply2.implant mustEqual GlobalDefinitions.darklight_vision
|
||||
}
|
||||
|
||||
"player can not learn a fake implant ('aimbot')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "aimbot", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
|
||||
"player can un-learn an implant ('darklight_vision')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "darklight_vision", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.SellImplant] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.SellImplant]
|
||||
reply2.implant mustEqual GlobalDefinitions.darklight_vision
|
||||
}
|
||||
|
||||
"player can not un-learn a fake implant ('aimbot')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.implant_terminal_interface)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Sell, 0, "aimbot", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class CertTerminalControl3Test extends ActorTest {
|
|||
class VehicleTerminalControl1Test extends ActorTest {
|
||||
"TerminalControl can be used to buy a vehicle ('two_man_assault_buggy')" in {
|
||||
val (player, terminal) = TerminalControlTest.SetUpAgents(GlobalDefinitions.ground_vehicle_terminal, PlanetSideEmpire.TR)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 46769, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Actor ! Terminal.Request(player, msg)
|
||||
val reply = receiveOne(Duration.create(500, "ms"))
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class VehicleTerminalCombinedTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
terminal.Owner = new Building(0, Zone.Nowhere, StructureType.Building)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a ground vehicle, the harasser ('two_man_assault_buggy')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.weapons mustEqual Nil
|
||||
reply2.inventory.length mustEqual 6
|
||||
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_12mm
|
||||
}
|
||||
|
||||
"player can buy a flying vehicle, the reaver ('lightgunship')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.weapons mustEqual Nil
|
||||
reply2.inventory.length mustEqual 6
|
||||
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.reaver_rocket
|
||||
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue