2018-07-14 21:25:44 -04:00
|
|
|
// Copyright (c) 2017 PSForever
|
|
|
|
|
package objects
|
|
|
|
|
|
|
|
|
|
import akka.actor.{Actor, Props}
|
|
|
|
|
import akka.routing.RandomPool
|
|
|
|
|
import akka.testkit.TestProbe
|
|
|
|
|
import base.ActorTest
|
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
|
|
|
import net.psforever.objects.guid.{NumberPoolHub, TaskResolver}
|
|
|
|
|
import net.psforever.objects.guid.source.LimitedNumberSource
|
|
|
|
|
import net.psforever.objects.{Avatar, GlobalDefinitions, Player, Vehicle}
|
2018-07-14 21:25:44 -04:00
|
|
|
import net.psforever.objects.serverobject.resourcesilo.{ResourceSilo, ResourceSiloControl, ResourceSiloDefinition}
|
|
|
|
|
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
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
|
|
|
import net.psforever.objects.zones.{Zone, ZoneActor, ZoneMap}
|
2020-01-06 08:45:55 -05:00
|
|
|
import net.psforever.packet.game.UseItemMessage
|
|
|
|
|
import net.psforever.types._
|
2018-07-14 21:25:44 -04:00
|
|
|
import org.specs2.mutable.Specification
|
2019-12-11 08:34:29 -05:00
|
|
|
import services.ServiceManager
|
2019-04-08 08:05:15 -04:00
|
|
|
import services.avatar.{AvatarAction, AvatarServiceMessage}
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
import scala.concurrent.duration._
|
|
|
|
|
|
|
|
|
|
class ResourceSiloTest extends Specification {
|
|
|
|
|
"Resource Silo" should {
|
|
|
|
|
"define" in {
|
|
|
|
|
val obj = new ResourceSiloDefinition
|
|
|
|
|
obj.ObjectId mustEqual 731
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"construct" in {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.Definition mustEqual GlobalDefinitions.resource_silo
|
|
|
|
|
obj.MaximumCharge mustEqual 1000
|
|
|
|
|
obj.ChargeLevel mustEqual 0
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.LowNtuWarningOn mustEqual true
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.CapacitorDisplay mustEqual 0
|
|
|
|
|
//
|
|
|
|
|
obj.ChargeLevel = 50
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.LowNtuWarningOn = false
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.CapacitorDisplay = 75
|
|
|
|
|
obj.ChargeLevel mustEqual 50
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.LowNtuWarningOn mustEqual false
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.CapacitorDisplay mustEqual 75
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"charge level can not exceed limits(0 to maximum)" in {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.ChargeLevel mustEqual 0
|
|
|
|
|
obj.ChargeLevel = -5
|
|
|
|
|
obj.ChargeLevel mustEqual 0
|
|
|
|
|
|
2019-12-10 14:17:55 +00:00
|
|
|
obj.ChargeLevel = obj.MaximumCharge + 100
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.ChargeLevel mustEqual 1000
|
|
|
|
|
obj.ChargeLevel mustEqual obj.MaximumCharge
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"using the silo generates a charge event" in {
|
|
|
|
|
val msg = UseItemMessage(PlanetSideGUID(1), PlanetSideGUID(0), PlanetSideGUID(2), 0L, false, Vector3(0f,0f,0f),Vector3(0f,0f,0f),0,0,0,0L) //faked
|
|
|
|
|
ResourceSilo().Use(ResourceSiloTest.player, msg) mustEqual ResourceSilo.ChargeEvent()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlStartupTest extends ActorTest {
|
|
|
|
|
val serviceManager = ServiceManager.boot(system)
|
|
|
|
|
serviceManager ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.GUID = PlanetSideGUID(1)
|
|
|
|
|
val probe = TestProbe()
|
|
|
|
|
serviceManager ! ServiceManager.Register(Props(classOf[ResourceSiloTest.ProbedAvatarService], probe), "avatar")
|
|
|
|
|
|
|
|
|
|
"Resource silo" should {
|
|
|
|
|
"startup properly" in {
|
|
|
|
|
expectNoMsg(500 milliseconds)
|
|
|
|
|
system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
|
|
|
|
expectNoMsg(1 seconds)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlUseTest extends ActorTest {
|
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 guid = new NumberPoolHub(new LimitedNumberSource(10))
|
|
|
|
|
val map = new ZoneMap("test")
|
|
|
|
|
val zone = new Zone("test", map, 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
GUID(guid)
|
|
|
|
|
}
|
|
|
|
|
zone.Actor = system.actorOf(Props(classOf[ZoneActor], zone), "test-zone-actor")
|
|
|
|
|
zone.Actor ! Zone.Init()
|
|
|
|
|
val building = new Building("Building", building_guid = 0, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building) //guid=1
|
|
|
|
|
|
|
|
|
|
val obj = ResourceSilo() //guid=2
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Actor = system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
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
|
|
|
obj.Owner = building
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Actor ! "startup"
|
|
|
|
|
|
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 player = Player(new Avatar(0L, "TestCharacter", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute)) //guid=3
|
|
|
|
|
val vehicle = Vehicle(GlobalDefinitions.ant) //guid=4
|
|
|
|
|
|
|
|
|
|
guid.register(building, 1)
|
|
|
|
|
guid.register(obj, 2)
|
|
|
|
|
guid.register(player, 3)
|
|
|
|
|
guid.register(vehicle, 4)
|
2020-04-16 17:46:00 -04:00
|
|
|
expectNoMsg(200 milliseconds)
|
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
|
|
|
zone.Transport ! Zone.Vehicle.Spawn(vehicle)
|
|
|
|
|
vehicle.Seats(0).Occupant = player
|
|
|
|
|
player.VehicleSeated = vehicle.GUID
|
|
|
|
|
val msg = UseItemMessage(PlanetSideGUID(1), PlanetSideGUID(0), PlanetSideGUID(2), 0L, false, Vector3.Zero,Vector3.Zero,0,0,0,0L) //faked
|
|
|
|
|
expectNoMsg(200 milliseconds)
|
|
|
|
|
|
2018-07-14 21:25:44 -04:00
|
|
|
"Resource silo" should {
|
|
|
|
|
"respond when being used" in {
|
|
|
|
|
expectNoMsg(1 seconds)
|
|
|
|
|
obj.Actor ! ResourceSilo.Use(ResourceSiloTest.player, msg)
|
|
|
|
|
|
|
|
|
|
val reply = receiveOne(500 milliseconds)
|
|
|
|
|
assert(reply.isInstanceOf[ResourceSilo.ResourceSiloMessage])
|
|
|
|
|
assert(reply.asInstanceOf[ResourceSilo.ResourceSiloMessage].player == ResourceSiloTest.player)
|
|
|
|
|
assert(reply.asInstanceOf[ResourceSilo.ResourceSiloMessage].msg == msg)
|
|
|
|
|
assert(reply.asInstanceOf[ResourceSilo.ResourceSiloMessage].response == ResourceSilo.ChargeEvent())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlNtuWarningTest extends ActorTest {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.GUID = PlanetSideGUID(1)
|
|
|
|
|
obj.Actor = system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
|
|
|
|
obj.Actor ! "startup"
|
2019-12-10 14:17:55 +00:00
|
|
|
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
2019-12-11 08:34:29 -05:00
|
|
|
obj.Owner = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
2020-01-19 21:32:14 -05:00
|
|
|
obj.Owner.GUID = PlanetSideGUID(6)
|
2019-12-10 08:37:57 -05:00
|
|
|
val zoneEvents = TestProbe("zone-events")
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
"Resource silo" should {
|
2018-07-18 13:41:28 +01:00
|
|
|
"announce high ntu" in {
|
2019-12-10 08:37:57 -05:00
|
|
|
zone.AvatarEvents = zoneEvents.ref
|
|
|
|
|
assert(obj.LowNtuWarningOn)
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.Actor ! ResourceSilo.LowNtuWarning(false)
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2019-12-10 08:37:57 -05:00
|
|
|
val reply = zoneEvents.receiveOne(500 milliseconds)
|
|
|
|
|
assert(!obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(6))
|
|
|
|
|
assert(reply.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 47)
|
|
|
|
|
assert(reply.asInstanceOf[AvatarServiceMessage]
|
2018-07-18 13:41:28 +01:00
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 0)
|
2018-07-14 21:25:44 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlUpdate1Test extends ActorTest {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.GUID = PlanetSideGUID(1)
|
|
|
|
|
obj.Actor = system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
|
|
|
|
obj.Actor ! "startup"
|
2019-12-10 14:17:55 +00:00
|
|
|
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
2019-12-11 08:34:29 -05:00
|
|
|
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
2020-01-19 21:32:14 -05:00
|
|
|
bldg.GUID = PlanetSideGUID(6)
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Owner = bldg
|
2019-12-10 08:37:57 -05:00
|
|
|
val zoneEvents = TestProbe("zone-events")
|
|
|
|
|
val buildingEvents = TestProbe("building-events")
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
"Resource silo" should {
|
2018-07-18 13:41:28 +01:00
|
|
|
"update the charge level and capacitor display (report high ntu, power restored)" in {
|
2019-12-10 08:37:57 -05:00
|
|
|
zone.AvatarEvents = zoneEvents.ref
|
|
|
|
|
bldg.Actor = buildingEvents.ref
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
assert(obj.ChargeLevel == 0)
|
|
|
|
|
assert(obj.CapacitorDisplay == 0)
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.Actor ! ResourceSilo.UpdateChargeLevel(305)
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2019-12-10 08:37:57 -05:00
|
|
|
val reply1 = zoneEvents.receiveOne(500 milliseconds)
|
|
|
|
|
val reply2 = buildingEvents.receiveOne(500 milliseconds)
|
2018-07-18 13:41:28 +01:00
|
|
|
assert(obj.ChargeLevel == 305)
|
2019-08-21 15:33:26 +01:00
|
|
|
assert(obj.CapacitorDisplay == 4)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply1.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(1))
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 45)
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
2019-08-21 15:33:26 +01:00
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 4)
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2018-08-10 23:21:15 +01:00
|
|
|
assert(reply2.isInstanceOf[Building.SendMapUpdate])
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2019-12-10 08:37:57 -05:00
|
|
|
val reply3 = zoneEvents.receiveOne(500 milliseconds)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply3.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(6))
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 48)
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 0)
|
|
|
|
|
|
2019-12-10 08:37:57 -05:00
|
|
|
val reply4 = zoneEvents.receiveOne(500 milliseconds)
|
2018-09-23 08:00:58 -04:00
|
|
|
assert(!obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply4.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply4.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply4.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply4.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(6))
|
|
|
|
|
assert(reply4.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 47)
|
|
|
|
|
assert(reply4.asInstanceOf[AvatarServiceMessage]
|
2018-07-18 13:41:28 +01:00
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 0)
|
2018-07-14 21:25:44 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlUpdate2Test extends ActorTest {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.GUID = PlanetSideGUID(1)
|
|
|
|
|
obj.Actor = system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
|
|
|
|
obj.Actor ! "startup"
|
2019-12-10 14:17:55 +00:00
|
|
|
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
2019-12-11 08:34:29 -05:00
|
|
|
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
2020-01-19 21:32:14 -05:00
|
|
|
bldg.GUID = PlanetSideGUID(6)
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Owner = bldg
|
2019-12-10 08:37:57 -05:00
|
|
|
val zoneEvents = TestProbe("zone-events")
|
|
|
|
|
val buildingEvents = TestProbe("building-events")
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
"Resource silo" should {
|
|
|
|
|
"update the charge level and capacitor display (report good ntu)" in {
|
2019-12-10 08:37:57 -05:00
|
|
|
zone.AvatarEvents = zoneEvents.ref
|
|
|
|
|
bldg.Actor = buildingEvents.ref
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
obj.ChargeLevel = 100
|
|
|
|
|
obj.CapacitorDisplay = 1
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.LowNtuWarningOn = true
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(obj.ChargeLevel == 100)
|
|
|
|
|
assert(obj.CapacitorDisplay == 1)
|
2019-12-10 08:37:57 -05:00
|
|
|
assert(obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Actor ! ResourceSilo.UpdateChargeLevel(105)
|
|
|
|
|
|
2019-12-11 08:34:29 -05:00
|
|
|
val reply1 = zoneEvents.receiveOne(1000 milliseconds)
|
|
|
|
|
val reply2 = buildingEvents.receiveOne(1000 milliseconds)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(obj.ChargeLevel == 205)
|
2019-08-21 15:33:26 +01:00
|
|
|
assert(obj.CapacitorDisplay == 3)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply1.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(1))
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 45)
|
|
|
|
|
assert(reply1.asInstanceOf[AvatarServiceMessage]
|
2019-08-21 15:33:26 +01:00
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 3)
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2018-08-10 23:21:15 +01:00
|
|
|
assert(reply2.isInstanceOf[Building.SendMapUpdate])
|
2018-07-14 21:25:44 -04:00
|
|
|
|
2019-12-10 08:37:57 -05:00
|
|
|
val reply3 = zoneEvents.receiveOne(500 milliseconds)
|
|
|
|
|
assert(!obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(reply3.isInstanceOf[AvatarServiceMessage])
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage].forChannel == "nowhere")
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.isInstanceOf[AvatarAction.PlanetsideAttribute])
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].player_guid == PlanetSideGUID(6))
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_type == 47)
|
|
|
|
|
assert(reply3.asInstanceOf[AvatarServiceMessage]
|
|
|
|
|
.actionMessage.asInstanceOf[AvatarAction.PlanetsideAttribute].attribute_value == 0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ResourceSiloControlNoUpdateTest extends ActorTest {
|
|
|
|
|
val obj = ResourceSilo()
|
|
|
|
|
obj.GUID = PlanetSideGUID(1)
|
|
|
|
|
obj.Actor = system.actorOf(Props(classOf[ResourceSiloControl], obj), "test-silo")
|
|
|
|
|
obj.Actor ! "startup"
|
2019-12-10 14:17:55 +00:00
|
|
|
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
2019-12-11 08:34:29 -05:00
|
|
|
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
2020-01-19 21:32:14 -05:00
|
|
|
bldg.GUID = PlanetSideGUID(6)
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Owner = bldg
|
2019-12-10 08:37:57 -05:00
|
|
|
val zoneEvents = TestProbe("zone-events")
|
|
|
|
|
val buildingEvents = TestProbe("building-events")
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
"Resource silo" should {
|
|
|
|
|
"update, but not sufficiently to change the capacitor display" in {
|
2019-12-10 08:37:57 -05:00
|
|
|
zone.AvatarEvents = zoneEvents.ref
|
|
|
|
|
bldg.Actor = buildingEvents.ref
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
obj.ChargeLevel = 250
|
|
|
|
|
obj.CapacitorDisplay = 3
|
2018-07-18 13:41:28 +01:00
|
|
|
obj.LowNtuWarningOn = false
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(obj.ChargeLevel == 250)
|
|
|
|
|
assert(obj.CapacitorDisplay == 3)
|
2019-12-10 08:37:57 -05:00
|
|
|
assert(!obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
obj.Actor ! ResourceSilo.UpdateChargeLevel(50)
|
|
|
|
|
|
|
|
|
|
expectNoMsg(500 milliseconds)
|
2019-12-10 08:37:57 -05:00
|
|
|
zoneEvents.expectNoMsg(500 milliseconds)
|
|
|
|
|
buildingEvents.expectNoMsg(500 milliseconds)
|
2019-04-04 19:32:28 +01:00
|
|
|
assert(obj.ChargeLevel == 299 || obj.ChargeLevel == 300) // Just in case the capacitor level drops while waiting for the message check 299 & 300
|
2018-07-14 21:25:44 -04:00
|
|
|
assert(obj.CapacitorDisplay == 3)
|
2019-12-10 08:37:57 -05:00
|
|
|
assert(!obj.LowNtuWarningOn)
|
2018-07-14 21:25:44 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object ResourceSiloTest {
|
2019-12-10 08:37:57 -05:00
|
|
|
val player = Player(new Avatar(0L, "TestCharacter", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
2018-07-14 21:25:44 -04:00
|
|
|
|
|
|
|
|
class ProbedAvatarService(probe : TestProbe) extends Actor {
|
|
|
|
|
override def receive : Receive = {
|
|
|
|
|
case msg =>
|
|
|
|
|
probe.ref ! msg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ProbedBuildingControl(probe : TestProbe) extends Actor {
|
|
|
|
|
override def receive : Receive = {
|
|
|
|
|
case msg =>
|
|
|
|
|
probe.ref ! msg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ProbedResourceSiloControl(silo : ResourceSilo, probe : TestProbe) extends ResourceSiloControl(silo) {
|
|
|
|
|
override def receive : Receive = {
|
|
|
|
|
case msg =>
|
|
|
|
|
super.receive.apply(msg)
|
|
|
|
|
probe.ref ! msg
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|