2017-11-06 10:24:36 -05:00
|
|
|
// Copyright (c) 2017 PSForever
|
|
|
|
|
package objects
|
|
|
|
|
|
2018-03-24 00:28:02 -04:00
|
|
|
import java.util.concurrent.atomic.AtomicInteger
|
2020-10-10 09:16:56 -04:00
|
|
|
|
2020-07-22 17:28:09 +02:00
|
|
|
import akka.actor.ActorContext
|
2018-07-14 21:25:44 -04:00
|
|
|
import base.ActorTest
|
2017-11-06 10:24:36 -05:00
|
|
|
import net.psforever.objects.entity.IdentifiableEntity
|
|
|
|
|
import net.psforever.objects.equipment.Equipment
|
|
|
|
|
import net.psforever.objects.guid.NumberPoolHub
|
2020-09-15 19:46:56 -04:00
|
|
|
import net.psforever.objects.guid.source.MaxNumberSource
|
2018-03-24 00:28:02 -04:00
|
|
|
import net.psforever.objects.serverobject.terminals.Terminal
|
|
|
|
|
import net.psforever.objects.serverobject.tube.SpawnTube
|
2018-03-31 19:31:17 -04:00
|
|
|
import net.psforever.objects._
|
2020-01-06 08:45:55 -05:00
|
|
|
import net.psforever.types._
|
2018-04-03 23:14:44 -04:00
|
|
|
import net.psforever.objects.serverobject.structures.{Building, FoundationBuilder, StructureType}
|
2020-07-22 17:28:09 +02:00
|
|
|
import net.psforever.objects.zones.{Zone, ZoneMap}
|
2018-04-03 23:14:44 -04:00
|
|
|
import net.psforever.objects.Vehicle
|
2017-11-06 10:24:36 -05:00
|
|
|
import org.specs2.mutable.Specification
|
2020-07-22 17:28:09 +02:00
|
|
|
import akka.actor.typed.scaladsl.adapter._
|
|
|
|
|
import net.psforever.actors.zone.ZoneActor
|
2020-08-01 12:25:03 +02:00
|
|
|
import net.psforever.objects.avatar.Avatar
|
2020-10-10 09:16:56 -04:00
|
|
|
import net.psforever.services.ServiceManager
|
2017-11-06 10:24:36 -05:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
import scala.concurrent.duration._
|
2018-03-24 00:28:02 -04:00
|
|
|
|
2017-11-06 10:24:36 -05:00
|
|
|
class ZoneTest extends Specification {
|
2020-07-22 17:28:09 +02:00
|
|
|
def test(a: String, b: Int, c: Int, d: Zone, e: ActorContext): Building = {
|
|
|
|
|
Building.NoBuilding
|
|
|
|
|
}
|
2018-01-26 15:32:08 -05:00
|
|
|
|
2017-11-06 10:24:36 -05:00
|
|
|
"ZoneMap" should {
|
|
|
|
|
"construct" in {
|
|
|
|
|
new ZoneMap("map13")
|
|
|
|
|
ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"references bases by a positive building id (defaults to 0)" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.localBuildings mustEqual Map.empty
|
|
|
|
|
map.addLocalBuilding("Building", buildingGuid = 10, mapId = 0, FoundationBuilder(test))
|
|
|
|
|
map.localBuildings.keySet.contains(("Building", 10, 0)) mustEqual true
|
|
|
|
|
map.addLocalBuilding("Building", buildingGuid = -1, mapId = 0, FoundationBuilder(test))
|
|
|
|
|
map.localBuildings.keySet.contains(("Building", 10, 0)) mustEqual true
|
|
|
|
|
map.localBuildings.keySet.contains(("Building", -1, 0)) mustEqual false
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"associates objects to bases (doesn't check numbers)" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.objectToBuilding mustEqual Map.empty
|
|
|
|
|
map.linkObjectToBuilding(1, 2)
|
|
|
|
|
map.objectToBuilding mustEqual Map(1 -> 2)
|
|
|
|
|
map.linkObjectToBuilding(3, 4)
|
|
|
|
|
map.objectToBuilding mustEqual Map(1 -> 2, 3 -> 4)
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"associates doors to door locks (doesn't check numbers)" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.doorToLock mustEqual Map.empty
|
|
|
|
|
map.linkDoorToLock(1, 2)
|
|
|
|
|
map.doorToLock mustEqual Map(1 -> 2)
|
|
|
|
|
map.linkDoorToLock(3, 4)
|
|
|
|
|
map.doorToLock mustEqual Map(1 -> 2, 3 -> 4)
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
2017-11-29 22:30:25 -05:00
|
|
|
|
|
|
|
|
"associates terminals to spawn pads (doesn't check numbers)" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.terminalToSpawnPad mustEqual Map.empty
|
|
|
|
|
map.linkTerminalToSpawnPad(1, 2)
|
|
|
|
|
map.terminalToSpawnPad mustEqual Map(1 -> 2)
|
|
|
|
|
map.linkTerminalToSpawnPad(3, 4)
|
|
|
|
|
map.terminalToSpawnPad mustEqual Map(1 -> 2, 3 -> 4)
|
2017-11-29 22:30:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"associates mechanical components to implant terminals (doesn't check numbers)" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.terminalToInterface mustEqual Map.empty
|
|
|
|
|
map.linkTerminalToInterface(1, 2)
|
|
|
|
|
map.terminalToInterface mustEqual Map(1 -> 2)
|
|
|
|
|
map.linkTerminalToInterface(3, 4)
|
|
|
|
|
map.terminalToInterface mustEqual Map(1 -> 2, 3 -> 4)
|
2018-07-14 21:25:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"associate turrets to weapons" in {
|
|
|
|
|
val map = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map.turretToWeapon mustEqual Map.empty
|
|
|
|
|
map.linkTurretToWeapon(1, 2)
|
|
|
|
|
map.turretToWeapon mustEqual Map(1 -> 2)
|
|
|
|
|
map.linkTurretToWeapon(3, 4)
|
|
|
|
|
map.turretToWeapon mustEqual Map(1 -> 2, 3 -> 4)
|
2017-11-29 22:30:25 -05:00
|
|
|
}
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val map13 = new ZoneMap("map13")
|
2020-08-01 12:25:03 +02:00
|
|
|
map13.addLocalBuilding("Building", buildingGuid = 0, mapId = 10, FoundationBuilder(test))
|
2017-11-06 10:24:36 -05:00
|
|
|
class TestObject extends IdentifiableEntity
|
|
|
|
|
|
|
|
|
|
"Zone" should {
|
|
|
|
|
"construct" in {
|
|
|
|
|
val zone = new Zone("home3", map13, 13)
|
|
|
|
|
zone.EquipmentOnGround mustEqual List.empty[Equipment]
|
|
|
|
|
zone.Vehicles mustEqual List.empty[Vehicle]
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Players mustEqual List.empty[Player]
|
|
|
|
|
zone.Corpses mustEqual List.empty[Player]
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"can have its unique identifier system changed if no objects were added to it" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("home3", map13, 13)
|
2020-09-15 19:46:56 -04:00
|
|
|
val guid1: NumberPoolHub = new NumberPoolHub(new MaxNumberSource(100))
|
2017-11-06 10:24:36 -05:00
|
|
|
zone.GUID(guid1) mustEqual true
|
2018-06-15 14:50:42 -04:00
|
|
|
zone.AddPool("pool1", (0 to 50).toList)
|
|
|
|
|
zone.AddPool("pool2", (51 to 75).toList)
|
2017-11-06 10:24:36 -05:00
|
|
|
|
|
|
|
|
val obj = new TestObject()
|
2020-08-25 15:24:26 -04:00
|
|
|
val registration = guid1.register(obj, "pool2")
|
|
|
|
|
registration.isSuccess mustEqual true
|
2020-02-14 21:11:40 -05:00
|
|
|
guid1.WhichPool(obj).contains("pool2") mustEqual true
|
2017-11-06 10:24:36 -05:00
|
|
|
|
2020-09-15 19:46:56 -04:00
|
|
|
zone.GUID(new NumberPoolHub(new MaxNumberSource(150))) mustEqual false
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
class ZoneActorTest extends ActorTest {
|
2020-10-10 09:16:56 -04:00
|
|
|
ServiceManager.boot
|
2018-03-24 00:28:02 -04:00
|
|
|
"Zone" should {
|
2018-06-15 14:50:42 -04:00
|
|
|
"refuse new number pools after the Actor is started" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("map6"), 1) { override def SetupNumberPools() = {} }
|
2020-09-15 19:46:56 -04:00
|
|
|
zone.GUID(new NumberPoolHub(new MaxNumberSource(40150)))
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), "test-add-pool-actor-init")
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(500, "ms"))
|
2018-06-15 14:50:42 -04:00
|
|
|
|
2020-07-14 05:54:05 +02:00
|
|
|
assert(!zone.AddPool("test1", 1 to 2))
|
2018-06-15 14:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"refuse to remove number pools after the Actor is started" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("map6"), 1) { override def SetupNumberPools() = {} }
|
2018-06-15 14:50:42 -04:00
|
|
|
|
2020-09-15 19:46:56 -04:00
|
|
|
zone.GUID(new NumberPoolHub(new MaxNumberSource(10)))
|
2018-06-15 14:50:42 -04:00
|
|
|
zone.AddPool("test", 1 to 2)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), "test-remove-pool-actor-init")
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(300, "ms"))
|
2018-06-15 14:50:42 -04:00
|
|
|
|
2020-07-14 05:54:05 +02:00
|
|
|
assert(!zone.RemovePool("test"))
|
2018-06-15 14:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
2018-03-24 00:28:02 -04:00
|
|
|
"set up spawn groups based on buildings" in {
|
|
|
|
|
val map6 = new ZoneMap("map6") {
|
2020-08-01 12:25:03 +02:00
|
|
|
addLocalBuilding(
|
2020-07-14 05:54:05 +02:00
|
|
|
"Building",
|
2020-08-01 12:25:03 +02:00
|
|
|
buildingGuid = 1,
|
|
|
|
|
mapId = 1,
|
2020-07-14 05:54:05 +02:00
|
|
|
FoundationBuilder(Building.Structure(StructureType.Building, Vector3(1, 1, 1)))
|
|
|
|
|
)
|
2020-08-01 12:25:03 +02:00
|
|
|
addLocalObject(2, SpawnTube.Constructor(Vector3(1, 0, 0), Vector3.Zero))
|
|
|
|
|
addLocalObject(3, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
|
|
|
|
addLocalObject(4, SpawnTube.Constructor(Vector3(1, 0, 0), Vector3.Zero))
|
|
|
|
|
linkObjectToBuilding(2, 1)
|
|
|
|
|
linkObjectToBuilding(3, 1)
|
|
|
|
|
linkObjectToBuilding(4, 1)
|
|
|
|
|
|
|
|
|
|
addLocalBuilding(
|
2020-07-14 05:54:05 +02:00
|
|
|
"Building",
|
2020-08-01 12:25:03 +02:00
|
|
|
buildingGuid = 5,
|
|
|
|
|
mapId = 2,
|
2020-07-14 05:54:05 +02:00
|
|
|
FoundationBuilder(Building.Structure(StructureType.Building))
|
|
|
|
|
)
|
2020-08-01 12:25:03 +02:00
|
|
|
addLocalObject(6, SpawnTube.Constructor(Vector3.Zero, Vector3.Zero))
|
|
|
|
|
linkObjectToBuilding(6, 5)
|
2020-02-14 21:11:40 -05:00
|
|
|
|
2020-08-01 12:25:03 +02:00
|
|
|
addLocalBuilding(
|
2020-07-14 05:54:05 +02:00
|
|
|
"Building",
|
2020-08-01 12:25:03 +02:00
|
|
|
buildingGuid = 7,
|
|
|
|
|
mapId = 3,
|
2020-07-14 05:54:05 +02:00
|
|
|
FoundationBuilder(Building.Structure(StructureType.Building, Vector3(1, 1, 1)))
|
|
|
|
|
)
|
2020-08-01 12:25:03 +02:00
|
|
|
addLocalObject(8, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
|
|
|
|
addLocalObject(9, SpawnTube.Constructor(Vector3(1, 0, 0), Vector3.Zero))
|
|
|
|
|
addLocalObject(10, Terminal.Constructor(Vector3.Zero, GlobalDefinitions.dropship_vehicle_terminal))
|
|
|
|
|
linkObjectToBuilding(8, 7)
|
|
|
|
|
linkObjectToBuilding(9, 7)
|
|
|
|
|
linkObjectToBuilding(10, 7)
|
2018-03-24 00:28:02 -04:00
|
|
|
}
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", map6, 1) { override def SetupNumberPools() = {} }
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), "test-init")
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(1, "seconds"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
val groups = zone.SpawnGroups()
|
|
|
|
|
assert(groups.size == 2)
|
2020-07-14 05:54:05 +02:00
|
|
|
zone
|
|
|
|
|
.SpawnGroups()
|
|
|
|
|
.foreach({
|
|
|
|
|
case (building, tubes) =>
|
|
|
|
|
if (building.MapId == 1) {
|
|
|
|
|
val building1 = zone.SpawnGroups(building)
|
|
|
|
|
assert(tubes.length == 2)
|
|
|
|
|
assert(tubes.head == building1.head)
|
|
|
|
|
assert(tubes.head.GUID == PlanetSideGUID(2))
|
|
|
|
|
assert(tubes(1) == building1(1))
|
|
|
|
|
assert(tubes(1).GUID == PlanetSideGUID(4))
|
|
|
|
|
} else if (building.MapId == 3) {
|
|
|
|
|
val building2 = zone.SpawnGroups(building)
|
|
|
|
|
assert(tubes.length == 1)
|
|
|
|
|
assert(tubes.head == building2.head)
|
|
|
|
|
assert(tubes.head.GUID == PlanetSideGUID(9))
|
|
|
|
|
} else {
|
|
|
|
|
assert(false)
|
|
|
|
|
}
|
|
|
|
|
})
|
2018-03-24 00:28:02 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ZonePopulationTest extends ActorTest {
|
|
|
|
|
"ZonePopulationActor" should {
|
|
|
|
|
"add new user to zones" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2020-08-25 15:24:26 -04:00
|
|
|
val player = Player(avatar)
|
|
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.isEmpty)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player, null)
|
2020-08-01 12:25:03 +02:00
|
|
|
expectNoMessage(Duration.create(200, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
2020-08-01 12:25:03 +02:00
|
|
|
// assert(zone.LivePlayers.isEmpty)
|
2018-03-24 00:28:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"remove user from zones" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val avatar = Avatar(1, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2020-08-25 15:24:26 -04:00
|
|
|
val player = Player(avatar)
|
|
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2018-03-24 00:28:02 -04:00
|
|
|
receiveOne(Duration.create(200, "ms")) //consume
|
|
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player, null)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
zone.Population ! Zone.Population.Leave(avatar)
|
2020-08-01 12:25:03 +02:00
|
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Population.PlayerHasLeft])
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Players.isEmpty)
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-01 12:25:03 +02:00
|
|
|
/* TODO they need AvatarActor, which has further dependencies
|
2018-03-24 00:28:02 -04:00
|
|
|
"associate user with a character" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) { override def SetupNumberPools() = {} }
|
2020-08-01 12:25:03 +02:00
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player = Player(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.size == 1)
|
|
|
|
|
assert(zone.LivePlayers.head == player)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"disassociate character from a user" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) { override def SetupNumberPools() = {} }
|
2020-08-01 12:25:03 +02:00
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player = Player(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.size == 1)
|
|
|
|
|
assert(zone.LivePlayers.head == player)
|
|
|
|
|
zone.Population ! Zone.Population.Release(avatar)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user tries to Leave, but still has an associated character" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) { override def SetupNumberPools() = {} }
|
2020-08-01 12:25:03 +02:00
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player = Player(avatar)
|
Persistence (#337)
* constructed service actor to handle persistence of player on server beyond the reaches of WSA from one login to the next; created in PSLogin, interfaced with and updated in WSA
* for what it's worth, players can be completely logged out of the world after 60s of inactivity, alive Infantry only right now; some code was removed from WSA to make it accessible to other classes but it's incomparable to the new code; broke, fixed, compromised on the code that handles loadouts, server login time, etc.
* moved another common vehicle function into global space; persistence object for players in vehicles during log-out or relogging in a vehicle
* support for relogging when dead/released/unfound; silenced implant slot setup during character select screen
* tested and commented code for managing player avatar persistence
* clarificaion of WSA postStop
* test fixed
* postStop change to account for WSA being cut short during initialization
* clarification of SquadService logout
* player died during setup; probably a relog
* kill the doppelganger WSA; die when you are actually dead
* created manifest to assist with vehicle gating; vehicle gating now accomodates the persistence model much better
* fixed the test
* fixed initial vehicle seat access permissions; moved a subscription to AvatarService to support persistence
* bug fixes: safer GridInventory collision checks, plus specific exceptions; SessionRouter waits for the account intermediary before allowing itself to be started; WSA - match error colution, and MAX without arm now creates the arm it expects
* adjusted insertion and removal code to make inventory management less prone to partoial insertions of removals; inventory integrity checking code writen, but no plans on implementing it yet
2020-02-14 10:54:52 -05:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.size == 1)
|
|
|
|
|
assert(zone.LivePlayers.head == player)
|
|
|
|
|
zone.Population ! Zone.Population.Leave(avatar)
|
2020-02-14 21:11:40 -05:00
|
|
|
val reply = receiveOne(Duration.create(500, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Players.isEmpty)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Population.PlayerHasLeft])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerHasLeft].zone == zone)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerHasLeft].player.contains(player))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user tries to Spawn a character, but an associated character already exists" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) { override def SetupNumberPools() = {} }
|
2020-08-01 12:25:03 +02:00
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player1 = Player(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
player1.GUID = PlanetSideGUID(1)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player2 = Player(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
player2.GUID = PlanetSideGUID(2)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player1)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.size == 1)
|
|
|
|
|
assert(zone.LivePlayers.head == player1)
|
|
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player2)
|
|
|
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
|
|
|
|
assert(zone.LivePlayers.size == 1)
|
|
|
|
|
assert(zone.LivePlayers.head == player1)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Population.PlayerAlreadySpawned])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerAlreadySpawned].player == player1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user tries to Spawn a character, but did not Join first" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) { override def SetupNumberPools() = {} }
|
2020-08-01 12:25:03 +02:00
|
|
|
val avatar = Avatar(0, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2018-03-24 00:28:02 -04:00
|
|
|
val player = Player(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.isEmpty)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player)
|
|
|
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
|
|
|
|
assert(zone.Players.isEmpty)
|
|
|
|
|
assert(zone.LivePlayers.isEmpty)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Population.PlayerCanNotSpawn])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerCanNotSpawn].zone == zone)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerCanNotSpawn].player == player)
|
|
|
|
|
}
|
2020-08-01 12:25:03 +02:00
|
|
|
*/
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
"user tries to Release a character, but did not Spawn a character first" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val avatar = Avatar(2, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
2020-08-25 15:24:26 -04:00
|
|
|
val player = Player(avatar)
|
|
|
|
|
player.GUID = PlanetSideGUID(1)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Join(avatar)
|
2020-08-25 15:24:26 -04:00
|
|
|
zone.Population ! Zone.Population.Spawn(avatar, player, null)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(Duration.create(100, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Players.size == 1)
|
|
|
|
|
assert(zone.Players.head == avatar)
|
2020-08-01 12:25:03 +02:00
|
|
|
// assert(zone.LivePlayers.isEmpty)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Population.Release(avatar)
|
|
|
|
|
val reply = receiveOne(Duration.create(100, "ms"))
|
2020-08-01 12:25:03 +02:00
|
|
|
// assert(zone.Players.size == 1)
|
|
|
|
|
// assert(zone.Players.head == avatar)
|
|
|
|
|
// assert(zone.LivePlayers.isEmpty)
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(reply.isInstanceOf[Zone.Population.PlayerHasLeft])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Population.PlayerHasLeft].zone == zone)
|
2020-08-01 12:25:03 +02:00
|
|
|
// assert(reply.asInstanceOf[Zone.Population.PlayerHasLeft].player.isEmpty)
|
2018-03-24 00:28:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user adds character to list of retired characters" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val player = Player(Avatar(3, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2018-03-24 00:28:02 -04:00
|
|
|
player.Release
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Corpses.isEmpty)
|
|
|
|
|
zone.Population ! Zone.Corpse.Add(player)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(500, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Corpses.size == 1)
|
|
|
|
|
assert(zone.Corpses.head == player)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user removes character from the list of retired characters" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val player = Player(Avatar(4, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2018-03-24 00:28:02 -04:00
|
|
|
player.Release
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Corpse.Add(player)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(500, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Corpses.size == 1)
|
|
|
|
|
assert(zone.Corpses.head == player)
|
|
|
|
|
zone.Population ! Zone.Corpse.Remove(player)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(200, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Corpses.isEmpty)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user removes THE CORRECT character from the list of retired characters" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val player1 = Player(Avatar(5, "Chord1", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player1.GUID = PlanetSideGUID(1)
|
2018-03-24 00:28:02 -04:00
|
|
|
player1.Release
|
2020-08-01 12:25:03 +02:00
|
|
|
val player2 = Player(Avatar(6, "Chord2", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player2.GUID = PlanetSideGUID(2)
|
2018-03-24 00:28:02 -04:00
|
|
|
player2.Release
|
2020-08-01 12:25:03 +02:00
|
|
|
val player3 = Player(Avatar(7, "Chord3", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player3.GUID = PlanetSideGUID(3)
|
2018-03-24 00:28:02 -04:00
|
|
|
player3.Release
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
zone.Population ! Zone.Corpse.Add(player1)
|
|
|
|
|
zone.Population ! Zone.Corpse.Add(player2)
|
|
|
|
|
zone.Population ! Zone.Corpse.Add(player3)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(500, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Corpses.size == 3)
|
|
|
|
|
assert(zone.Corpses.head == player1)
|
|
|
|
|
assert(zone.Corpses(1) == player2)
|
|
|
|
|
assert(zone.Corpses(2) == player3)
|
|
|
|
|
zone.Population ! Zone.Corpse.Remove(player2)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(200, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Corpses.size == 2)
|
|
|
|
|
assert(zone.Corpses.head == player1)
|
|
|
|
|
assert(zone.Corpses(1) == player3)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"user tries to add character to list of retired characters, but is not in correct state" in {
|
2020-08-01 12:25:03 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap(""), 0) {
|
|
|
|
|
override def SetupNumberPools() = {}
|
|
|
|
|
}
|
|
|
|
|
val player = Player(Avatar(8, "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5))
|
2020-08-25 15:24:26 -04:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
2018-03-24 00:28:02 -04:00
|
|
|
//player.Release !!important
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-03-24 00:28:02 -04:00
|
|
|
|
|
|
|
|
assert(zone.Corpses.isEmpty)
|
|
|
|
|
zone.Population ! Zone.Corpse.Add(player)
|
2020-06-10 09:23:52 -04:00
|
|
|
expectNoMessage(Duration.create(200, "ms"))
|
2018-03-24 00:28:02 -04:00
|
|
|
assert(zone.Corpses.isEmpty)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
class ZoneGroundDropItemTest extends ActorTest {
|
2018-03-31 19:31:17 -04:00
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10)
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"DropItem" should {
|
2018-03-31 19:31:17 -04:00
|
|
|
"drop item on ground" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
2018-05-22 19:13:59 -04:00
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3(1.1f, 2.2f, 3.3f), Vector3(4.4f, 5.5f, 6.6f))
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
val reply = receiveOne(200 milliseconds)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Ground.ItemOnGround])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.ItemOnGround].item == item)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.ItemOnGround].pos == Vector3(1.1f, 2.2f, 3.3f))
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.ItemOnGround].orient == Vector3(4.4f, 5.5f, 6.6f))
|
|
|
|
|
assert(zone.EquipmentOnGround.contains(item))
|
2018-03-31 19:31:17 -04:00
|
|
|
}
|
2018-05-27 02:24:20 -04:00
|
|
|
}
|
|
|
|
|
}
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
class ZoneGroundCanNotDropItem1Test extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
//hub.register(item, 10) //!important
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"DropItem" should {
|
|
|
|
|
"not drop an item that is not registered" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
2018-05-22 19:13:59 -04:00
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
val reply = receiveOne(300 milliseconds)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Ground.CanNotDropItem])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].item == item)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].zone == zone)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].reason == "not registered yet")
|
|
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ZoneGroundCanNotDropItem2Test extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10) //!important
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
//zone.GUID(hub) //!important
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"DropItem" should {
|
|
|
|
|
"not drop an item that is not registered to the zone" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
|
|
|
|
|
|
|
|
|
val reply = receiveOne(300 milliseconds)
|
|
|
|
|
assert(reply.isInstanceOf[Zone.Ground.CanNotDropItem])
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].item == item)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].zone == zone)
|
|
|
|
|
assert(reply.asInstanceOf[Zone.Ground.CanNotDropItem].reason == "registered to some other zone")
|
|
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
class ZoneGroundCanNotDropItem3Test extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10) //!important
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub) //!important
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"DropItem" should {
|
|
|
|
|
"not drop an item that has already been dropped" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
2018-03-31 19:31:17 -04:00
|
|
|
assert(zone.EquipmentOnGround.isEmpty)
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
|
|
|
|
|
|
|
|
|
val reply1 = receiveOne(300 milliseconds)
|
|
|
|
|
assert(reply1.isInstanceOf[Zone.Ground.ItemOnGround])
|
|
|
|
|
assert(reply1.asInstanceOf[Zone.Ground.ItemOnGround].item == item)
|
|
|
|
|
assert(zone.EquipmentOnGround.contains(item))
|
|
|
|
|
assert(zone.EquipmentOnGround.size == 1)
|
|
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
|
|
|
|
|
|
|
|
|
val reply2 = receiveOne(300 milliseconds)
|
|
|
|
|
assert(reply2.isInstanceOf[Zone.Ground.CanNotDropItem])
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotDropItem].item == item)
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotDropItem].zone == zone)
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotDropItem].reason == "already dropped")
|
|
|
|
|
assert(zone.EquipmentOnGround.size == 1)
|
2018-03-31 19:31:17 -04:00
|
|
|
}
|
2018-05-27 02:24:20 -04:00
|
|
|
}
|
|
|
|
|
}
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
class ZoneGroundPickupItemTest extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10)
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub)
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"PickupItem" should {
|
|
|
|
|
"pickup an item from ground" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
2018-05-22 19:13:59 -04:00
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
2018-03-31 19:31:17 -04:00
|
|
|
|
2018-05-27 02:24:20 -04:00
|
|
|
val reply1 = receiveOne(200 milliseconds)
|
|
|
|
|
assert(reply1.isInstanceOf[Zone.Ground.ItemOnGround])
|
|
|
|
|
assert(zone.EquipmentOnGround.contains(item))
|
|
|
|
|
zone.Ground ! Zone.Ground.PickupItem(item.GUID)
|
|
|
|
|
|
|
|
|
|
val reply2 = receiveOne(200 milliseconds)
|
|
|
|
|
assert(reply2.isInstanceOf[Zone.Ground.ItemInHand])
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.ItemInHand].item == item)
|
|
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ZoneGroundCanNotPickupItemTest extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10)
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub) //still registered to this zone
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"PickupItem" should {
|
|
|
|
|
"not pickup an item if it can not be found" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second) //consume
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
zone.Ground ! Zone.Ground.PickupItem(item.GUID)
|
|
|
|
|
|
|
|
|
|
val reply2 = receiveOne(200 milliseconds)
|
|
|
|
|
assert(reply2.isInstanceOf[Zone.Ground.CanNotPickupItem])
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotPickupItem].item_guid == item.GUID)
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotPickupItem].zone == zone)
|
|
|
|
|
assert(reply2.asInstanceOf[Zone.Ground.CanNotPickupItem].reason == "can not find")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ZoneGroundRemoveItemTest extends ActorTest {
|
|
|
|
|
val item = AmmoBox(GlobalDefinitions.bullet_9mm)
|
2020-09-15 19:46:56 -04:00
|
|
|
val hub = new NumberPoolHub(new MaxNumberSource(20))
|
2018-05-27 02:24:20 -04:00
|
|
|
hub.register(item, 10)
|
2020-07-14 05:54:05 +02:00
|
|
|
val zone = new Zone("test", new ZoneMap("test-map"), 0) { override def SetupNumberPools() = {} }
|
2018-05-27 02:24:20 -04:00
|
|
|
zone.GUID(hub) //still registered to this zone
|
2020-07-22 17:28:09 +02:00
|
|
|
zone.actor = system.spawn(ZoneActor(zone), ZoneTest.TestName)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(200 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
|
|
|
|
|
"RemoveItem" should {
|
|
|
|
|
"remove an item from the ground without callback (even if the item is not found)" in {
|
2018-05-28 09:04:09 -04:00
|
|
|
receiveOne(1 second)
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
zone.Ground ! Zone.Ground.DropItem(item, Vector3.Zero, Vector3.Zero)
|
|
|
|
|
receiveOne(200 milliseconds)
|
|
|
|
|
assert(zone.EquipmentOnGround.contains(item)) //dropped
|
|
|
|
|
|
|
|
|
|
zone.Ground ! Zone.Ground.RemoveItem(item.GUID)
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(500 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
|
|
|
|
|
|
|
|
|
zone.Ground ! Zone.Ground.RemoveItem(item.GUID) //repeat
|
2020-05-26 19:50:54 -04:00
|
|
|
expectNoMessage(500 milliseconds)
|
2018-05-27 02:24:20 -04:00
|
|
|
assert(!zone.EquipmentOnGround.contains(item))
|
2018-03-31 19:31:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-24 00:28:02 -04:00
|
|
|
object ZoneTest {
|
2020-07-14 05:54:05 +02:00
|
|
|
val testNum = new AtomicInteger(1)
|
|
|
|
|
def TestName: String = s"test${testNum.getAndIncrement()}"
|
2018-03-24 00:28:02 -04:00
|
|
|
}
|