mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-25 01:23:36 +00:00
Building:
Replaces class object/serverobject/door/Base.scala. It performs nearly the exact same purpose but now has a list of owned objects called Amenities. Buildings are now a PlanetSideServerObject (PSSO), which allows them to have accept a *Control Actor and possess FactionAffinity. FoundationBuilder: FoundationBuilder : Building :: ServerObjectBuilder : [T <: PlanetSideServerObject] Amenity: Most PSSO's now accept Amenity as their parent in class hierarchy. Flagged PSSO's like Building and Vehicle are, on the other hand, capable of becoming the owner for these Amenity PSSOs, which allows them to inherit the same FactionAffinity. FactionAffinity: A trait that connects objects that are intended to communicate PlanetSideEmpire values. MountableBhevaior: Split between Mount and Dismount behavior. Passes appropriate messages to ensure coherent workflows. Control Actors: FactionAffinityBehavior and MountableBehavior are PartialFunctions that get processed in series. VehicleControl: Distinguished behavior allowed between an operational vehicle and a deactivated one. WSA: Tightened up DismountVehicleMsg handling code, since MountableBehavior has been enhanced. Minor: Shotgun shell stacking goes from 32 to 16. Various PSSO classes now have reliable Definition objects. Tests: We now have 1012 tests, some of them useful.
This commit is contained in:
parent
8c02f8d519
commit
eefe4d2e20
56 changed files with 1362 additions and 425 deletions
131
common/src/test/scala/objects/FactionAffinityTest.scala
Normal file
131
common/src/test/scala/objects/FactionAffinityTest.scala
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{Actor, ActorSystem, Props}
|
||||
import net.psforever.objects.{GlobalDefinitions, Vehicle}
|
||||
import net.psforever.objects.serverobject.affinity.FactionAffinity
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
import net.psforever.objects.serverobject.structures.Building
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
class FactionAffinityTest extends Specification {
|
||||
"FactionAffinity" should {
|
||||
"construct (basic)" in {
|
||||
val obj = new FactionAffinity { def Faction = PlanetSideEmpire.TR }
|
||||
obj.Faction mustEqual PlanetSideEmpire.TR
|
||||
}
|
||||
|
||||
"construct (part of)" in {
|
||||
val obj = new Door(GlobalDefinitions.door)
|
||||
obj.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
}
|
||||
|
||||
"can not change affinity directly (basic)" in {
|
||||
val obj = new FactionAffinity { def Faction = PlanetSideEmpire.TR }
|
||||
(obj.Faction = PlanetSideEmpire.NC) mustEqual PlanetSideEmpire.TR
|
||||
}
|
||||
|
||||
"can not change affinity directly (part of)" in {
|
||||
val obj = new Door(GlobalDefinitions.door)
|
||||
(obj.Faction = PlanetSideEmpire.TR) mustEqual PlanetSideEmpire.NEUTRAL
|
||||
}
|
||||
|
||||
"inherits affinity from owner 1" in {
|
||||
val obj = new Door(GlobalDefinitions.door)
|
||||
obj.Owner.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
(obj.Faction = PlanetSideEmpire.TR) mustEqual PlanetSideEmpire.NEUTRAL
|
||||
}
|
||||
|
||||
"inherits affinity from owner 2" in {
|
||||
val obj = new Door(GlobalDefinitions.door)
|
||||
val bldg = new Building(1, Zone.Nowhere)
|
||||
obj.Owner = bldg
|
||||
obj.Faction mustEqual PlanetSideEmpire.NEUTRAL
|
||||
|
||||
bldg.Faction = PlanetSideEmpire.TR
|
||||
obj.Faction mustEqual PlanetSideEmpire.TR
|
||||
|
||||
bldg.Faction = PlanetSideEmpire.NC
|
||||
obj.Faction mustEqual PlanetSideEmpire.NC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FactionAffinity1Test extends ActorTest() {
|
||||
"FactionAffinity" should {
|
||||
"assert affinity on confirm request" in {
|
||||
val obj = FactionAffinityTest.SetUpAgent
|
||||
obj.Faction = PlanetSideEmpire.VS //object is a type that can be changed directly
|
||||
assert(obj.Faction == PlanetSideEmpire.VS)
|
||||
|
||||
obj.Actor ! FactionAffinity.ConfirmFactionAffinity()
|
||||
val reply = receiveOne(Duration.create(100, "ms"))
|
||||
assert(reply.isInstanceOf[FactionAffinity.AssertFactionAffinity])
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].obj == obj)
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].faction == PlanetSideEmpire.VS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FactionAffinity2Test extends ActorTest() {
|
||||
"FactionAffinity" should {
|
||||
"assert affinity on assert request" in {
|
||||
val obj = FactionAffinityTest.SetUpAgent
|
||||
obj.Faction = PlanetSideEmpire.VS //object is a type that can be changed directly
|
||||
assert(obj.Faction == PlanetSideEmpire.VS)
|
||||
|
||||
obj.Actor ! FactionAffinity.AssertFactionAffinity(obj, PlanetSideEmpire.NEUTRAL)
|
||||
val reply = receiveOne(Duration.create(100, "ms"))
|
||||
assert(reply.isInstanceOf[FactionAffinity.AssertFactionAffinity])
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].obj == obj)
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].faction == PlanetSideEmpire.VS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FactionAffinity3Test extends ActorTest() {
|
||||
"FactionAffinity" should {
|
||||
"convert and assert affinity on convert request" in {
|
||||
val obj = FactionAffinityTest.SetUpAgent
|
||||
obj.Faction = PlanetSideEmpire.VS //object is a type that can be changed directly
|
||||
assert(obj.Faction == PlanetSideEmpire.VS)
|
||||
|
||||
obj.Actor ! FactionAffinity.ConvertFactionAffinity(PlanetSideEmpire.TR)
|
||||
val reply = receiveOne(Duration.create(100, "ms"))
|
||||
assert(reply.isInstanceOf[FactionAffinity.AssertFactionAffinity])
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].obj == obj)
|
||||
assert(reply.asInstanceOf[FactionAffinity.AssertFactionAffinity].faction == PlanetSideEmpire.TR)
|
||||
assert(obj.Faction == PlanetSideEmpire.TR)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object FactionAffinityTest {
|
||||
import net.psforever.objects.serverobject.affinity.FactionAffinityBehavior
|
||||
|
||||
private class AffinityControl(obj : FactionAffinity) extends Actor
|
||||
with FactionAffinityBehavior.Check
|
||||
with FactionAffinityBehavior.Convert {
|
||||
override def FactionObject = obj
|
||||
def receive = checkBehavior.orElse(convertBehavior).orElse { case _ => }
|
||||
}
|
||||
|
||||
def SetUpAgent(implicit system : ActorSystem) = {
|
||||
val obj = new Vehicle(GlobalDefinitions.quadstealth)
|
||||
obj.Actor = system.actorOf(Props(classOf[FactionAffinityTest.AffinityControl], obj), "test")
|
||||
obj
|
||||
}
|
||||
|
||||
def FreeFactionObject : FactionAffinity = new FactionAffinity() {
|
||||
private var faction : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
def Faction : PlanetSideEmpire.Value = faction
|
||||
override def Faction_=(fac : PlanetSideEmpire.Value) : PlanetSideEmpire.Value = {
|
||||
faction = fac
|
||||
faction
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue