2018-01-26 15:32:08 -05:00
|
|
|
// Copyright (c) 2017 PSForever
|
|
|
|
|
package objects
|
|
|
|
|
|
|
|
|
|
import akka.actor.{ActorRef, Props}
|
2018-07-14 21:25:44 -04:00
|
|
|
import base.ActorTest
|
2018-01-26 15:32:08 -05:00
|
|
|
import net.psforever.objects.GlobalDefinitions
|
|
|
|
|
import net.psforever.objects.serverobject.affinity.FactionAffinity
|
|
|
|
|
import net.psforever.objects.serverobject.doors.{Door, DoorControl}
|
2018-03-24 00:28:02 -04:00
|
|
|
import net.psforever.objects.serverobject.structures._
|
2018-01-26 15:32:08 -05:00
|
|
|
import net.psforever.objects.zones.Zone
|
2020-01-06 08:45:55 -05:00
|
|
|
import net.psforever.types.{PlanetSideEmpire, PlanetSideGUID}
|
2018-01-26 15:32:08 -05:00
|
|
|
import org.specs2.mutable.Specification
|
2018-06-16 20:09:25 -04:00
|
|
|
import services.ServiceManager
|
|
|
|
|
import services.galaxy.GalaxyService
|
2018-01-26 15:32:08 -05:00
|
|
|
|
2018-06-16 20:09:25 -04:00
|
|
|
import scala.concurrent.duration._
|
2018-01-26 15:32:08 -05:00
|
|
|
|
|
|
|
|
class AmenityTest extends Specification {
|
Destroy and repair (#346)
* bog-standard order_terminal amenities now take damage up to the point of destruction and can be repaired from destruction to functional to the point of being fully repaired; this is mostly proof fo concept
* restored proper destruction to FacilityTurrets; extended proper rrepairs to FacilityTurrets; co-opted terminal hacking into TerminalControl; started to expand on hacking protocol, but chose restraint
* changes made thus that a clear Definition hierarchy is established; all of this is in line with making future changes to repair/destroy variables, and making generic the repair code
* all meaningful facility amenities take damage and can be repaired; spawn tubes can be destroyed and the base will properly lose spawns (and show it on the map); some hack logic has been redistributed into the appropriate control objects, following in the wake of repair/damage logic
* deployables are repairable; the TRAP has been converted into a ComplexDeployable; changed the nature of the Repairable traits
* player bank repair and medapp heal has been moved out from WSA into PlayerControl
* overhaul of Progress callback system and the inclusion of player revival as a Progress activity
* begun relocating functionality for hacking outside of WSA; set up behavoir mixin for cargo operations, in order to move vehicle hack function, but did not yet integrate
* integration of the actor behavior mixin for vehicle cargo operations to support the integration of vehicle hacking finalization
* establishing inheritance/override potential of Damageable activity; Generator and SpawnTube map behavior behavior (currently inactive)
* ImplantTerminalMech objects now have a 'with-coordinates' constructor and a deprecated 'no-coordinates' constructor; implants mechs and interfaces are now damageable and repairable, and their damage state can also block mounting
* generators are destroyed and repaired properly, and even explode, killing a radius-worth of players
* destroy and repair pass on deployables, except for explosive types
* Damageable pass; client synchronization pass
* helpful comments
* some tests for damageable and repairable; refined output and repaired existing tests
* enabled friendly fire check and recovery
* handled friendly fire against allied mines; moved jammer code to common damageable behavior
* tweaks to damageability, infantry heal and repair, and sensor and explosive animations
* animations; framework for future vitals events; closing database connections
* adding some deployable tests; fixing a bunch of other tests; History is back
* testing for basic Damageable functions; removing a log message
* finicky animation stuff
* event messages to the Generator to represent health changes
* damage against BFR's is now only used against mythical creatures
* test fix
2020-04-14 15:17:32 -04:00
|
|
|
val definition = new AmenityDefinition(0) {
|
|
|
|
|
//intentionally blank
|
|
|
|
|
}
|
2018-01-26 15:32:08 -05:00
|
|
|
class AmenityObject extends Amenity {
|
Destroy and repair (#346)
* bog-standard order_terminal amenities now take damage up to the point of destruction and can be repaired from destruction to functional to the point of being fully repaired; this is mostly proof fo concept
* restored proper destruction to FacilityTurrets; extended proper rrepairs to FacilityTurrets; co-opted terminal hacking into TerminalControl; started to expand on hacking protocol, but chose restraint
* changes made thus that a clear Definition hierarchy is established; all of this is in line with making future changes to repair/destroy variables, and making generic the repair code
* all meaningful facility amenities take damage and can be repaired; spawn tubes can be destroyed and the base will properly lose spawns (and show it on the map); some hack logic has been redistributed into the appropriate control objects, following in the wake of repair/damage logic
* deployables are repairable; the TRAP has been converted into a ComplexDeployable; changed the nature of the Repairable traits
* player bank repair and medapp heal has been moved out from WSA into PlayerControl
* overhaul of Progress callback system and the inclusion of player revival as a Progress activity
* begun relocating functionality for hacking outside of WSA; set up behavoir mixin for cargo operations, in order to move vehicle hack function, but did not yet integrate
* integration of the actor behavior mixin for vehicle cargo operations to support the integration of vehicle hacking finalization
* establishing inheritance/override potential of Damageable activity; Generator and SpawnTube map behavior behavior (currently inactive)
* ImplantTerminalMech objects now have a 'with-coordinates' constructor and a deprecated 'no-coordinates' constructor; implants mechs and interfaces are now damageable and repairable, and their damage state can also block mounting
* generators are destroyed and repaired properly, and even explode, killing a radius-worth of players
* destroy and repair pass on deployables, except for explosive types
* Damageable pass; client synchronization pass
* helpful comments
* some tests for damageable and repairable; refined output and repaired existing tests
* enabled friendly fire check and recovery
* handled friendly fire against allied mines; moved jammer code to common damageable behavior
* tweaks to damageability, infantry heal and repair, and sensor and explosive animations
* animations; framework for future vitals events; closing database connections
* adding some deployable tests; fixing a bunch of other tests; History is back
* testing for basic Damageable functions; removing a log message
* finicky animation stuff
* event messages to the Generator to represent health changes
* damage against BFR's is now only used against mythical creatures
* test fix
2020-04-14 15:17:32 -04:00
|
|
|
def Definition : AmenityDefinition = definition
|
2018-01-26 15:32:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"Amenity" should {
|
|
|
|
|
"construct" in {
|
|
|
|
|
val ao = new AmenityObject()
|
|
|
|
|
ao.Owner mustEqual Building.NoBuilding
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"can be owned by a building" in {
|
|
|
|
|
val ao = new AmenityObject()
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-01-26 15:32:08 -05:00
|
|
|
|
|
|
|
|
ao.Owner = bldg
|
|
|
|
|
ao.Owner mustEqual bldg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"be owned by a vehicle" in {
|
|
|
|
|
import net.psforever.objects.Vehicle
|
|
|
|
|
val ao = new AmenityObject()
|
|
|
|
|
val veh = Vehicle(GlobalDefinitions.quadstealth)
|
|
|
|
|
|
|
|
|
|
ao.Owner = veh
|
|
|
|
|
ao.Owner mustEqual veh
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"not be owned by an unexpected object" in {
|
|
|
|
|
val ao = new AmenityObject()
|
|
|
|
|
//ao.Owner = net.psforever.objects.serverobject.mblocker.Locker() //will not compile
|
|
|
|
|
ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"confer faction allegiance through ownership" in {
|
|
|
|
|
//see FactionAffinityTest
|
|
|
|
|
val ao = new AmenityObject()
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-01-26 15:32:08 -05:00
|
|
|
ao.Owner = bldg
|
|
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
|
|
|
|
ao.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
|
|
|
|
|
|
|
|
|
bldg.Faction = PlanetSideEmpire.TR
|
|
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.TR
|
|
|
|
|
ao.Faction mustEqual PlanetSideEmpire.TR
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BuildingTest extends Specification {
|
|
|
|
|
"Building" should {
|
|
|
|
|
"construct" in {
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2019-04-04 19:32:28 +01:00
|
|
|
bldg.MapId mustEqual 10
|
2018-01-26 15:32:08 -05:00
|
|
|
bldg.Actor mustEqual ActorRef.noSender
|
|
|
|
|
bldg.Amenities mustEqual Nil
|
|
|
|
|
bldg.Zone mustEqual Zone.Nowhere
|
|
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"change faction affinity" in {
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-01-26 15:32:08 -05:00
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
|
|
|
|
|
|
|
|
|
bldg.Faction = PlanetSideEmpire.TR
|
|
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.TR
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"keep track of amenities" in {
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-01-26 15:32:08 -05:00
|
|
|
val door1 = Door(GlobalDefinitions.door)
|
|
|
|
|
val door2 = Door(GlobalDefinitions.door)
|
|
|
|
|
|
|
|
|
|
bldg.Amenities mustEqual Nil
|
|
|
|
|
bldg.Amenities = door2
|
|
|
|
|
bldg.Amenities mustEqual List(door2)
|
|
|
|
|
bldg.Amenities = door1
|
|
|
|
|
bldg.Amenities mustEqual List(door2, door1)
|
|
|
|
|
door1.Owner mustEqual bldg
|
|
|
|
|
door2.Owner mustEqual bldg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 23:26:38 -05:00
|
|
|
class WarpGateTest extends Specification {
|
|
|
|
|
"WarpGate" should {
|
|
|
|
|
"construct" in {
|
2019-12-11 08:34:29 -05:00
|
|
|
val bldg = WarpGate("WarpGate", 0, 10, Zone.Nowhere, GlobalDefinitions.warpgate)
|
2019-04-04 19:32:28 +01:00
|
|
|
bldg.MapId mustEqual 10
|
2018-03-05 23:26:38 -05:00
|
|
|
bldg.Actor mustEqual ActorRef.noSender
|
|
|
|
|
bldg.Amenities mustEqual Nil
|
|
|
|
|
bldg.Zone mustEqual Zone.Nowhere
|
|
|
|
|
bldg.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 15:32:08 -05:00
|
|
|
class BuildingControl1Test extends ActorTest {
|
|
|
|
|
"Building Control" should {
|
|
|
|
|
"construct" in {
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-01-26 15:32:08 -05:00
|
|
|
bldg.Actor = system.actorOf(Props(classOf[BuildingControl], bldg), "test")
|
|
|
|
|
assert(bldg.Actor != ActorRef.noSender)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BuildingControl2Test extends ActorTest {
|
2018-06-16 20:09:25 -04:00
|
|
|
ServiceManager.boot(system) ! ServiceManager.Register(Props[GalaxyService], "galaxy")
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-06-16 20:09:25 -04:00
|
|
|
bldg.Faction = PlanetSideEmpire.TR
|
|
|
|
|
bldg.Actor = system.actorOf(Props(classOf[BuildingControl], bldg), "test")
|
2018-07-14 21:25:44 -04:00
|
|
|
bldg.Actor ! "startup"
|
2018-06-16 20:09:25 -04:00
|
|
|
|
2018-01-26 15:32:08 -05:00
|
|
|
"Building Control" should {
|
|
|
|
|
"convert and assert faction affinity on convert request" in {
|
2018-07-14 21:25:44 -04:00
|
|
|
expectNoMsg(500 milliseconds)
|
2018-01-26 15:32:08 -05:00
|
|
|
|
2018-06-16 20:09:25 -04:00
|
|
|
assert(bldg.Faction == PlanetSideEmpire.TR)
|
2018-01-26 15:32:08 -05:00
|
|
|
bldg.Actor ! FactionAffinity.ConvertFactionAffinity(PlanetSideEmpire.VS)
|
2018-06-16 20:09:25 -04:00
|
|
|
val reply = receiveOne(500 milliseconds)
|
2018-01-26 15:32:08 -05:00
|
|
|
assert(reply.isInstanceOf[FactionAffinity.AssertFactionAffinity])
|
|
|
|
|
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].obj == bldg)
|
|
|
|
|
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].faction == PlanetSideEmpire.VS)
|
|
|
|
|
assert(bldg.Faction == PlanetSideEmpire.VS)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BuildingControl3Test extends ActorTest {
|
2018-06-16 20:09:25 -04:00
|
|
|
ServiceManager.boot(system) ! ServiceManager.Register(Props[GalaxyService], "galaxy")
|
2019-12-10 14:17:55 +00:00
|
|
|
val bldg = Building("Building", 0, 10, Zone.Nowhere, StructureType.Building)
|
2018-06-16 20:09:25 -04:00
|
|
|
bldg.Faction = PlanetSideEmpire.TR
|
|
|
|
|
bldg.Actor = system.actorOf(Props(classOf[BuildingControl], bldg), "test")
|
|
|
|
|
val door1 = Door(GlobalDefinitions.door)
|
|
|
|
|
door1.GUID = PlanetSideGUID(1)
|
|
|
|
|
door1.Actor = system.actorOf(Props(classOf[DoorControl], door1), "door1-test")
|
|
|
|
|
val door2 = Door(GlobalDefinitions.door)
|
|
|
|
|
door2.GUID = PlanetSideGUID(2)
|
|
|
|
|
door2.Actor = system.actorOf(Props(classOf[DoorControl], door2), "door2-test")
|
|
|
|
|
bldg.Amenities = door2
|
|
|
|
|
bldg.Amenities = door1
|
2018-07-14 21:25:44 -04:00
|
|
|
bldg.Actor ! "startup"
|
2018-06-16 20:09:25 -04:00
|
|
|
|
2018-01-26 15:32:08 -05:00
|
|
|
"Building Control" should {
|
|
|
|
|
"convert and assert faction affinity on convert request, and for each of its amenities" in {
|
2018-07-14 21:25:44 -04:00
|
|
|
expectNoMsg(500 milliseconds)
|
2018-06-16 20:09:25 -04:00
|
|
|
|
2018-01-26 15:32:08 -05:00
|
|
|
assert(bldg.Faction == PlanetSideEmpire.TR)
|
|
|
|
|
assert(bldg.Amenities.length == 2)
|
|
|
|
|
assert(bldg.Amenities.head == door2)
|
|
|
|
|
assert(bldg.Amenities(1) == door1)
|
|
|
|
|
|
|
|
|
|
bldg.Actor ! FactionAffinity.ConvertFactionAffinity(PlanetSideEmpire.VS)
|
2018-07-14 21:25:44 -04:00
|
|
|
val reply = ActorTest.receiveMultiple(3, 500 milliseconds, this)
|
|
|
|
|
//val reply = receiveN(3, Duration.create(5000, "ms"))
|
2018-01-26 15:32:08 -05:00
|
|
|
assert(reply.length == 3)
|
|
|
|
|
var building_count = 0
|
|
|
|
|
var door_count = 0
|
|
|
|
|
reply.foreach(item => {
|
|
|
|
|
assert(item.isInstanceOf[FactionAffinity.AssertFactionAffinity])
|
|
|
|
|
val item2 = item.asInstanceOf[FactionAffinity.AssertFactionAffinity]
|
|
|
|
|
item2.obj match {
|
|
|
|
|
case _ : Building =>
|
|
|
|
|
building_count += 1
|
|
|
|
|
case _ : Door =>
|
|
|
|
|
door_count += 1
|
|
|
|
|
case _ =>
|
|
|
|
|
assert(false)
|
|
|
|
|
}
|
|
|
|
|
assert(item2.faction == PlanetSideEmpire.VS)
|
|
|
|
|
})
|
|
|
|
|
assert(building_count == 1 && door_count == 2)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|