mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-04 12:40:20 +00:00
Facility Turrets (#223)
* object class, actor class, and definitions for base turrets; untested * wired base turrets into existence, with hoop jumping; created interface for objects with mounted weapons (vehicles and turrets); working example phalanx_sgl_hevgatcan in Anguta, Ceryshen * re-wiring manned turrets so that the turreted weapon itself never changes externally but merely identifies different and changes internally; workflow for upgrading wall turrets in place (30s); clarifications and documentation for HackMessage and UseItemMessage; getting rid of orphaned packages from previous location of services * added a simple task that reverts upgraded manned turrets to their None state after a certain amount of time has passed; it works but need improvement * turret weapon upgrades now last for a duration of 30 minutes before reverting; created a service support actor base actor that underlies all current support actors; nano-dispenser now properly loads 1 unit of upgrade canister, rather than 100 units; all canister types have appropriate 2x3 inventory size * forgot to hurry; moved over the Services tests from main/test folder into the common/test folder and needed to change the location of ActorTest to accommodate it; test and documentation for MannedTurret; codecov ignore update * wired facility turrets in Anguta, Ceryshen; Akna tower, Ceryshen; and S.Villa tower, home3 (Anguta tower is a watchtower); attempted workaround for Travis CI issues with receiveN; re-introduced RemoveActorTest, at least the first test; expanded how ZoneActor performs tests on MannedTurret setup * getting rid of useless commented-out code; making common operations for mounting and dismounting * removed outdated comment; added ResourceSilo tests; added extra test for Zone
This commit is contained in:
parent
61a51c1dd1
commit
b81ff2bbf4
75 changed files with 2246 additions and 680 deletions
|
|
@ -11,6 +11,8 @@ import net.psforever.objects.serverobject.pad.VehicleSpawnPad
|
|||
import net.psforever.objects.serverobject.structures.{Building, FoundationBuilder, StructureType, WarpGate}
|
||||
import net.psforever.objects.serverobject.terminals.{ProximityTerminal, Terminal}
|
||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects.serverobject.resourcesilo.ResourceSilo
|
||||
import net.psforever.objects.serverobject.turret.MannedTurret
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
object Maps {
|
||||
|
|
@ -1215,6 +1217,14 @@ object Maps {
|
|||
LocalObject(1186, Locker.Constructor)
|
||||
LocalObject(1187, Locker.Constructor)
|
||||
LocalObject(1188, Locker.Constructor)
|
||||
LocalObject(1418, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1419, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1421, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1426, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1427, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1428, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1431, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1432, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1492, ProximityTerminal.Constructor(medical_terminal)) //lobby
|
||||
LocalObject(1494, ProximityTerminal.Constructor(medical_terminal)) //kitchen
|
||||
LocalObject(1564, Terminal.Constructor(order_terminal))
|
||||
|
|
@ -1330,6 +1340,14 @@ object Maps {
|
|||
ObjectToBuilding(1186, 2)
|
||||
ObjectToBuilding(1187, 2)
|
||||
ObjectToBuilding(1188, 2)
|
||||
ObjectToBuilding(1418, 2)
|
||||
ObjectToBuilding(1419, 2)
|
||||
ObjectToBuilding(1421, 2)
|
||||
ObjectToBuilding(1426, 2)
|
||||
ObjectToBuilding(1427, 2)
|
||||
ObjectToBuilding(1428, 2)
|
||||
ObjectToBuilding(1431, 2)
|
||||
ObjectToBuilding(1432, 2)
|
||||
ObjectToBuilding(1492, 2)
|
||||
ObjectToBuilding(1494, 2)
|
||||
ObjectToBuilding(1479, 2)
|
||||
|
|
@ -1385,6 +1403,14 @@ object Maps {
|
|||
DoorToLock(715, 751)
|
||||
TerminalToSpawnPad(224, 223)
|
||||
TerminalToSpawnPad(2419, 1479)
|
||||
TurretToWeapon(1418, 5000)
|
||||
TurretToWeapon(1419, 5001)
|
||||
TurretToWeapon(1421, 5002)
|
||||
TurretToWeapon(1426, 5003)
|
||||
TurretToWeapon(1427, 5004)
|
||||
TurretToWeapon(1428, 5005)
|
||||
TurretToWeapon(1431, 5006)
|
||||
TurretToWeapon(1432, 5007)
|
||||
}
|
||||
|
||||
def Building38() : Unit = {
|
||||
|
|
@ -1487,6 +1513,8 @@ object Maps {
|
|||
LocalObject(1226, Locker.Constructor)
|
||||
LocalObject(1227, Locker.Constructor)
|
||||
LocalObject(1228, Locker.Constructor)
|
||||
LocalObject(1440, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1442, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(1591, Terminal.Constructor(order_terminal))
|
||||
LocalObject(1592, Terminal.Constructor(order_terminal))
|
||||
LocalObject(1593, Terminal.Constructor(order_terminal))
|
||||
|
|
@ -1514,6 +1542,8 @@ object Maps {
|
|||
ObjectToBuilding(1226, 49)
|
||||
ObjectToBuilding(1227, 49)
|
||||
ObjectToBuilding(1228, 49)
|
||||
ObjectToBuilding(1440, 49)
|
||||
ObjectToBuilding(1442, 49)
|
||||
ObjectToBuilding(1591, 49)
|
||||
ObjectToBuilding(1592, 49)
|
||||
ObjectToBuilding(1593, 49)
|
||||
|
|
@ -1529,6 +1559,8 @@ object Maps {
|
|||
DoorToLock(431, 907)
|
||||
DoorToLock(432, 902)
|
||||
DoorToLock(433, 903)
|
||||
TurretToWeapon(1440, 5008)
|
||||
TurretToWeapon(1442, 5009)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1615,10 +1647,6 @@ object Maps {
|
|||
Projectiles(this)
|
||||
}
|
||||
|
||||
val map12 = new ZoneMap("map12") {
|
||||
Projectiles(this)
|
||||
}
|
||||
|
||||
val map13 = new ZoneMap("map13") {
|
||||
Building1()
|
||||
Building2()
|
||||
|
|
@ -1766,6 +1794,8 @@ object Maps {
|
|||
LocalObject(557, IFFLock.Constructor)
|
||||
LocalObject(558, IFFLock.Constructor)
|
||||
LocalObject(559, IFFLock.Constructor)
|
||||
LocalObject(670, MannedTurret.Constructor(manned_turret))
|
||||
LocalObject(671, MannedTurret.Constructor(manned_turret))
|
||||
ObjectToBuilding(330, 29)
|
||||
ObjectToBuilding(331, 29)
|
||||
ObjectToBuilding(332, 29)
|
||||
|
|
@ -1774,10 +1804,14 @@ object Maps {
|
|||
ObjectToBuilding(557, 29)
|
||||
ObjectToBuilding(558, 29)
|
||||
ObjectToBuilding(559, 29)
|
||||
ObjectToBuilding(670, 29)
|
||||
ObjectToBuilding(671, 29)
|
||||
DoorToLock(330, 558)
|
||||
DoorToLock(331, 559)
|
||||
DoorToLock(332, 556)
|
||||
DoorToLock(333, 557)
|
||||
TurretToWeapon(670, 5000)
|
||||
TurretToWeapon(671, 5001)
|
||||
}
|
||||
|
||||
def Building42() : Unit = {
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ object PsLogin {
|
|||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.util.{Failure, Success}
|
||||
implicit val timeout = Timeout(500 milliseconds)
|
||||
implicit val timeout = Timeout(5 seconds)
|
||||
val requestVehicleEventBus : Future[ServiceManager.LookupResult] =
|
||||
(ServiceManager.serviceManager ask ServiceManager.Lookup("vehicle")).mapTo[ServiceManager.LookupResult]
|
||||
requestVehicleEventBus.onComplete {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import net.psforever.objects.serverobject.structures.{Building, StructureType, W
|
|||
import net.psforever.objects.serverobject.terminals._
|
||||
import net.psforever.objects.serverobject.terminals.Terminal.TerminalMessage
|
||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects.vehicles.{AccessPermissionGroup, Cargo, Utility, VehicleLockState}
|
||||
import net.psforever.objects.vehicles._
|
||||
import net.psforever.objects.zones.{InterstellarCluster, Zone}
|
||||
import net.psforever.packet.game.objectcreate._
|
||||
import net.psforever.types._
|
||||
|
|
@ -43,7 +43,7 @@ import services.{RemoverActor, _}
|
|||
import services.avatar.{AvatarAction, AvatarResponse, AvatarServiceMessage, AvatarServiceResponse}
|
||||
import services.galaxy.{GalaxyResponse, GalaxyServiceResponse}
|
||||
import services.local.{LocalAction, LocalResponse, LocalServiceMessage, LocalServiceResponse}
|
||||
import services.vehicle.VehicleAction.UnstowEquipment
|
||||
import services.vehicle.support.TurretUpgrader
|
||||
import services.vehicle.{VehicleAction, VehicleResponse, VehicleServiceMessage, VehicleServiceResponse}
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
|
@ -54,6 +54,7 @@ import scala.concurrent.duration._
|
|||
import scala.util.Success
|
||||
import akka.pattern.ask
|
||||
import net.psforever.objects.ballistics.{Projectile, ProjectileResolution}
|
||||
import net.psforever.objects.serverobject.turret.{MannedTurret, TurretUpgrade}
|
||||
|
||||
class WorldSessionActor extends Actor with MDCContextAware {
|
||||
import WorldSessionActor._
|
||||
|
|
@ -179,7 +180,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
* Vehicle cleanup that is specific to log out behavior.
|
||||
*/
|
||||
def DismountVehicleOnLogOut() : Unit = {
|
||||
//TODO Will base guns implement Vehicle type? Don't want those to deconstruct
|
||||
(player.VehicleSeated match {
|
||||
case Some(vehicle_guid) =>
|
||||
continent.GUID(vehicle_guid)
|
||||
|
|
@ -572,6 +572,11 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case VehicleResponse.DetachFromRails(vehicle_guid, pad_guid, pad_position, pad_orientation_z) =>
|
||||
sendResponse(ObjectDetachMessage(pad_guid, vehicle_guid, pad_position + Vector3(0,0,0.5f), pad_orientation_z))
|
||||
|
||||
case VehicleResponse.EquipmentInSlot(pkt) =>
|
||||
if(tplayer_guid != guid) {
|
||||
sendResponse(pkt)
|
||||
}
|
||||
|
||||
case VehicleResponse.InventoryState(obj, parent_guid, start, con_data) =>
|
||||
if(tplayer_guid != guid) {
|
||||
//TODO prefer ObjectDetachMessage, but how to force ammo pools to update properly?
|
||||
|
|
@ -764,20 +769,24 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case Mountable.MountMessages(tplayer, reply) =>
|
||||
reply match {
|
||||
case Mountable.CanMount(obj : ImplantTerminalMech, seat_num) =>
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
val obj_guid : PlanetSideGUID = obj.GUID
|
||||
log.info(s"MountVehicleMsg: $player_guid mounts $obj @ $seat_num")
|
||||
PlayerActionsToCancel()
|
||||
sendResponse(PlanetsideAttributeMessage(obj_guid, 0, 1000L)) //health of mech
|
||||
sendResponse(ObjectAttachMessage(obj_guid, player_guid, seat_num))
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.MountVehicle(player_guid, obj_guid, seat_num))
|
||||
MountingAction(tplayer, obj, seat_num)
|
||||
sendResponse(PlanetsideAttributeMessage(obj.GUID, 0, 1000L)) //health of mech
|
||||
|
||||
case Mountable.CanMount(obj : MannedTurret, seat_num) =>
|
||||
obj.WeaponControlledFromSeat(seat_num) match {
|
||||
case Some(weapon : Tool) =>
|
||||
//update mounted weapon belonging to seat
|
||||
weapon.AmmoSlots.foreach(slot => { //update the magazine(s) in the weapon, specifically
|
||||
val magazine = slot.Box
|
||||
sendResponse(InventoryStateMessage(magazine.GUID, weapon.GUID, magazine.Capacity.toLong))
|
||||
})
|
||||
case _ => ; //no weapons to update
|
||||
}
|
||||
sendResponse(PlanetsideAttributeMessage(obj.GUID, 0, obj.Health))
|
||||
MountingAction(tplayer, obj, seat_num)
|
||||
|
||||
case Mountable.CanMount(obj : Vehicle, seat_num) =>
|
||||
val obj_guid : PlanetSideGUID = obj.GUID
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
log.info(s"MountVehicleMsg: $player_guid mounts $obj_guid @ $seat_num")
|
||||
vehicleService ! VehicleServiceMessage.Decon(RemoverActor.ClearSpecific(List(obj), continent)) //clear timer
|
||||
PlayerActionsToCancel()
|
||||
if(seat_num == 0) { //simplistic vehicle ownership management
|
||||
obj.Owner match {
|
||||
case Some(owner_guid) =>
|
||||
|
|
@ -791,7 +800,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case None => ;
|
||||
}
|
||||
tplayer.VehicleOwned = Some(obj_guid)
|
||||
obj.Owner = Some(player_guid)
|
||||
obj.Owner = Some(tplayer.GUID)
|
||||
}
|
||||
obj.WeaponControlledFromSeat(seat_num) match {
|
||||
case Some(weapon : Tool) =>
|
||||
|
|
@ -802,29 +811,27 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
})
|
||||
case _ => ; //no weapons to update
|
||||
}
|
||||
sendResponse(ObjectAttachMessage(obj_guid, player_guid, seat_num))
|
||||
//sendResponse(PlanetsideAttributeMessage(obj.GUID, 0, obj.Health)) //TODO vehicle max health in definition
|
||||
vehicleService ! VehicleServiceMessage.Decon(RemoverActor.ClearSpecific(List(obj), continent)) //clear timer
|
||||
AccessContents(obj)
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.MountVehicle(player_guid, obj_guid, seat_num))
|
||||
MountingAction(tplayer, obj, seat_num)
|
||||
|
||||
case Mountable.CanMount(obj : Mountable, _) =>
|
||||
log.warn(s"MountVehicleMsg: $obj is some generic mountable object and nothing will happen")
|
||||
|
||||
case Mountable.CanDismount(obj : ImplantTerminalMech, seat_num) =>
|
||||
val obj_guid : PlanetSideGUID = obj.GUID
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
log.info(s"DismountVehicleMsg: $player_guid dismounts $obj @ $seat_num")
|
||||
sendResponse(DismountVehicleMsg(player_guid, BailType.Normal, false))
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.DismountVehicle(player_guid, BailType.Normal, false))
|
||||
DismountAction(tplayer, obj, seat_num)
|
||||
|
||||
case Mountable.CanDismount(obj : MannedTurret, seat_num) =>
|
||||
DismountAction(tplayer, obj, seat_num)
|
||||
|
||||
case Mountable.CanDismount(obj : Vehicle, seat_num) =>
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
if(player_guid == player.GUID) {
|
||||
//disembarking self
|
||||
log.info(s"DismountVehicleMsg: $player_guid dismounts $obj @ $seat_num")
|
||||
TotalDriverVehicleControl(obj)
|
||||
sendResponse(DismountVehicleMsg(player_guid, BailType.Normal, false))
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.DismountVehicle(player_guid, BailType.Normal, false))
|
||||
UnAccessContents(obj)
|
||||
DismountAction(tplayer, obj, seat_num)
|
||||
}
|
||||
else {
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.KickPassenger(player_guid, seat_num, true, obj.GUID))
|
||||
|
|
@ -1713,7 +1720,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
antDischargingTick.cancel()
|
||||
}
|
||||
|
||||
case ItemHacking(tplayer, target, tool_guid, delta, completeAction, tickAction) =>
|
||||
case HackingProgress(progressType, tplayer, target, tool_guid, delta, completeAction, tickAction) =>
|
||||
progressBarUpdate.cancel
|
||||
if(progressBarValue.isDefined) {
|
||||
val progressBarVal : Float = progressBarValue.get + delta
|
||||
|
|
@ -1726,10 +1733,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
else {
|
||||
HackState.Ongoing
|
||||
}
|
||||
sendResponse(HackMessage(1, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
|
||||
sendResponse(HackMessage(progressType, target.GUID, player.GUID, progressBarVal.toInt, 0L, vis, 8L))
|
||||
if(progressBarVal > 100) { //done
|
||||
progressBarValue = None
|
||||
log.info(s"Hacked a $target")
|
||||
// sendResponse(HackMessage(0, target.GUID, player.GUID, 100, 1114636288L, HackState.Hacked, 8L))
|
||||
completeAction()
|
||||
}
|
||||
|
|
@ -1737,7 +1743,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
tickAction.getOrElse(() => Unit)()
|
||||
progressBarValue = Some(progressBarVal)
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
progressBarUpdate = context.system.scheduler.scheduleOnce(250 milliseconds, self, ItemHacking(tplayer, target, tool_guid, delta, completeAction))
|
||||
progressBarUpdate = context.system.scheduler.scheduleOnce(250 milliseconds, self, HackingProgress(progressType, tplayer, target, tool_guid, delta, completeAction))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1803,6 +1809,11 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
avatar.Certifications += GalaxyGunship
|
||||
avatar.Certifications += Phantasm
|
||||
avatar.Certifications += UniMAX
|
||||
avatar.Certifications += Engineering
|
||||
avatar.Certifications += CombatEngineering
|
||||
avatar.Certifications += AdvancedEngineering
|
||||
avatar.Certifications += FortificationEngineering
|
||||
avatar.Certifications += AssaultEngineering
|
||||
AwardBattleExperiencePoints(avatar, 1000000L)
|
||||
player = new Player(avatar)
|
||||
//player.Position = Vector3(3561.0f, 2854.0f, 90.859375f) //home3, HART C
|
||||
|
|
@ -1812,9 +1823,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
//player.Orientation = Vector3(0f, 0f, 132.1875f)
|
||||
// player.ExoSuit = ExoSuitType.MAX //TODO strange issue; divide number above by 10 when uncommenting
|
||||
player.Slot(0).Equipment = SimpleItem(remote_electronics_kit) //Tool(GlobalDefinitions.StandardPistol(player.Faction))
|
||||
player.Slot(2).Equipment = Tool(mini_chaingun) //punisher //suppressor
|
||||
player.Slot(2).Equipment = Tool(nano_dispenser) //punisher //suppressor
|
||||
player.Slot(4).Equipment = Tool(GlobalDefinitions.StandardMelee(player.Faction))
|
||||
player.Slot(6).Equipment = AmmoBox(bullet_9mm, 20) //bullet_9mm
|
||||
player.Slot(6).Equipment = AmmoBox(upgrade_canister) //bullet_9mm
|
||||
player.Slot(9).Equipment = AmmoBox(rocket, 11) //bullet_9mm
|
||||
player.Slot(12).Equipment = AmmoBox(frag_cartridge) //bullet_9mm
|
||||
player.Slot(33).Equipment = AmmoBox(bullet_9mm_AP)
|
||||
|
|
@ -2056,6 +2067,45 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case _ => ;
|
||||
}
|
||||
})
|
||||
|
||||
//base turrets
|
||||
continent.Map.TurretToWeapon.foreach({ case((turret_guid, weapon_guid)) =>
|
||||
val parent_guid = PlanetSideGUID(turret_guid)
|
||||
continent.GUID(turret_guid) match {
|
||||
case Some(turret : MannedTurret) =>
|
||||
//attached weapon
|
||||
turret.ControlledWeapon(1) match {
|
||||
case Some(obj : Tool) =>
|
||||
val objDef = obj.Definition
|
||||
sendResponse(
|
||||
ObjectCreateMessage(
|
||||
objDef.ObjectId,
|
||||
obj.GUID,
|
||||
ObjectCreateMessageParent(parent_guid, 1),
|
||||
objDef.Packet.ConstructorData(obj).get
|
||||
)
|
||||
)
|
||||
case _ => ;
|
||||
}
|
||||
//reserved ammunition?
|
||||
//TODO need to register if it exists
|
||||
//seat turret occupant
|
||||
turret.Seats(0).Occupant match {
|
||||
case Some(tplayer) =>
|
||||
val tdefintion = tplayer.Definition
|
||||
sendResponse(
|
||||
ObjectCreateMessage(
|
||||
tdefintion.ObjectId,
|
||||
tplayer.GUID,
|
||||
ObjectCreateMessageParent(parent_guid, 0),
|
||||
tdefintion.Packet.ConstructorData(tplayer).get
|
||||
)
|
||||
)
|
||||
case None => ;
|
||||
}
|
||||
case _ => ;
|
||||
}
|
||||
})
|
||||
StopBundlingPackets()
|
||||
self ! SetCurrentAvatar(player)
|
||||
|
||||
|
|
@ -2079,33 +2129,22 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
|
||||
case msg @ ChildObjectStateMessage(object_guid, pitch, yaw) =>
|
||||
//the majority of the following check retrieves information to determine if we are in control of the child
|
||||
player.VehicleSeated match {
|
||||
case Some(vehicle_guid) =>
|
||||
continent.GUID(vehicle_guid) match {
|
||||
case Some(obj : Vehicle) =>
|
||||
obj.PassengerInSeat(player) match {
|
||||
case Some(seat_num) =>
|
||||
obj.WeaponControlledFromSeat(seat_num) match {
|
||||
case Some(tool) =>
|
||||
if(tool.GUID == object_guid) {
|
||||
//TODO set tool orientation?
|
||||
player.Orientation = Vector3(0f, pitch, yaw)
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.ChildObjectState(player.GUID, object_guid, pitch, yaw))
|
||||
}
|
||||
case None =>
|
||||
log.warn(s"ChildObjectState: player $player is not using stated controllable agent")
|
||||
}
|
||||
case None =>
|
||||
log.warn(s"ChildObjectState: player ${player.GUID} is not in a position to use controllable agent")
|
||||
}
|
||||
case _ =>
|
||||
log.warn(s"ChildObjectState: player $player's controllable agent not available in scope")
|
||||
FindContainedWeapon match {
|
||||
case (Some(_), Some(tool)) =>
|
||||
if(tool.GUID == object_guid) {
|
||||
//TODO set tool orientation?
|
||||
player.Orientation = Vector3(0f, pitch, yaw)
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.ChildObjectState(player.GUID, object_guid, pitch, yaw))
|
||||
}
|
||||
case None =>
|
||||
//TODO status condition of "playing getting out of vehicle to allow for late packets without warning
|
||||
//log.warn(s"ChildObjectState: player $player not related to anything with a controllable agent")
|
||||
else {
|
||||
log.warn(s"ChildObjectState: ${player.Name} is using a different controllable agent than #${object_guid.guid}")
|
||||
}
|
||||
case (Some(obj), None) =>
|
||||
log.warn(s"ChildObjectState: ${player.Name} can not find any controllable agent, let alone #${object_guid.guid}")
|
||||
case (None, _) => ;
|
||||
//TODO status condition of "playing getting out of vehicle to allow for late packets without warning
|
||||
//log.warn(s"ChildObjectState: player $player not related to anything with a controllable agent")
|
||||
}
|
||||
//log.info("ChildObjectState: " + msg)
|
||||
|
||||
case msg @ VehicleStateMessage(vehicle_guid, unk1, pos, ang, vel, unk5, unk6, unk7, wheels, unk9, unkA) =>
|
||||
continent.GUID(vehicle_guid) match {
|
||||
|
|
@ -2299,9 +2338,9 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
FindContainedWeapon match {
|
||||
case (Some(obj), Some(tool : Tool)) =>
|
||||
val originalAmmoType = tool.AmmoType
|
||||
val fullMagazine = tool.MaxMagazine
|
||||
do {
|
||||
val requestedAmmoType = tool.NextAmmoType
|
||||
val fullMagazine = tool.MaxMagazine
|
||||
if(requestedAmmoType != tool.AmmoSlot.Box.AmmoType) {
|
||||
FindEquipmentStock(obj, FindAmmoBoxThatUses(requestedAmmoType), fullMagazine, CountAmmunition).reverse match {
|
||||
case Nil => ;
|
||||
|
|
@ -2823,14 +2862,13 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
log.warn(s"Player ${player.GUID} - ${player.Faction} tried to refill silo ${resourceSilo.GUID} - ${resourceSilo.Faction} belonging to another empire")
|
||||
}
|
||||
|
||||
|
||||
case Some(panel : IFFLock) =>
|
||||
if(panel.Faction != player.Faction && panel.HackedBy.isEmpty) {
|
||||
player.Slot(player.DrawnSlot).Equipment match {
|
||||
case Some(tool : SimpleItem) =>
|
||||
if(tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||
self ! WorldSessionActor.ItemHacking(player, panel, tool.GUID, GetPlayerHackSpeed(), FinishHacking(panel, 1114636288L))
|
||||
self ! WorldSessionActor.HackingProgress(1, player, panel, tool.GUID, GetPlayerHackSpeed(), FinishHacking(panel, 1114636288L))
|
||||
log.info("Hacking a door~")
|
||||
}
|
||||
case _ => ;
|
||||
|
|
@ -2892,7 +2930,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case Some(tool: SimpleItem) =>
|
||||
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||
self ! WorldSessionActor.HackingProgress(1, player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||
log.info("Hacking a locker")
|
||||
}
|
||||
case _ => ;
|
||||
|
|
@ -2907,6 +2945,32 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
log.info(s"UseItem: not $player's locker")
|
||||
}
|
||||
|
||||
case Some(obj : MannedTurret) =>
|
||||
player.Slot(player.DrawnSlot).Equipment match {
|
||||
case Some(tool : Tool) =>
|
||||
if(tool.Definition == GlobalDefinitions.nano_dispenser && tool.Magazine > 0) {
|
||||
val ammo = tool.AmmoType
|
||||
if(ammo == Ammo.upgrade_canister && obj.Seats.values.count(_.isOccupied) == 0) {
|
||||
progressBarValue = Some(-1.25f)
|
||||
self ! WorldSessionActor.HackingProgress(
|
||||
2,
|
||||
player,
|
||||
obj,
|
||||
tool.GUID,
|
||||
1.25f,
|
||||
FinishUpgradingMannedTurret(obj, tool, TurretUpgrade(unk2.toInt))
|
||||
)
|
||||
}
|
||||
else if(ammo == Ammo.armor_canister && obj.Health < obj.MaxHealth) {
|
||||
//repair turret
|
||||
}
|
||||
}
|
||||
else if(tool.Definition == GlobalDefinitions.trek) {
|
||||
//infect turret with virus
|
||||
}
|
||||
case _ => ;
|
||||
}
|
||||
|
||||
case Some(obj : Vehicle) =>
|
||||
val equipment = player.Slot(player.DrawnSlot).Equipment
|
||||
if(player.Faction == obj.Faction) {
|
||||
|
|
@ -2969,7 +3033,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
case Some(tool: SimpleItem) =>
|
||||
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||
self ! WorldSessionActor.HackingProgress(1, player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||
log.info("Hacking a terminal")
|
||||
}
|
||||
case _ => ;
|
||||
|
|
@ -2979,7 +3043,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
// Otherwise allow the faction that owns the terminal to use it
|
||||
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, unk2, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case Some(obj : SpawnTube) =>
|
||||
|
|
@ -3853,7 +3916,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
}
|
||||
|
||||
/**
|
||||
* The process of hacking an object is completed
|
||||
* The process of hacking an object is completed.
|
||||
* Pass the message onto the hackable object and onto the local events system.
|
||||
* @param target the `Hackable` object that has been hacked
|
||||
* @param unk na;
|
||||
|
|
@ -3862,16 +3925,33 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
*/
|
||||
//TODO add params here depending on which params in HackMessage are important
|
||||
private def FinishHacking(target : PlanetSideServerObject with Hackable, unk : Long)() : Unit = {
|
||||
log.info(s"Hacked a $target")
|
||||
// Wait for the target actor to set the HackedBy property, otherwise LocalAction.HackTemporarily will not complete properly
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
ask(target.Actor, CommonMessages.Hack(player))(1 second).mapTo[Boolean].onComplete {
|
||||
case Success(_) =>
|
||||
localService ! LocalServiceMessage(continent.Id, LocalAction.TriggerSound(player.GUID, target.HackSound, player.Position, 30, 0.49803925f))
|
||||
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
||||
case scala.util.Failure(_) => log.warn(s"Hack message failed on target guid: ${target.GUID}")
|
||||
}
|
||||
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
||||
case scala.util.Failure(_) =>
|
||||
log.warn(s"Hack message failed on target guid: ${target.GUID}")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The process of upgrading a turret's weapon(s) is completed.
|
||||
* Pass the message onto the turret and onto the vehicle events system.
|
||||
* Additionally, force-deplete the ammunition count of the nano-dispenser used to perform the upgrade.
|
||||
* @param target the turret
|
||||
* @param tool the nano-dispenser that was used to perform this upgrade
|
||||
* @param upgrade the new upgrade state
|
||||
*/
|
||||
private def FinishUpgradingMannedTurret(target : MannedTurret, tool : Tool, upgrade : TurretUpgrade.Value)() : Unit = {
|
||||
log.info(s"Converting manned wall turret weapon to $upgrade")
|
||||
tool.Magazine = 0
|
||||
sendResponse(InventoryStateMessage(tool.AmmoSlot.Box.GUID, tool.GUID, 0))
|
||||
vehicleService ! VehicleServiceMessage.TurretUpgrade(TurretUpgrader.ClearSpecific(List(target), continent))
|
||||
vehicleService ! VehicleServiceMessage.TurretUpgrade(TurretUpgrader.AddTask(target, continent, upgrade))
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary function that iterates over vehicle permissions and turns them into `PlanetsideAttributeMessage` packets.<br>
|
||||
|
|
@ -3887,7 +3967,10 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
* Occasionally, during deployment, local(?) vehicle seat access permissions may change.
|
||||
* This results in players being locked into their own vehicle.
|
||||
* Reloading vehicle permissions supposedly ensures the seats will be properly available.
|
||||
* This is considered a client issue; but, somehow, it also impacts server operation somehow.
|
||||
* This is considered a client issue; but, somehow, it also impacts server operation somehow.<br>
|
||||
* <br>
|
||||
* 22 June 2018:<br>
|
||||
* I think vehicle ownership works properly now.
|
||||
* @param vehicle the `Vehicle`
|
||||
*/
|
||||
def ReloadVehicleAccessPermissions(vehicle : Vehicle) : Unit = {
|
||||
|
|
@ -4025,7 +4108,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
player.VehicleSeated match {
|
||||
case Some(vehicle_guid) => //weapon is vehicle turret?
|
||||
continent.GUID(vehicle_guid) match {
|
||||
case Some(vehicle : Vehicle) =>
|
||||
case Some(vehicle : Mountable with MountedWeapons with Container) =>
|
||||
vehicle.PassengerInSeat(player) match {
|
||||
case Some(seat_num) =>
|
||||
(Some(vehicle), vehicle.WeaponControlledFromSeat(seat_num))
|
||||
|
|
@ -5312,6 +5395,34 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common activities/procedure when a player mounts a valid object.
|
||||
* @param tplayer the player
|
||||
* @param obj the mountable object
|
||||
* @param seatNum the seat into which the player is mounting
|
||||
*/
|
||||
def MountingAction(tplayer : Player, obj : PlanetSideGameObject with Mountable, seatNum : Int) : Unit = {
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
val obj_guid : PlanetSideGUID = obj.GUID
|
||||
PlayerActionsToCancel()
|
||||
log.info(s"MountVehicleMsg: $player_guid mounts $obj @ $seatNum")
|
||||
sendResponse(ObjectAttachMessage(obj_guid, player_guid, seatNum))
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.MountVehicle(player_guid, obj_guid, seatNum))
|
||||
}
|
||||
|
||||
/**
|
||||
* Common activities/procedure when a player dismounts a valid object.
|
||||
* @param tplayer the player
|
||||
* @param obj the mountable object
|
||||
* @param seatNum the seat out of which which the player is disembarking
|
||||
*/
|
||||
def DismountAction(tplayer : Player, obj : PlanetSideGameObject with Mountable, seatNum : Int) : Unit = {
|
||||
val player_guid : PlanetSideGUID = tplayer.GUID
|
||||
log.info(s"DismountVehicleMsg: ${tplayer.Name} dismounts $obj from $seatNum")
|
||||
sendResponse(DismountVehicleMsg(player_guid, BailType.Normal, false))
|
||||
vehicleService ! VehicleServiceMessage(continent.Id, VehicleAction.DismountVehicle(player_guid, BailType.Normal, false))
|
||||
}
|
||||
|
||||
def failWithError(error : String) = {
|
||||
log.error(error)
|
||||
sendResponse(ConnectionClose())
|
||||
|
|
@ -5470,9 +5581,12 @@ object WorldSessionActor {
|
|||
|
||||
|
||||
/**
|
||||
* A message that indicates the user is using a remote electronics kit to hack some server object.
|
||||
* A message that indicates the user is using a remote electronics kit to hack some server object.<br>
|
||||
* <br>
|
||||
* Each time this message is sent for a given hack attempt counts as a single "tick" of progress.
|
||||
* The process of "making progress" with a hack involves sending this message repeatedly until the progress is 100 or more.
|
||||
* To calculate the actual amount of change in the progress `delta`,
|
||||
* start with 100, divide by the length of time in seconds, then divide once more by 4.
|
||||
* @param tplayer the player
|
||||
* @param target the object being hacked
|
||||
* @param tool_guid the REK
|
||||
|
|
@ -5480,12 +5594,13 @@ object WorldSessionActor {
|
|||
* @param completeAction a custom action performed once the hack is completed
|
||||
* @param tickAction an optional action is is performed for each tick of progress
|
||||
*/
|
||||
private final case class ItemHacking(tplayer : Player,
|
||||
target : PlanetSideServerObject,
|
||||
tool_guid : PlanetSideGUID,
|
||||
delta : Float,
|
||||
completeAction : () => Unit,
|
||||
tickAction : Option[() => Unit] = None)
|
||||
private final case class HackingProgress(progressType : Int,
|
||||
tplayer : Player,
|
||||
target : PlanetSideServerObject,
|
||||
tool_guid : PlanetSideGUID,
|
||||
delta : Float,
|
||||
completeAction : () => Unit,
|
||||
tickAction : Option[() => Unit] = None)
|
||||
|
||||
private final case class NtuCharging(tplayer: Player,
|
||||
vehicle: Vehicle)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import akka.actor.{ActorRef, ActorSystem, MDCContextAware}
|
||||
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
|
||||
import com.typesafe.config.{ConfigFactory, ConfigValueFactory}
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import net.psforever.packet.{ControlPacket, GamePacket}
|
||||
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
|
||||
import org.specs2.specification.Scope
|
||||
|
|
@ -39,7 +39,7 @@ object ActorTest {
|
|||
Normally inaccessible from the outside, the payload is unwrapped within the standard receive PartialFunction.
|
||||
By interacting with a TestProbe constructor param, information that would be concealed by MdcMsg can be polled.
|
||||
|
||||
The l-neighbor of the MDCContextAware is the system of the ActorTest TestKit.
|
||||
The l-neighbor of the MDCContextAware is the system of the base.ActorTest TestKit.
|
||||
The r-neighbor of the MDCContextAware is this MDCTestProbe and, indirectly, the TestProbe that was interjected.
|
||||
Pass l-input into the MDCContextAware itself.
|
||||
The r-output is a normal message that can be polled on that TestProbe.
|
||||
|
|
|
|||
|
|
@ -1,541 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import akka.actor.Props
|
||||
import akka.routing.RandomPool
|
||||
import net.psforever.objects._
|
||||
import net.psforever.objects.guid.{GUIDTask, TaskResolver}
|
||||
import net.psforever.objects.zones.{Zone, ZoneActor, ZoneMap}
|
||||
import net.psforever.packet.game.objectcreate.{DroppedItemData, ObjectClass, ObjectCreateMessageParent, PlacementData}
|
||||
import net.psforever.packet.game.{ObjectCreateMessage, PlanetSideGUID, PlayerStateMessageUpstream}
|
||||
import net.psforever.types._
|
||||
import services.{RemoverActor, Service, ServiceManager}
|
||||
import services.avatar._
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class AvatarService1Test extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"construct" in {
|
||||
ServiceManager.boot(system)
|
||||
system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarService2Test extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"subscribe" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarService3Test extends ActorTest {
|
||||
"AvatarService" should {
|
||||
ServiceManager.boot(system)
|
||||
"subscribe to a specific channel" in {
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! Service.Leave()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarService4Test extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"subscribe" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! Service.LeaveAll()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarService5Test extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass an unhandled message" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! "hello"
|
||||
expectNoMsg()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ArmorChangedTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ArmorChanged" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ArmorChanged(PlanetSideGUID(10), ExoSuitType.Reinforced, 0))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ArmorChanged(ExoSuitType.Reinforced, 0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ConcealPlayerTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ConcealPlayer" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ConcealPlayer(PlanetSideGUID(10)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ConcealPlayer()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class EquipmentInHandTest extends ActorTest {
|
||||
ServiceManager.boot(system) ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
||||
val service = system.actorOf(Props[AvatarService], "release-test-service")
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0)
|
||||
val taskResolver = system.actorOf(Props[TaskResolver], "release-test-resolver")
|
||||
|
||||
val toolDef = GlobalDefinitions.beamer
|
||||
val tool = Tool(toolDef)
|
||||
tool.GUID = PlanetSideGUID(40)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(41)
|
||||
val pkt = ObjectCreateMessage(
|
||||
toolDef.ObjectId,
|
||||
tool.GUID,
|
||||
ObjectCreateMessageParent(PlanetSideGUID(11), 2),
|
||||
toolDef.Packet.ConstructorData(tool).get
|
||||
)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass EquipmentInHand" in {
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.EquipmentInHand(PlanetSideGUID(10), PlanetSideGUID(11), 2, tool))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.EquipmentInHand(pkt)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DroptItemTest extends ActorTest {
|
||||
ServiceManager.boot(system) ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
||||
val service = system.actorOf(Props[AvatarService], "release-test-service")
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0)
|
||||
val taskResolver = system.actorOf(Props[TaskResolver], "drop-item-test-resolver")
|
||||
zone.Actor = system.actorOf(Props(classOf[ZoneActor], zone), "drop-item-test-zone")
|
||||
zone.Actor ! Zone.Init()
|
||||
|
||||
val toolDef = GlobalDefinitions.beamer
|
||||
val tool = Tool(toolDef)
|
||||
tool.Position = Vector3(1,2,3)
|
||||
tool.Orientation = Vector3(4,5,6)
|
||||
tool.GUID = PlanetSideGUID(40)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(41)
|
||||
val pkt = ObjectCreateMessage(
|
||||
toolDef.ObjectId,
|
||||
tool.GUID,
|
||||
DroppedItemData(
|
||||
PlacementData(tool.Position, tool.Orientation),
|
||||
toolDef.Packet.ConstructorData(tool).get
|
||||
)
|
||||
)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass DropItem" in {
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.DropItem(PlanetSideGUID(10), tool, zone))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.DropItem(pkt)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LoadPlayerTest extends ActorTest {
|
||||
val obj = Player(Avatar("TestCharacter1", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
obj.GUID = PlanetSideGUID(10)
|
||||
obj.Slot(5).Equipment.get.GUID = PlanetSideGUID(11)
|
||||
val c1data = obj.Definition.Packet.DetailedConstructorData(obj).get
|
||||
val pkt1 = ObjectCreateMessage(ObjectClass.avatar, PlanetSideGUID(10), c1data)
|
||||
val parent = ObjectCreateMessageParent(PlanetSideGUID(12), 0)
|
||||
obj.VehicleSeated = PlanetSideGUID(12)
|
||||
val c2data = obj.Definition.Packet.DetailedConstructorData(obj).get
|
||||
val pkt2 = ObjectCreateMessage(ObjectClass.avatar, PlanetSideGUID(10), parent, c2data)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass LoadPlayer" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
//no parent data
|
||||
service ! AvatarServiceMessage("test", AvatarAction.LoadPlayer(
|
||||
PlanetSideGUID(20), ObjectClass.avatar, PlanetSideGUID(10), c1data, None)
|
||||
)
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(20), AvatarResponse.LoadPlayer(pkt1)))
|
||||
//parent data
|
||||
service ! AvatarServiceMessage("test", AvatarAction.LoadPlayer(
|
||||
PlanetSideGUID(20), ObjectClass.avatar, PlanetSideGUID(10), c2data, Some(parent))
|
||||
)
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(20), AvatarResponse.LoadPlayer(pkt2)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectDeleteTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ObjectDelete" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ObjectDelete(PlanetSideGUID(10), PlanetSideGUID(11)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ObjectDelete(PlanetSideGUID(11), 0)))
|
||||
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ObjectDelete(PlanetSideGUID(10), PlanetSideGUID(11), 55))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ObjectDelete(PlanetSideGUID(11), 55)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectHeldTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ObjectHeld" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ObjectHeld(PlanetSideGUID(10), 1))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ObjectHeld(1)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlanetsideAttributeTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass PlanetsideAttribute" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.PlanetsideAttribute(PlanetSideGUID(10), 5, 1200L))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.PlanetsideAttribute(5, 1200L)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerStateTest extends ActorTest {
|
||||
val msg = PlayerStateMessageUpstream(PlanetSideGUID(75), Vector3(3694.1094f, 2735.4531f, 90.84375f), Some(Vector3(4.375f, 2.59375f, 0.0f)), 61.875f, 351.5625f, 0.0f, 136, 0, false, false, false, false, 112, 0)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass PlayerState" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.PlayerState(PlanetSideGUID(10), msg, false, false))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.PlayerState(msg, false, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PickupItemATest extends ActorTest {
|
||||
val obj = Player(Avatar("TestCharacter", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
obj.GUID = PlanetSideGUID(10)
|
||||
obj.Slot(5).Equipment.get.GUID = PlanetSideGUID(11)
|
||||
|
||||
val toolDef = GlobalDefinitions.beamer
|
||||
val tool = Tool(toolDef)
|
||||
tool.GUID = PlanetSideGUID(40)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(41)
|
||||
val pkt = ObjectCreateMessage(
|
||||
toolDef.ObjectId,
|
||||
tool.GUID,
|
||||
ObjectCreateMessageParent(PlanetSideGUID(10), 0),
|
||||
toolDef.Packet.ConstructorData(tool).get
|
||||
)
|
||||
|
||||
"pass PickUpItem as EquipmentInHand (visible pistol slot)" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.PickupItem(PlanetSideGUID(10), Zone.Nowhere, obj, 0, tool))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.EquipmentInHand(pkt)))
|
||||
}
|
||||
}
|
||||
|
||||
class PickupItemBTest extends ActorTest {
|
||||
val obj = Player(Avatar("TestCharacter", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
val tool = Tool(GlobalDefinitions.beamer)
|
||||
tool.GUID = PlanetSideGUID(40)
|
||||
|
||||
"pass PickUpItem as ObjectDelete (not visible inventory space)" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.PickupItem(PlanetSideGUID(10), Zone.Nowhere, obj, 6, tool))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ObjectDelete(tool.GUID, 0)))
|
||||
}
|
||||
}
|
||||
|
||||
class ReloadTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass Reload" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.Reload(PlanetSideGUID(10), PlanetSideGUID(40)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.Reload(PlanetSideGUID(40))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeAmmoTest extends ActorTest {
|
||||
val ammoDef = GlobalDefinitions.energy_cell
|
||||
val ammoBox = AmmoBox(ammoDef)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass ChangeAmmo" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ChangeAmmo(PlanetSideGUID(10), PlanetSideGUID(40), 0, PlanetSideGUID(40), ammoDef.ObjectId, PlanetSideGUID(41), ammoDef.Packet.ConstructorData(ammoBox).get))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ChangeAmmo(PlanetSideGUID(40), 0, PlanetSideGUID(40), ammoDef.ObjectId, PlanetSideGUID(41), ammoDef.Packet.ConstructorData(ammoBox).get)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeFireModeTest extends ActorTest {
|
||||
val ammoDef = GlobalDefinitions.energy_cell
|
||||
val ammoBox = AmmoBox(ammoDef)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass ChangeFireMode" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ChangeFireMode(PlanetSideGUID(10), PlanetSideGUID(40), 0))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ChangeFireMode(PlanetSideGUID(40), 0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeFireStateStartTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ChangeFireState_Start" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ChangeFireState_Start(PlanetSideGUID(10), PlanetSideGUID(40)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ChangeFireState_Start(PlanetSideGUID(40))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeFireStateStopTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass ChangeFireState_Stop" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.ChangeFireState_Stop(PlanetSideGUID(10), PlanetSideGUID(40)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.ChangeFireState_Stop(PlanetSideGUID(40))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WeaponDryFireTest extends ActorTest {
|
||||
"AvatarService" should {
|
||||
"pass WeaponDryFire" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.WeaponDryFire(PlanetSideGUID(10), PlanetSideGUID(40)))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.WeaponDryFire(PlanetSideGUID(40))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarStowEquipmentTest extends ActorTest {
|
||||
val tool = Tool(GlobalDefinitions.beamer)
|
||||
|
||||
"AvatarService" should {
|
||||
"pass StowEquipment" in {
|
||||
ServiceManager.boot(system)
|
||||
val service = system.actorOf(Props[AvatarService], AvatarServiceTest.TestName)
|
||||
service ! Service.Join("test")
|
||||
service ! AvatarServiceMessage("test", AvatarAction.StowEquipment(PlanetSideGUID(10), PlanetSideGUID(11), 2, tool))
|
||||
expectMsg(AvatarServiceResponse("/test/Avatar", PlanetSideGUID(10), AvatarResponse.StowEquipment(PlanetSideGUID(11), 2, tool)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Preparation for these three Release tests is involved.
|
||||
The ServiceManager must not only be set up correctly, but must be given a TaskResolver.
|
||||
The AvatarService is started and that starts CorpseRemovalActor, an essential part of this test.
|
||||
The CorpseRemovalActor needs that TaskResolver created by the ServiceManager;
|
||||
but, another independent TaskResolver will be needed for manual parts of the test.
|
||||
(The ServiceManager's TaskResolver can be "borrowed" but that requires writing code to intercept it.)
|
||||
The Zone needs to be set up and initialized properly with a ZoneActor.
|
||||
The ZoneActor builds the GUID Actor and the ZonePopulationActor.
|
||||
|
||||
ALL of these Actors will talk to each other.
|
||||
The lines of communication can short circuit if the next Actor does not have the correct information.
|
||||
Putting Actor startup in the main class, outside of the body of the test, helps.
|
||||
Frequent pauses to allow everything to sort their messages also helps.
|
||||
Even with all this work, the tests have a high chance of failure just due to being asynchronous.
|
||||
*/
|
||||
class AvatarReleaseTest extends ActorTest {
|
||||
ServiceManager.boot(system) ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
||||
val service = system.actorOf(Props[AvatarService], "release-test-service")
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = { AddPool("dynamic", 1 to 10) } }
|
||||
val taskResolver = system.actorOf(Props[TaskResolver], "release-test-resolver")
|
||||
zone.Actor = system.actorOf(Props(classOf[ZoneActor], zone), "release-test-zone")
|
||||
zone.Actor ! Zone.Init()
|
||||
val obj = Player(Avatar("TestCharacter", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
obj.Continent = "test"
|
||||
obj.Release
|
||||
|
||||
"AvatarService" should {
|
||||
"pass Release" in {
|
||||
expectNoMsg(100 milliseconds) //spacer
|
||||
|
||||
service ! Service.Join("test")
|
||||
taskResolver ! GUIDTask.RegisterObjectTask(obj)(zone.GUID)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
zone.Population ! Zone.Corpse.Add(obj)
|
||||
expectNoMsg(200 milliseconds) //spacer
|
||||
|
||||
assert(zone.Corpses.size == 1)
|
||||
assert(obj.HasGUID)
|
||||
val guid = obj.GUID
|
||||
service ! AvatarServiceMessage("test", AvatarAction.Release(obj, zone, Some(1 second))) //alive for one second
|
||||
|
||||
val reply1 = receiveOne(200 milliseconds)
|
||||
assert(reply1.isInstanceOf[AvatarServiceResponse])
|
||||
val reply1msg = reply1.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply1msg.toChannel == "/test/Avatar")
|
||||
assert(reply1msg.avatar_guid == guid)
|
||||
assert(reply1msg.replyMessage.isInstanceOf[AvatarResponse.Release])
|
||||
assert(reply1msg.replyMessage.asInstanceOf[AvatarResponse.Release].player == obj)
|
||||
|
||||
val reply2 = receiveOne(2 seconds)
|
||||
assert(reply2.isInstanceOf[AvatarServiceResponse])
|
||||
val reply2msg = reply2.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply2msg.toChannel.equals("/test/Avatar"))
|
||||
assert(reply2msg.avatar_guid == Service.defaultPlayerGUID)
|
||||
assert(reply2msg.replyMessage.isInstanceOf[AvatarResponse.ObjectDelete])
|
||||
assert(reply2msg.replyMessage.asInstanceOf[AvatarResponse.ObjectDelete].item_guid == guid)
|
||||
|
||||
expectNoMsg(1 seconds)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
assert(!obj.HasGUID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarReleaseEarly1Test extends ActorTest {
|
||||
ServiceManager.boot(system) ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
||||
val service = system.actorOf(Props[AvatarService], "release-test-service")
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = { AddPool("dynamic", 1 to 10) } }
|
||||
val taskResolver = system.actorOf(Props[TaskResolver], "release-test-resolver")
|
||||
zone.Actor = system.actorOf(Props(classOf[ZoneActor], zone), "release-test-zone")
|
||||
zone.Actor ! Zone.Init()
|
||||
val obj = Player(Avatar("TestCharacter1", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
obj.Continent = "test"
|
||||
obj.Release
|
||||
|
||||
"AvatarService" should {
|
||||
"pass Release" in {
|
||||
expectNoMsg(100 milliseconds) //spacer
|
||||
|
||||
service ! Service.Join("test")
|
||||
taskResolver ! GUIDTask.RegisterObjectTask(obj)(zone.GUID)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
zone.Population ! Zone.Corpse.Add(obj)
|
||||
expectNoMsg(200 milliseconds) //spacer
|
||||
|
||||
assert(zone.Corpses.size == 1)
|
||||
assert(obj.HasGUID)
|
||||
val guid = obj.GUID
|
||||
service ! AvatarServiceMessage("test", AvatarAction.Release(obj, zone)) //3+ minutes!
|
||||
|
||||
val reply1 = receiveOne(200 milliseconds)
|
||||
assert(reply1.isInstanceOf[AvatarServiceResponse])
|
||||
val reply1msg = reply1.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply1msg.toChannel == "/test/Avatar")
|
||||
assert(reply1msg.avatar_guid == guid)
|
||||
assert(reply1msg.replyMessage.isInstanceOf[AvatarResponse.Release])
|
||||
assert(reply1msg.replyMessage.asInstanceOf[AvatarResponse.Release].player == obj)
|
||||
|
||||
service ! AvatarServiceMessage.Corpse(RemoverActor.HurrySpecific(List(obj), zone)) //IMPORTANT: ONE ENTRY
|
||||
val reply2 = receiveOne(200 milliseconds)
|
||||
assert(reply2.isInstanceOf[AvatarServiceResponse])
|
||||
val reply2msg = reply2.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply2msg.toChannel.equals("/test/Avatar"))
|
||||
assert(reply2msg.avatar_guid == Service.defaultPlayerGUID)
|
||||
assert(reply2msg.replyMessage.isInstanceOf[AvatarResponse.ObjectDelete])
|
||||
assert(reply2msg.replyMessage.asInstanceOf[AvatarResponse.ObjectDelete].item_guid == guid)
|
||||
|
||||
expectNoMsg(1 seconds)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
assert(!obj.HasGUID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarReleaseEarly2Test extends ActorTest {
|
||||
ServiceManager.boot(system) ! ServiceManager.Register(RandomPool(1).props(Props[TaskResolver]), "taskResolver")
|
||||
val service = system.actorOf(Props[AvatarService], "release-test-service")
|
||||
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = { AddPool("dynamic", 1 to 10) } }
|
||||
val taskResolver = system.actorOf(Props[TaskResolver], "release-test-resolver")
|
||||
zone.Actor = system.actorOf(Props(classOf[ZoneActor], zone), "release-test-zone")
|
||||
zone.Actor ! Zone.Init()
|
||||
val objAlt = Player(Avatar("TestCharacter2", PlanetSideEmpire.NC, CharacterGender.Male, 1, CharacterVoice.Voice1)) //necessary clutter
|
||||
val obj = Player(Avatar("TestCharacter1", PlanetSideEmpire.VS, CharacterGender.Female, 1, CharacterVoice.Voice1))
|
||||
obj.Continent = "test"
|
||||
obj.Release
|
||||
|
||||
"AvatarService" should {
|
||||
"pass Release" in {
|
||||
expectNoMsg(100 milliseconds) //spacer
|
||||
|
||||
service ! Service.Join("test")
|
||||
taskResolver ! GUIDTask.RegisterObjectTask(obj)(zone.GUID)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
zone.Population ! Zone.Corpse.Add(obj)
|
||||
expectNoMsg(200 milliseconds) //spacer
|
||||
|
||||
assert(zone.Corpses.size == 1)
|
||||
assert(obj.HasGUID)
|
||||
val guid = obj.GUID
|
||||
service ! AvatarServiceMessage("test", AvatarAction.Release(obj, zone)) //3+ minutes!
|
||||
|
||||
val reply1 = receiveOne(200 milliseconds)
|
||||
assert(reply1.isInstanceOf[AvatarServiceResponse])
|
||||
val reply1msg = reply1.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply1msg.toChannel == "/test/Avatar")
|
||||
assert(reply1msg.avatar_guid == guid)
|
||||
assert(reply1msg.replyMessage.isInstanceOf[AvatarResponse.Release])
|
||||
assert(reply1msg.replyMessage.asInstanceOf[AvatarResponse.Release].player == obj)
|
||||
|
||||
service ! AvatarServiceMessage.Corpse(RemoverActor.HurrySpecific(List(objAlt, obj), zone)) //IMPORTANT: TWO ENTRIES
|
||||
val reply2 = receiveOne(100 milliseconds)
|
||||
assert(reply2.isInstanceOf[AvatarServiceResponse])
|
||||
val reply2msg = reply2.asInstanceOf[AvatarServiceResponse]
|
||||
assert(reply2msg.toChannel.equals("/test/Avatar"))
|
||||
assert(reply2msg.avatar_guid == Service.defaultPlayerGUID)
|
||||
assert(reply2msg.replyMessage.isInstanceOf[AvatarResponse.ObjectDelete])
|
||||
assert(reply2msg.replyMessage.asInstanceOf[AvatarResponse.ObjectDelete].item_guid == guid)
|
||||
|
||||
expectNoMsg(1 seconds)
|
||||
assert(zone.Corpses.isEmpty)
|
||||
assert(!obj.HasGUID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object AvatarServiceTest {
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
private val number = new AtomicInteger(1)
|
||||
|
||||
def TestName : String = {
|
||||
s"service${number.getAndIncrement()}"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import services.Service
|
||||
import services.local._
|
||||
|
||||
class LocalService1Test extends ActorTest {
|
||||
"LocalService" should {
|
||||
"construct" in {
|
||||
system.actorOf(Props[LocalService], "service")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LocalService2Test extends ActorTest {
|
||||
"LocalService" should {
|
||||
"subscribe" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LocalService3Test extends ActorTest {
|
||||
"LocalService" should {
|
||||
"subscribe to a specific channel" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! Service.Leave()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LocalService4Test extends ActorTest {
|
||||
"LocalService" should {
|
||||
"subscribe" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! Service.LeaveAll()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LocalService5Test extends ActorTest {
|
||||
"LocalService" should {
|
||||
"pass an unhandled message" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! "hello"
|
||||
expectNoMsg()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DoorClosesTest extends ActorTest {
|
||||
"LocalService" should {
|
||||
"pass DoorCloses" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! LocalServiceMessage("test", LocalAction.DoorCloses(PlanetSideGUID(10), PlanetSideGUID(40)))
|
||||
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.DoorCloses(PlanetSideGUID(40))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HackClearTest extends ActorTest {
|
||||
val obj = new PlanetSideServerObject() {
|
||||
def Faction = PlanetSideEmpire.NEUTRAL
|
||||
def Definition = null
|
||||
GUID = PlanetSideGUID(40)
|
||||
}
|
||||
|
||||
"LocalService" should {
|
||||
"pass HackClear" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! LocalServiceMessage("test", LocalAction.HackClear(PlanetSideGUID(10), obj, 0L, 1000L))
|
||||
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.HackClear(PlanetSideGUID(40), 0L, 1000L)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProximityTerminalEffectTest extends ActorTest {
|
||||
"LocalService" should {
|
||||
"pass ProximityTerminalEffect" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! LocalServiceMessage("test", LocalAction.ProximityTerminalEffect(PlanetSideGUID(10), PlanetSideGUID(40), true))
|
||||
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.ProximityTerminalEffect(PlanetSideGUID(40), true)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TriggerSoundTest extends ActorTest {
|
||||
import net.psforever.packet.game.TriggeredSound
|
||||
|
||||
"LocalService" should {
|
||||
"pass TriggerSound" in {
|
||||
val service = system.actorOf(Props[LocalService], "service")
|
||||
service ! Service.Join("test")
|
||||
service ! LocalServiceMessage("test", LocalAction.TriggerSound(PlanetSideGUID(10), TriggeredSound.LockedOut, Vector3(1.1f, 2.2f, 3.3f), 0, 0.75f))
|
||||
expectMsg(LocalServiceResponse("/test/Local", PlanetSideGUID(10), LocalResponse.TriggerSound(TriggeredSound.LockedOut, Vector3(1.1f, 2.2f, 3.3f), 0, 0.75f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object LocalServiceTest {
|
||||
//decoy
|
||||
}
|
||||
|
|
@ -1,537 +0,0 @@
|
|||
//// Copyright (c) 2017 PSForever
|
||||
//import akka.actor.{ActorRef, Props}
|
||||
//import akka.routing.RandomPool
|
||||
//import akka.testkit.TestProbe
|
||||
//import net.psforever.objects.PlanetSideGameObject
|
||||
//import net.psforever.objects.definition.{EquipmentDefinition, ObjectDefinition}
|
||||
//import net.psforever.objects.equipment.Equipment
|
||||
//import net.psforever.objects.guid.TaskResolver
|
||||
//import net.psforever.objects.zones.{Zone, ZoneMap}
|
||||
//import net.psforever.packet.game.PlanetSideGUID
|
||||
//import services.{RemoverActor, ServiceManager}
|
||||
//
|
||||
//import scala.concurrent.duration._
|
||||
//
|
||||
//class StandardRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "handle a simple task" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere)
|
||||
//
|
||||
// val reply1 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
|
||||
// val reply2 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply2.isInstanceOf[RemoverActorTest.InitialJobAlert])
|
||||
// probe.expectNoMsg(1 seconds) //delay
|
||||
// val reply3 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class DelayedRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "handle a simple task (timed)" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(100 milliseconds))
|
||||
//
|
||||
// val reply1 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
|
||||
// val reply2 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply2.isInstanceOf[RemoverActorTest.InitialJobAlert])
|
||||
// //no delay
|
||||
// val reply3 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class ExcludedRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// val AlternateTestObject = new PlanetSideGameObject() { def Definition = new ObjectDefinition(0) { } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "allow only specific objects" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(AlternateTestObject, Zone.Nowhere)
|
||||
//
|
||||
// val reply1 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
|
||||
// expectNoMsg(2 seconds)
|
||||
// //RemoverActor is stalled because it received an object that it was not allowed to act upon
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class MultipleRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "work on parallel tasks" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere)
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere)
|
||||
//
|
||||
// val replies = probe.receiveN(14, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// var fja : Int = 0
|
||||
// var cta : Int = 0
|
||||
// var sja : Int = 0
|
||||
// var dta : Int = 0
|
||||
// var dtr : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case RemoverActorTest.FirstJobAlert() => fja += 1
|
||||
// case RemoverActorTest.ClearanceTestAlert() => cta += 1
|
||||
// case RemoverActorTest.SecondJobAlert() => sja += 1
|
||||
// case RemoverActorTest.DeletionTaskAlert() => dta += 1
|
||||
// case RemoverActorTest.DeletionTaskRunAlert() => dtr += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2 && fja == 2 && cta == 2 && sja == 2 && dta == 2 && dtr == 2)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class HurrySpecificRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry certain tasks" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(10 minutes)) //TEN MINUTE WAIT
|
||||
//
|
||||
// val reply1 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply1.isInstanceOf[RemoverActorTest.InclusionTestAlert])
|
||||
// val reply2 = probe.receiveOne(200 milliseconds)
|
||||
// assert(reply2.isInstanceOf[RemoverActorTest.InitialJobAlert])
|
||||
// probe.expectNoMsg(3 seconds) //long delay, longer than standard but not yet 10 minutes
|
||||
// remover ! RemoverActor.HurrySpecific(List(RemoverActorTest.TestObject), Zone.Nowhere) //hurried
|
||||
// val reply3 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class HurrySelectionRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry certain tasks, but let others finish normally" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(10 seconds))
|
||||
//
|
||||
// val replies = probe.receiveN(4, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2)
|
||||
// probe.expectNoMsg(3 seconds) //long delay, longer than standard but not yet 5 seconds
|
||||
// remover ! RemoverActor.HurrySpecific(List(RemoverActorTest.TestObject), Zone.Nowhere) //hurried
|
||||
// //first
|
||||
// val reply3a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3a.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4a.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5a.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6a = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6a.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7a = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7a.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// //second
|
||||
// remover ! RemoverActor.HurrySpecific(List(TestObject2), Zone.Nowhere) //hurried
|
||||
// val reply3b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3b.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4b.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5b.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6b.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7b.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class HurryMultipleRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
// final val TestObject3 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(3) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry certain tasks, but only valid ones" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(5 seconds))
|
||||
//
|
||||
// val replies = probe.receiveN(4, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2)
|
||||
// probe.expectNoMsg(3 seconds) //long delay, longer than standard but not yet 5 seconds
|
||||
// remover ! RemoverActor.HurrySpecific(List(RemoverActorTest.TestObject, TestObject3), Zone.Nowhere) //multiple hurried, only one valid
|
||||
// //first
|
||||
// val reply3a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3a.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4a.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5a = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5a.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6a = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6a.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7a = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7a.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// //second
|
||||
// remover ! RemoverActor.HurrySpecific(List(TestObject2), Zone.Nowhere) //hurried
|
||||
// val reply3b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3b.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4b.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5b.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6b.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7b.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class HurryByZoneRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
// final val TestObject3 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(3) } }
|
||||
// final val zone = new Zone("test", new ZoneMap("test-map"), 11)
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry certain tasks by their zone" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, zone, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject3, Zone.Nowhere, Some(5 seconds))
|
||||
//
|
||||
// val replies1 = probe.receiveN(6, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies1.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 3 && ija == 3)
|
||||
// probe.expectNoMsg(3 seconds) //long delay, longer than standard but not yet 5 seconds
|
||||
// remover ! RemoverActor.HurrySpecific(List(), Zone.Nowhere) //multiple hurried, only the two entries with Zone.Nowhere
|
||||
// //
|
||||
// val replies2 = probe.receiveN(10, 5 seconds)
|
||||
// var fja : Int = 0
|
||||
// var cta : Int = 0
|
||||
// var sja : Int = 0
|
||||
// var dta : Int = 0
|
||||
// var dtr : Int = 0
|
||||
// replies2.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case RemoverActorTest.FirstJobAlert() => fja += 1
|
||||
// case RemoverActorTest.ClearanceTestAlert() => cta += 1
|
||||
// case RemoverActorTest.SecondJobAlert() => sja += 1
|
||||
// case RemoverActorTest.DeletionTaskAlert() => dta += 1
|
||||
// case RemoverActorTest.DeletionTaskRunAlert() => dtr += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(fja == 2 && cta == 2 && sja == 2 && dta == 2 && dtr == 2)
|
||||
// //final
|
||||
// remover ! RemoverActor.HurrySpecific(List(), zone) //hurried
|
||||
// val reply3b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply3b.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4b.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5b = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5b.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6b.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7b = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7b.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class HurryAllRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
// final val TestObject3 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(3) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry all tasks to completion" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(20 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(15 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject3, Zone.Nowhere, Some(10 seconds))
|
||||
//
|
||||
// val replies1 = probe.receiveN(6, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies1.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 3 && ija == 3)
|
||||
// probe.expectNoMsg(3 seconds) //long delay, longer than standard but not yet longer than any of the tasks
|
||||
// remover ! RemoverActor.HurryAll() //all hurried
|
||||
// //
|
||||
// val replies2 = probe.receiveN(15, 5 seconds)
|
||||
// var fja : Int = 0
|
||||
// var cta : Int = 0
|
||||
// var sja : Int = 0
|
||||
// var dta : Int = 0
|
||||
// var dtr : Int = 0
|
||||
// replies2.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case RemoverActorTest.FirstJobAlert() => fja += 1
|
||||
// case RemoverActorTest.ClearanceTestAlert() => cta += 1
|
||||
// case RemoverActorTest.SecondJobAlert() => sja += 1
|
||||
// case RemoverActorTest.DeletionTaskAlert() => dta += 1
|
||||
// case RemoverActorTest.DeletionTaskRunAlert() => dtr += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(fja == 3 && cta == 3 && sja == 3 && dta == 3 && dtr == 3)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class ClearSelectionRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to clear certain tasks" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(5 seconds))
|
||||
//
|
||||
// val replies = probe.receiveN(4, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2)
|
||||
// probe.expectNoMsg(4 seconds) //long delay, longer than standard but not yet 5 seconds
|
||||
// remover ! RemoverActor.ClearSpecific(List(RemoverActorTest.TestObject), Zone.Nowhere) //cleared
|
||||
// //
|
||||
// val reply3 = probe.receiveOne(2 seconds)
|
||||
// assert(reply3.isInstanceOf[RemoverActorTest.FirstJobAlert])
|
||||
// val reply4 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply4.isInstanceOf[RemoverActorTest.ClearanceTestAlert])
|
||||
// val reply5 = probe.receiveOne(300 milliseconds)
|
||||
// assert(reply5.isInstanceOf[RemoverActorTest.SecondJobAlert])
|
||||
// val reply6 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply6.isInstanceOf[RemoverActorTest.DeletionTaskAlert])
|
||||
// val reply7 = probe.receiveOne(500 milliseconds)
|
||||
// assert(reply7.isInstanceOf[RemoverActorTest.DeletionTaskRunAlert])
|
||||
// //wait
|
||||
// probe.expectNoMsg(2 seconds) //nothing more to do
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class ClearAllRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to clear all tasks, with no more work on them" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(5 seconds))
|
||||
//
|
||||
// val replies = probe.receiveN(4, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2)
|
||||
// probe.expectNoMsg(4 seconds) //long delay, longer than standard but not yet 5 seconds
|
||||
// remover ! RemoverActor.ClearAll() //cleared
|
||||
// //wait
|
||||
// probe.expectNoMsg(3 seconds) //nothing more to do
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class EarlyDeathRemoverActorTest extends ActorTest {
|
||||
// ServiceManager.boot ! ServiceManager.Register(RandomPool(2).props(Props[TaskResolver]), "taskResolver")
|
||||
// final val TestObject2 = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(2) } }
|
||||
//
|
||||
// "RemoverActor" should {
|
||||
// "be able to hurry certain tasks" in {
|
||||
// expectNoMsg(500 milliseconds)
|
||||
// val probe = TestProbe()
|
||||
// val remover = system.actorOf(Props(classOf[RemoverActorTest.TestRemover], probe), "test-remover")
|
||||
// remover ! RemoverActor.AddTask(RemoverActorTest.TestObject, Zone.Nowhere, Some(5 seconds))
|
||||
// remover ! RemoverActor.AddTask(TestObject2, Zone.Nowhere, Some(5 seconds))
|
||||
//
|
||||
// val replies = probe.receiveN(4, 5 seconds)
|
||||
// var ita : Int = 0
|
||||
// var ija : Int = 0
|
||||
// replies.collect {
|
||||
// case RemoverActorTest.InclusionTestAlert() => ita += 1
|
||||
// case RemoverActorTest.InitialJobAlert() => ija += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(ita == 2 && ija == 2)
|
||||
// probe.expectNoMsg(2 seconds)
|
||||
// remover ! akka.actor.PoisonPill
|
||||
// //
|
||||
// val replies2 = probe.receiveN(8, 5 seconds)
|
||||
// var fja : Int = 0
|
||||
// var cta : Int = 0
|
||||
// var sja : Int = 0
|
||||
// var dta : Int = 0
|
||||
// var dtr : Int = 0
|
||||
// replies2.collect {
|
||||
// case RemoverActorTest.FirstJobAlert() => fja += 1
|
||||
// case RemoverActorTest.ClearanceTestAlert() => cta += 1
|
||||
// case RemoverActorTest.SecondJobAlert() => sja += 1
|
||||
// case RemoverActorTest.DeletionTaskAlert() => dta += 1
|
||||
// case RemoverActorTest.DeletionTaskRunAlert() => dtr += 1
|
||||
// case msg => assert(false, s"$msg")
|
||||
// }
|
||||
// assert(fja == 2 && cta == 0 && sja == 2 && dta == 2 && dtr == 2) //no clearance tests
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//object RemoverActorTest {
|
||||
// final val TestObject = new Equipment() { def Definition = new EquipmentDefinition(0) { GUID = PlanetSideGUID(1) } }
|
||||
//
|
||||
// final case class InclusionTestAlert()
|
||||
//
|
||||
// final case class InitialJobAlert()
|
||||
//
|
||||
// final case class FirstJobAlert()
|
||||
//
|
||||
// final case class SecondJobAlert()
|
||||
//
|
||||
// final case class ClearanceTestAlert()
|
||||
//
|
||||
// final case class DeletionTaskAlert()
|
||||
//
|
||||
// final case class DeletionTaskRunAlert()
|
||||
//
|
||||
// class TestRemover(probe : TestProbe) extends RemoverActor {
|
||||
// import net.psforever.objects.guid.{Task, TaskResolver}
|
||||
// val FirstStandardDuration = 1 seconds
|
||||
//
|
||||
// val SecondStandardDuration = 100 milliseconds
|
||||
//
|
||||
// def InclusionTest(entry : RemoverActor.Entry) : Boolean = {
|
||||
// probe.ref ! InclusionTestAlert()
|
||||
// entry.obj.isInstanceOf[Equipment]
|
||||
// }
|
||||
//
|
||||
// def InitialJob(entry : RemoverActor.Entry) : Unit = {
|
||||
// probe.ref ! InitialJobAlert()
|
||||
// }
|
||||
//
|
||||
// def FirstJob(entry : RemoverActor.Entry) : Unit = {
|
||||
// probe.ref ! FirstJobAlert()
|
||||
// }
|
||||
//
|
||||
// override def SecondJob(entry : RemoverActor.Entry) : Unit = {
|
||||
// probe.ref ! SecondJobAlert()
|
||||
// super.SecondJob(entry)
|
||||
// }
|
||||
//
|
||||
// def ClearanceTest(entry : RemoverActor.Entry) : Boolean = {
|
||||
// probe.ref ! ClearanceTestAlert()
|
||||
// true
|
||||
// }
|
||||
//
|
||||
// def DeletionTask(entry : RemoverActor.Entry) : TaskResolver.GiveTask = {
|
||||
// probe.ref ! DeletionTaskAlert()
|
||||
// TaskResolver.GiveTask(new Task() {
|
||||
// private val localProbe = probe
|
||||
//
|
||||
// override def isComplete = Task.Resolution.Success
|
||||
//
|
||||
// def Execute(resolver : ActorRef) : Unit = {
|
||||
// localProbe.ref ! DeletionTaskRunAlert()
|
||||
// resolver ! scala.util.Success(this)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects._
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types._
|
||||
import services.{Service, ServiceManager}
|
||||
import services.vehicle._
|
||||
|
||||
class VehicleService1Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"construct" in {
|
||||
system.actorOf(Props[VehicleService], "v-service")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleService2Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"subscribe" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleService3Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"subscribe to a specific channel" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! Service.Leave()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleService4Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"subscribe" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! Service.LeaveAll()
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleService5Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass an unhandled message" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! "hello"
|
||||
expectNoMsg()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OwnershipTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass Awareness" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.Ownership(PlanetSideGUID(10), PlanetSideGUID(11)))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.Ownership(PlanetSideGUID(11))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChildObjectStateTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass ChildObjectState" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.ChildObjectState(PlanetSideGUID(10), PlanetSideGUID(11), 1.2f, 3.4f))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.ChildObjectState(PlanetSideGUID(11), 1.2f, 3.4f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DeployRequestTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass DeployRequest" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.DeployRequest(PlanetSideGUID(10), PlanetSideGUID(11), DriveState.Mobile, 0, false, Vector3(1.2f, 3.4f, 5.6f)))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.DeployRequest(PlanetSideGUID(11), DriveState.Mobile, 0, false, Vector3(1.2f, 3.4f, 5.6f))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DismountVehicleTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass DismountVehicle" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.DismountVehicle(PlanetSideGUID(10), BailType.Normal, false))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.DismountVehicle(BailType.Normal, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InventoryStateTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
val tool = Tool(GlobalDefinitions.beamer)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(13)
|
||||
val cdata = tool.Definition.Packet.ConstructorData(tool).get
|
||||
|
||||
"VehicleService" should {
|
||||
"pass InventoryState" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.InventoryState(PlanetSideGUID(10), tool, PlanetSideGUID(11), 0, cdata))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.InventoryState(tool, PlanetSideGUID(11), 0, cdata)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InventoryState2Test extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
val tool = Tool(GlobalDefinitions.beamer)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(13)
|
||||
val cdata = tool.Definition.Packet.ConstructorData(tool).get
|
||||
|
||||
"VehicleService" should {
|
||||
"pass InventoryState2" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.InventoryState2(PlanetSideGUID(10), PlanetSideGUID(11), PlanetSideGUID(12), 13))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.InventoryState2(PlanetSideGUID(11), PlanetSideGUID(12), 13)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KickPassengerTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass KickPassenger" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.KickPassenger(PlanetSideGUID(10), 0, false, PlanetSideGUID(11)))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.KickPassenger(0, false, PlanetSideGUID(11))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LoadVehicleTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
val vehicle = Vehicle(GlobalDefinitions.quadstealth)
|
||||
val cdata = vehicle.Definition.Packet.ConstructorData(vehicle).get
|
||||
|
||||
"VehicleService" should {
|
||||
"pass LoadVehicle" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.LoadVehicle(PlanetSideGUID(10), vehicle, 12, PlanetSideGUID(11), cdata))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.LoadVehicle(vehicle, 12, PlanetSideGUID(11), cdata)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MountVehicleTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass MountVehicle" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.MountVehicle(PlanetSideGUID(10), PlanetSideGUID(11), 0))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.MountVehicle(PlanetSideGUID(11), 0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SeatPermissionsTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass SeatPermissions" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.SeatPermissions(PlanetSideGUID(10), PlanetSideGUID(11), 0, 12L))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.SeatPermissions(PlanetSideGUID(11), 0, 12L)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StowEquipmentTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
val tool = Tool(GlobalDefinitions.beamer)
|
||||
tool.GUID = PlanetSideGUID(12)
|
||||
tool.AmmoSlots.head.Box.GUID = PlanetSideGUID(13)
|
||||
val toolDef = tool.Definition
|
||||
val cdata = tool.Definition.Packet.DetailedConstructorData(tool).get
|
||||
|
||||
"StowEquipment" should {
|
||||
"pass StowEquipment" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.StowEquipment(PlanetSideGUID(10), PlanetSideGUID(11), 0, tool))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.StowEquipment(PlanetSideGUID(11), 0, toolDef.ObjectId, tool.GUID, cdata)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UnstowEquipmentTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass UnstowEquipment" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.UnstowEquipment(PlanetSideGUID(10), PlanetSideGUID(11)))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.UnstowEquipment(PlanetSideGUID(11))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleStateTest extends ActorTest {
|
||||
ServiceManager.boot(system)
|
||||
|
||||
"VehicleService" should {
|
||||
"pass VehicleState" in {
|
||||
val service = system.actorOf(Props[VehicleService], "v-service")
|
||||
service ! Service.Join("test")
|
||||
service ! VehicleServiceMessage("test", VehicleAction.VehicleState(PlanetSideGUID(10), PlanetSideGUID(11), 0, Vector3(1.2f, 3.4f, 5.6f), Vector3(7.8f, 9.1f, 2.3f), Some(Vector3(4.5f, 6.7f, 8.9f)), Option(1), 2, 3, 4, false, true))
|
||||
expectMsg(VehicleServiceResponse("/test/Vehicle", PlanetSideGUID(10), VehicleResponse.VehicleState(PlanetSideGUID(11), 0, Vector3(1.2f, 3.4f, 5.6f), Vector3(7.8f, 9.1f, 2.3f), Some(Vector3(4.5f, 6.7f, 8.9f)), Option(1), 2, 3, 4, false, true)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object VehicleServiceTest {
|
||||
//decoy
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue