mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-09 03:41:02 +00:00
* 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
199 lines
8.2 KiB
Scala
199 lines
8.2 KiB
Scala
// Copyright (c) 2017 PSForever
|
|
package objects
|
|
|
|
import akka.actor.{Actor, ActorSystem, Props}
|
|
import base.ActorTest
|
|
import net.psforever.objects.serverobject.PlanetSideServerObject
|
|
import net.psforever.objects.{GlobalDefinitions, Vehicle}
|
|
import net.psforever.objects.serverobject.deploy.{Deployment, DeploymentBehavior}
|
|
import net.psforever.types.{DriveState, PlanetSideEmpire}
|
|
import org.specs2.mutable.Specification
|
|
|
|
import scala.concurrent.duration.Duration
|
|
|
|
class DeploymentTest extends Specification {
|
|
"Deployment" should {
|
|
"construct" in {
|
|
val obj = new DeploymentTest.DeploymentObject()
|
|
obj.DeploymentState mustEqual DriveState.Mobile
|
|
obj.DeployTime mustEqual 0
|
|
obj.UndeployTime mustEqual 0
|
|
}
|
|
|
|
"change deployment state" in {
|
|
val obj = new DeploymentTest.DeploymentObject()
|
|
obj.DeploymentState mustEqual DriveState.Mobile
|
|
|
|
obj.DeploymentState = DriveState.Deployed
|
|
obj.DeploymentState mustEqual DriveState.Deployed
|
|
obj.DeploymentState = DriveState.Deploying
|
|
obj.DeploymentState mustEqual DriveState.Deploying
|
|
obj.DeploymentState = DriveState.Undeploying
|
|
obj.DeploymentState mustEqual DriveState.Undeploying
|
|
obj.DeploymentState = DriveState.State7
|
|
obj.DeploymentState mustEqual DriveState.State7
|
|
}
|
|
|
|
"have custom deployment time by object" in {
|
|
val ams = Vehicle(GlobalDefinitions.ams)
|
|
(ams.DeployTime == 0) mustEqual false //not default
|
|
(ams.UndeployTime == 0) mustEqual false //not default
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior1Test extends ActorTest {
|
|
"Deployment" should {
|
|
"construct" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.Actor != Actor.noSender)
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior2Test extends ActorTest {
|
|
"Deployment" should {
|
|
"change following a deployment cycle using TryDeployChange" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
//to Deploying
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Deploying)
|
|
val reply1 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply1.isInstanceOf[Deployment.CanDeploy])
|
|
assert(reply1.asInstanceOf[Deployment.CanDeploy].obj == obj)
|
|
assert(reply1.asInstanceOf[Deployment.CanDeploy].state == DriveState.Deploying)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Deployed)
|
|
val reply2 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply2.isInstanceOf[Deployment.CanDeploy])
|
|
assert(reply2.asInstanceOf[Deployment.CanDeploy].obj == obj)
|
|
assert(reply2.asInstanceOf[Deployment.CanDeploy].state == DriveState.Deployed)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Undeploying)
|
|
val reply3 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply3.isInstanceOf[Deployment.CanUndeploy])
|
|
assert(reply3.asInstanceOf[Deployment.CanUndeploy].obj == obj)
|
|
assert(reply3.asInstanceOf[Deployment.CanUndeploy].state == DriveState.Undeploying)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Mobile)
|
|
val reply4 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply4.isInstanceOf[Deployment.CanUndeploy])
|
|
assert(reply4.asInstanceOf[Deployment.CanUndeploy].obj == obj)
|
|
assert(reply4.asInstanceOf[Deployment.CanUndeploy].state == DriveState.Mobile)
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior3Test extends ActorTest {
|
|
"Deployment" should {
|
|
"change following a deployment cycle using TryDeploy and TryUndeploy" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
//to Deploying
|
|
obj.Actor ! Deployment.TryDeploy(DriveState.Deploying)
|
|
val reply1 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply1.isInstanceOf[Deployment.CanDeploy])
|
|
assert(reply1.asInstanceOf[Deployment.CanDeploy].obj == obj)
|
|
assert(reply1.asInstanceOf[Deployment.CanDeploy].state == DriveState.Deploying)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryDeploy(DriveState.Deployed)
|
|
val reply2 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply2.isInstanceOf[Deployment.CanDeploy])
|
|
assert(reply2.asInstanceOf[Deployment.CanDeploy].obj == obj)
|
|
assert(reply2.asInstanceOf[Deployment.CanDeploy].state == DriveState.Deployed)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryUndeploy(DriveState.Undeploying)
|
|
val reply3 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply3.isInstanceOf[Deployment.CanUndeploy])
|
|
assert(reply3.asInstanceOf[Deployment.CanUndeploy].obj == obj)
|
|
assert(reply3.asInstanceOf[Deployment.CanUndeploy].state == DriveState.Undeploying)
|
|
//to Deployed
|
|
obj.Actor ! Deployment.TryUndeploy(DriveState.Mobile)
|
|
val reply4 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply4.isInstanceOf[Deployment.CanUndeploy])
|
|
assert(reply4.asInstanceOf[Deployment.CanUndeploy].obj == obj)
|
|
assert(reply4.asInstanceOf[Deployment.CanUndeploy].state == DriveState.Mobile)
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior4Test extends ActorTest {
|
|
"Deployment" should {
|
|
"not deploy to an out of order state" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Deployed)
|
|
val reply1 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply1.isInstanceOf[Deployment.CanNotChangeDeployment])
|
|
assert(reply1.asInstanceOf[Deployment.CanNotChangeDeployment].obj == obj)
|
|
assert(reply1.asInstanceOf[Deployment.CanNotChangeDeployment].to_state == DriveState.Deployed)
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
|
|
obj.Actor ! Deployment.TryDeploy(DriveState.Deployed)
|
|
val reply2 = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply2.isInstanceOf[Deployment.CanNotChangeDeployment])
|
|
assert(reply2.asInstanceOf[Deployment.CanNotChangeDeployment].obj == obj)
|
|
assert(reply2.asInstanceOf[Deployment.CanNotChangeDeployment].to_state == DriveState.Deployed)
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior5Test extends ActorTest {
|
|
"Deployment" should {
|
|
"not deploy to an undeploy state" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Deploying)
|
|
receiveOne(Duration.create(100, "ms")) //consume
|
|
obj.Actor ! Deployment.TryDeploymentChange(DriveState.Deployed)
|
|
receiveOne(Duration.create(100, "ms")) //consume
|
|
assert(obj.DeploymentState == DriveState.Deployed)
|
|
|
|
obj.Actor ! Deployment.TryDeploy(DriveState.Undeploying)
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply.isInstanceOf[Deployment.CanNotChangeDeployment])
|
|
assert(reply.asInstanceOf[Deployment.CanNotChangeDeployment].obj == obj)
|
|
assert(reply.asInstanceOf[Deployment.CanNotChangeDeployment].to_state == DriveState.Undeploying)
|
|
assert(obj.DeploymentState == DriveState.Deployed)
|
|
}
|
|
}
|
|
}
|
|
|
|
class DeploymentBehavior6Test extends ActorTest {
|
|
"Deployment" should {
|
|
"not undeploy to a deploy state" in {
|
|
val obj = DeploymentTest.SetUpAgent
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
|
|
obj.Actor ! Deployment.TryUndeploy(DriveState.Deploying)
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
|
assert(reply.isInstanceOf[Deployment.CanNotChangeDeployment])
|
|
assert(reply.asInstanceOf[Deployment.CanNotChangeDeployment].obj == obj)
|
|
assert(reply.asInstanceOf[Deployment.CanNotChangeDeployment].to_state == DriveState.Deploying)
|
|
assert(obj.DeploymentState == DriveState.Mobile)
|
|
}
|
|
}
|
|
}
|
|
|
|
object DeploymentTest {
|
|
class DeploymentObject extends PlanetSideServerObject with Deployment {
|
|
def Faction : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
|
def Definition = null
|
|
}
|
|
|
|
private class DeploymentControl(obj : Deployment.DeploymentObject) extends Actor
|
|
with DeploymentBehavior {
|
|
override def DeploymentObject = obj
|
|
def receive = deployBehavior.orElse { case _ => }
|
|
}
|
|
|
|
def SetUpAgent(implicit system : ActorSystem) = {
|
|
val obj = new DeploymentObject()
|
|
obj.Actor = system.actorOf(Props(classOf[DeploymentControl], obj), "test")
|
|
obj
|
|
}
|
|
}
|