mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-27 18:23:36 +00:00
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
This commit is contained in:
parent
6cd18c5623
commit
5f3e7e5df8
113 changed files with 8155 additions and 2312 deletions
330
common/src/test/scala/objects/DeployableTest.scala
Normal file
330
common/src/test/scala/objects/DeployableTest.scala
Normal file
|
|
@ -0,0 +1,330 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{Actor, ActorRef, Props}
|
||||
import base.ActorTest
|
||||
import net.psforever.objects.ce.DeployedItem
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.{TurretDeployable, _}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class DeployableTest extends Specification {
|
||||
"Deployable" should {
|
||||
"know its owner by GUID" in {
|
||||
val obj = new ExplosiveDeployable(GlobalDefinitions.he_mine)
|
||||
obj.Owner mustEqual None
|
||||
obj.Owner = PlanetSideGUID(10)
|
||||
obj.Owner mustEqual Some(PlanetSideGUID(10))
|
||||
}
|
||||
|
||||
"know its owner by GUID" in {
|
||||
val obj = new ExplosiveDeployable(GlobalDefinitions.he_mine)
|
||||
obj.OwnerName mustEqual None
|
||||
obj.OwnerName = "TestCharacter"
|
||||
obj.OwnerName mustEqual Some("TestCharacter")
|
||||
}
|
||||
|
||||
"know its faction allegiance" in {
|
||||
val obj = new ExplosiveDeployable(GlobalDefinitions.he_mine)
|
||||
obj.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Faction mustEqual PlanetSideEmpire.TR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SensorDeployableTest extends Specification {
|
||||
"SensorDeployable" should {
|
||||
"construct" in {
|
||||
new SensorDeployable(GlobalDefinitions.motionalarmsensor)
|
||||
ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ExplosiveDeployableTest extends Specification {
|
||||
"ExplosiveDeployable" should {
|
||||
"construct" in {
|
||||
val obj = new ExplosiveDeployable(GlobalDefinitions.he_mine)
|
||||
obj.Exploded mustEqual false
|
||||
}
|
||||
|
||||
"explode" in {
|
||||
val obj = new ExplosiveDeployable(GlobalDefinitions.he_mine)
|
||||
obj.Exploded mustEqual false
|
||||
obj.Exploded = true
|
||||
obj.Exploded mustEqual true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BoomerDeployableTest extends Specification {
|
||||
"BoomerDeployable" should {
|
||||
"construct" in {
|
||||
val obj = new BoomerDeployable(GlobalDefinitions.boomer)
|
||||
obj.Exploded mustEqual false
|
||||
obj.Trigger mustEqual None
|
||||
}
|
||||
|
||||
"explode" in {
|
||||
val obj = new BoomerDeployable(GlobalDefinitions.boomer)
|
||||
obj.Exploded mustEqual false
|
||||
obj.Exploded = true
|
||||
obj.Exploded mustEqual true
|
||||
}
|
||||
|
||||
"manage its trigger" in {
|
||||
val obj = new BoomerDeployable(GlobalDefinitions.boomer)
|
||||
obj.Trigger mustEqual None
|
||||
|
||||
val trigger = new BoomerTrigger
|
||||
obj.Trigger = trigger
|
||||
obj.Trigger mustEqual Some(trigger)
|
||||
|
||||
obj.Trigger = None
|
||||
obj.Trigger mustEqual None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TrapDeployableTest extends Specification {
|
||||
"SensorDeployable" should {
|
||||
"construct" in {
|
||||
val obj = new TrapDeployable(GlobalDefinitions.tank_traps)
|
||||
obj.Health mustEqual GlobalDefinitions.tank_traps.MaxHealth
|
||||
}
|
||||
|
||||
"update health values" in {
|
||||
val obj = new TrapDeployable(GlobalDefinitions.tank_traps)
|
||||
obj.Health mustEqual GlobalDefinitions.tank_traps.MaxHealth
|
||||
obj.Health = 0
|
||||
obj.Health mustEqual 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretDeployableTest extends Specification {
|
||||
"TurretDeployable" should {
|
||||
"define (valid turret objects)" in {
|
||||
List(
|
||||
DeployedItem.spitfire_turret.id, DeployedItem.spitfire_cloaked.id, DeployedItem.spitfire_aa.id,
|
||||
DeployedItem.portable_manned_turret.id, DeployedItem.portable_manned_turret_tr.id,
|
||||
DeployedItem.portable_manned_turret_nc.id, DeployedItem.portable_manned_turret_vs.id
|
||||
).foreach(id => {
|
||||
try { new TurretDeployableDefinition(id) } catch { case _ : Exception => ko }
|
||||
})
|
||||
ok
|
||||
}
|
||||
|
||||
"define (invalid object)" in {
|
||||
new TurretDeployableDefinition(5) must throwA[NoSuchElementException] //wrong object id altogether
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.spitfire_turret)
|
||||
obj.Health mustEqual obj.MaxHealth
|
||||
}
|
||||
|
||||
"update health values" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.spitfire_turret)
|
||||
obj.Health mustEqual GlobalDefinitions.spitfire_turret.MaxHealth
|
||||
obj.Health = 0
|
||||
obj.Health mustEqual 0
|
||||
}
|
||||
|
||||
"may have mount point" in {
|
||||
new TurretDeployable(GlobalDefinitions.spitfire_turret).MountPoints mustEqual Map()
|
||||
new TurretDeployable(GlobalDefinitions.portable_manned_turret_vs).MountPoints mustEqual Map(1 -> 0, 2 -> 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ShieldGeneratorDeployableTest extends Specification {
|
||||
"ShieldGeneratorDeployable" should {
|
||||
"construct" in {
|
||||
val obj = new ShieldGeneratorDeployable(GlobalDefinitions.deployable_shield_generator)
|
||||
obj.Health mustEqual obj.MaxHealth
|
||||
}
|
||||
|
||||
"update health values" in {
|
||||
val obj = new ShieldGeneratorDeployable(GlobalDefinitions.deployable_shield_generator)
|
||||
obj.Health mustEqual GlobalDefinitions.deployable_shield_generator.MaxHealth
|
||||
obj.Health = 0
|
||||
obj.Health mustEqual 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlConstructTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"construct" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.spitfire_turret)
|
||||
system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlInitializeTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"initialize" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.spitfire_turret)
|
||||
obj.GUID = PlanetSideGUID(1)
|
||||
assert(obj.Actor == ActorRef.noSender)
|
||||
val init = system.actorOf(Props(classOf[DeployableTest.TurretInitializer], obj), "init_turret_test")
|
||||
init ! "initialize"
|
||||
expectNoMsg(200 milliseconds)
|
||||
assert(obj.Actor != ActorRef.noSender)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlUninitializeTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"uninitialize" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.spitfire_turret)
|
||||
val init = system.actorOf(Props(classOf[DeployableTest.TurretInitializer], obj), "init_turret_test")
|
||||
obj.GUID = PlanetSideGUID(1)
|
||||
init ! "initialize"
|
||||
expectNoMsg(200 milliseconds)
|
||||
assert(obj.Actor != ActorRef.noSender)
|
||||
|
||||
init ! "uninitialize"
|
||||
expectNoMsg(200 milliseconds)
|
||||
assert(obj.Actor == ActorRef.noSender)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlMountTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"control mounting" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.portable_manned_turret_tr) { GUID = PlanetSideGUID(1) }
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Actor = system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
val player1 = Player(Avatar("test1", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
obj.Actor ! Mountable.TryMount(player1, 0)
|
||||
val reply1a = receiveOne(200 milliseconds)
|
||||
assert(reply1a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply1b = reply1a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply1b.player == player1)
|
||||
assert(reply1b.response.isInstanceOf[Mountable.CanMount])
|
||||
assert(obj.Seats(0).Occupant.contains(player1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlBlockMountTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"block mounting by others if already mounted by someone" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.portable_manned_turret_tr) { GUID = PlanetSideGUID(1) }
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Actor = system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
val player1 = Player(Avatar("test1", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
obj.Actor ! Mountable.TryMount(player1, 0)
|
||||
val reply1a = receiveOne(200 milliseconds)
|
||||
assert(reply1a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply1b = reply1a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply1b.player == player1)
|
||||
assert(reply1b.response.isInstanceOf[Mountable.CanMount])
|
||||
assert(obj.Seats(0).Occupant.contains(player1))
|
||||
|
||||
val player2 = Player(Avatar("test2", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
obj.Actor ! Mountable.TryMount(player2, 0)
|
||||
val reply2a = receiveOne(200 milliseconds)
|
||||
assert(reply2a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply2b = reply2a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply2b.player == player2)
|
||||
assert(reply2b.response.isInstanceOf[Mountable.CanNotMount])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlBlockBetrayalMountTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"block mounting by players of another faction" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.portable_manned_turret_tr) { GUID = PlanetSideGUID(1) }
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Actor = system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.VS, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
obj.Actor ! Mountable.TryMount(player, 0)
|
||||
val reply1a = receiveOne(200 milliseconds)
|
||||
assert(reply1a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply1b = reply1a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply1b.player == player)
|
||||
assert(reply1b.response.isInstanceOf[Mountable.CanNotMount])
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlDismountTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"control dismounting" in {
|
||||
val obj = new TurretDeployable(GlobalDefinitions.portable_manned_turret_tr) { GUID = PlanetSideGUID(1) }
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Actor = system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
obj.Actor ! Mountable.TryMount(player, 0)
|
||||
val reply1a = receiveOne(200 milliseconds)
|
||||
assert(reply1a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply1b = reply1a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply1b.player == player)
|
||||
assert(reply1b.response.isInstanceOf[Mountable.CanMount])
|
||||
assert(obj.Seats(0).Occupant.contains(player))
|
||||
|
||||
obj.Actor ! Mountable.TryDismount(player, 0)
|
||||
val reply2a = receiveOne(200 milliseconds)
|
||||
assert(reply2a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply2b = reply2a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply2b.player == player)
|
||||
assert(reply2b.response.isInstanceOf[Mountable.CanDismount])
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TurretControlBetrayalMountTest extends ActorTest {
|
||||
"TurretControl" should {
|
||||
"allow all allegiances" in {
|
||||
val obj = new TurretDeployable(
|
||||
new TurretDeployableDefinition(685) { FactionLocked = false } //required (defaults to true)
|
||||
) { GUID = PlanetSideGUID(1) }
|
||||
obj.Faction = PlanetSideEmpire.TR
|
||||
obj.Actor = system.actorOf(Props(classOf[TurretControl], obj), s"${obj.Definition.Name}_test")
|
||||
|
||||
assert(obj.Seats(0).Occupant.isEmpty)
|
||||
val player = Player(Avatar("test", PlanetSideEmpire.NC, CharacterGender.Male, 0, CharacterVoice.Mute))
|
||||
assert(player.Faction != obj.Faction)
|
||||
obj.Actor ! Mountable.TryMount(player, 0)
|
||||
val reply1a = receiveOne(200 milliseconds)
|
||||
assert(reply1a.isInstanceOf[Mountable.MountMessages])
|
||||
val reply1b = reply1a.asInstanceOf[Mountable.MountMessages]
|
||||
assert(reply1b.player == player)
|
||||
assert(reply1b.response.isInstanceOf[Mountable.CanMount])
|
||||
assert(obj.Seats(0).Occupant.contains(player))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object DeployableTest {
|
||||
class TurretInitializer(obj : TurretDeployable) extends Actor {
|
||||
def receive : Receive = {
|
||||
case "initialize" =>
|
||||
obj.Definition.Initialize(obj, context)
|
||||
case "uninitialize" =>
|
||||
obj.Definition.Uninitialize(obj, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue