PSF-BotServer/common/src/test/scala/game/objectcreate/OneMannedFieldTurretDataTest.scala
Fate-JH 5f3e7e5df8
Deployables (#230)
* functions for certifcation ui updates (that don't work)

* initialization of combat engineering deployables ui on load and certification change

* representation classes for ACE and FDU; ability to pull ACE and FDU from equipment terminals

* ammo change functionality and fire mode change functionality for ConstructionItems refactored from Tool operations and supported properly (switch between deployable options)

* zone-specific structure for keeping track of deployables; abaility to dismiss deployables from the map screen (previous functionality); local client creation of explosive-type deployables

* refactored MannedTurret into FacilityTurret and lesser traits to be used in the deployable spitfires and the OMFT's; all ACE deployables are available for placement; partial management of the construction items after the deployable is placed; boomers create boomer triggers

* Avatar-specific storage for deployables and for updating UI elements

* refactored quite a bit of code in WSA for the benefit of deployable management; refinements to deployable creation; server messages about deployable quantities; corrected the FDU encoding pattern; lots of work dedicated just to synchronizing BoomerTrigger objects

* added RemoverActor for deployables and redistributed deconstruction functionality away from WSA to new DeployableRemover; added events to facilitate activities not inheritable with this model

* refactored and distributed Deployables classes; copious amounts of testing and document-writing

* boomers now explode from trigger; support for deployables being destroyed by weapon discharge, including individual health, soure identification, and damage model; shuffled deployable classes to build different hierarchy

* sensor_shield was skipped by accident

* identified stray object in Hanish, Ishundar, and added Irkalla, Ishundar's capture console; fixed issue with Warp command and 'Irkalla'; modified building amenity setup and setup testing in Zone; players load and die properly when seated in an omft; reserve ammunition in omft properly registered

* added local service channel, capture consoles, fixed tests as much as posible

* fixed LocalService tests by booting the ServiceManager; added avatar and local tests

* a simple attempt to refactor Actor messages in a way that is acceptable to Travis CI

* making the explosive deployables vanish upon explosion; sensor health bars are now supported
2018-09-23 08:00:58 -04:00

102 lines
4.1 KiB
Scala

// 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 OneMannedFieldTurretDataTest extends Specification {
val string_orion = hex"17 5E010000 D82640B 92F76 01D65 F611 00 00 5E 4400006304BFC1E4041826E1503900000010104CE704C06400000"
"OneMannedFieldTurretData" should {
"decode (orion)" in {
PacketCoding.DecodePacket(string_orion).require match {
case ObjectCreateMessage(len, cls, guid, parent, data) =>
len mustEqual 350
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
case _ =>
ko
}
}
"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)
),
255,
InventoryData(List(OneMannedFieldTurretData.orion(PlanetSideGUID(2615), 0x6, 0x8, PlanetSideGUID(2510), 8)))
)
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)
)
)
}
}
}