PSF-LoginServer/src/test/scala/game/ComponentDamageMessageTest.scala

68 lines
1.9 KiB
Scala
Raw Normal View History

Lump of Coal (#982) * preliminary elements needed to battle frame robotics; mostly from previous branch * introduction of FrameVehicleStateMessage and anticipated event system paths for BFR's; spawning amenities for BFR's are parsed and built from the zonemap files, but their coordinates are currently incorrect, and the resulting entity will not function atm * bfr's spawn correctly; default arm weapons will spawn correctly; bfr rearm terminal added but arm swap not working correctly; bfr shields charge if not full; proper separation of vehicle spawn pad types * arm weapon swapping in bfr's; swapped weapons switch, contextually, to either *_left or to *_right depending on the mounting; partial support for entities that do not have an OCDM packet form * crouching improves shield regeneration * some projectiles damage the bfr regardless of its shield * delay the final vehicle explosion; start of vehicle subsystems * handling for bfr shield ui updates; more of vehicle subsystems; corrections to TradeMessage packet; clarifications for FrameVehicleStateMessage package; report on flight status of bfr's * control agency support for vehicle subsystems for arm weapon fire control * vehicle capacitor, for what it's worth; shield and capacitor are influenced by recharge freeze and drain * initial packet and tests for AvatarAwardMessage; update the fields of FreindsResponse, DetailedCharacterData, and LoadoutType for FavoritesMessage; corrections to intiailization packets in SessionActor; players start as imprinted by default * support for GOAM and GAM integration into vehicle control agencies using a basic actor superclass; addition of vehicle subsystems; modifications to bfr control agency to allow for weapon handiness and subsystem control; fixed Fit mapping for vehicle override; made mountable seat transcoders independent * delayed explosions to accompany the delayed death for the bfr; bfr terminal window closes on successful purchase * the bfr armor siphon works * clarification for bfr inventory item manipulation; corrections to length of bfr transcoder for flight variants; everything else in in support of the various arm weapons that can be assigned to the bfr, including damage proxy support for causing/interacting with/cleaning up after radiation cloud projectiles * fixed the apc emp burst; fixed bfr arm weapon manipulation for activated subsystem; armor and ntu siphon support * battleframe loadouts available upon vehicle spawn (vs and tr only) * adb values for siphons; subsystem update message; some repairs * cargo vehicles are subject to radiation damage; damage for battleframes are different depending on shield evasion status; battleframe loadout deleting supported; bfr kill box; automatically wire bfr sheds, includeing the ones in sanctuary * proper bfr spawn angles; bfr vehicle timers; projectiles are no longer radiation clouds by default; better remote projectile cleanup; resolving incorrect weapon arm enabled states for bfrs * added tests for FrameVehicleState and GenericObjectActionAtPosition; pass around maximum sector for zone interactions * changed the triggers for the stamina regeneration timer * potential fix for issue related to finding arm weapon mounts * modifications to how vehicle subsystems are automated; jammer field updates; support and passing around custom block map ranges; does include activated dev tests for battleframe PAM, which will need to be stripped out later * commit while working on subsystems mk2 * subsystems fail when jammed; an unoccupied bfr does not have shields active; pulling a bfr of one variant should block the other variant too * fix distance check with radiation clouds; blocked bfr weaponry from anywhere but bfr arm mounts and cursor; ammunition depletion of aphelion laser; bfr shields deactivates when unoccupied * significant modifications to vehicle subsystem operations; disambiguation of weapon subsystems; debuffs to charge rate and use rate for the capacitor and shield of bfr; test for ComponentDamageMessage; somewhat proper jammering operations for bfr
2022-01-27 09:57:51 -05:00
// Copyright (c) 2021 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.{PlanetSideGUID, SubsystemComponent}
import scodec.bits._
class ComponentDamageMessageTest extends Specification {
val string_on = hex"d3 8f01 1a000000820000000000202040"
val string_off = hex"d3 8f01 1a00000000"
"decode (on)" in {
PacketCoding.decodePacket(string_on).require match {
case ComponentDamageMessage(guid, code, data) =>
guid mustEqual PlanetSideGUID(399)
code mustEqual SubsystemComponent.WeaponSystemsCOFRecovery
data match {
case Some(ComponentDamageField(u2, u3, u4)) =>
u2 mustEqual 4
u3 mustEqual 1077936128
u4 mustEqual true
case _ =>
ko
}
case _ =>
ko
}
}
"decode (off)" in {
PacketCoding.decodePacket(string_off).require match {
case ComponentDamageMessage(guid, code, data) =>
guid mustEqual PlanetSideGUID(399)
code mustEqual SubsystemComponent.WeaponSystemsCOFRecovery
data.isEmpty mustEqual true
case _ =>
ko
}
}
"encode (on)" in {
val msg = ComponentDamageMessage(
PlanetSideGUID(399),
SubsystemComponent.WeaponSystemsCOFRecovery,
Some(ComponentDamageField(4, 1077936128, unk = true))
)
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_on
}
"encode (off; 1)" in {
val msg = ComponentDamageMessage(PlanetSideGUID(399), SubsystemComponent.WeaponSystemsCOFRecovery, None)
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_off
}
"encode (off; 2)" in {
val msg = ComponentDamageMessage(PlanetSideGUID(399), SubsystemComponent.WeaponSystemsCOFRecovery)
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
pkt mustEqual string_off
}
}