mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-21 07:33:34 +00:00
Operational vehicle terminals:
Vehicles can now be pulled from assigned and initialized terminals. The vehicle's chosen spawn pad controls (or paces) all aspects of the spawning process. Support Actors ensure that a fully-realized Vehicle will be unloaded and unregistered if left alone, either right after spawning on the pad or after an extended period of time. The latter half of the procedure used for spawning vehicles is a temporary workaround until future analysis and functionality of the server vehicle override packet is incorporated. Weapons: Weapons will now construct their own default magazines thanks to a switch from Ammo.Value to AmmoBoxDefinition in the ToolDefinition. GenericObjectActionMessage : The only thing this packet does, at the moment, is obscure the player when he is being promoted into the owner of a vehicle.
This commit is contained in:
parent
73d0553b2c
commit
5428bbbfbf
57 changed files with 2957 additions and 538 deletions
68
common/src/test/scala/Vector3Test.scala
Normal file
68
common/src/test/scala/Vector3Test.scala
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
class Vector3Test extends Specification {
|
||||
val vec = Vector3(1.3f, -2.6f, 3.9f)
|
||||
|
||||
"Vector3" should {
|
||||
"construct" in {
|
||||
vec.x mustEqual 1.3f
|
||||
vec.y mustEqual -2.6f
|
||||
vec.z mustEqual 3.9f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 1" in {
|
||||
val obj = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Magnitude(obj) mustEqual 2.0f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 2" in {
|
||||
val obj = Vector3(3.0f, 4.0f, 0.0f)
|
||||
Vector3.Magnitude(obj) mustEqual 5.0f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 3" in {
|
||||
Vector3.Magnitude(vec) mustEqual 4.864155f
|
||||
}
|
||||
|
||||
"calculate square magnitude (like a vector)" in {
|
||||
Vector3.MagnitudeSquared(vec) mustEqual 23.66f
|
||||
}
|
||||
|
||||
"calculate distance 1" in {
|
||||
val obj1 = Vector3(0.0f, 0.0f, 0.0f)
|
||||
val obj2 = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual 2.0f
|
||||
}
|
||||
|
||||
"calculate distance 2" in {
|
||||
val obj1 = Vector3(0.0f, 0.0f, 0.0f)
|
||||
val obj2 = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual Vector3.Magnitude(obj2)
|
||||
}
|
||||
|
||||
"calculate distance 3" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual 0f
|
||||
}
|
||||
|
||||
"addition" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
obj1 + obj2 mustEqual Vector3(6f, 8f, 10f)
|
||||
}
|
||||
|
||||
"subtraction" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
obj1 - obj2 mustEqual Vector3(0f, 0f, 0f)
|
||||
}
|
||||
|
||||
"scalar" in {
|
||||
vec * 3f mustEqual Vector3(3.8999999f, -7.7999997f, 11.700001f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class GenericObjectActionMessageTest extends Specification {
|
||||
val string = hex"56 B501 24"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case GenericObjectActionMessage(object_guid, action) =>
|
||||
object_guid mustEqual PlanetSideGUID(437)
|
||||
action mustEqual 36
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = GenericObjectActionMessage(PlanetSideGUID(437), 36)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
@ -40,16 +40,15 @@ class ConverterTest extends Specification {
|
|||
"convert to packet" in {
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoTypeIndices += 1
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
tdef.FireModes.head.Magazine = 30
|
||||
val obj : Tool = Tool(tdef)
|
||||
val box = AmmoBox(PlanetSideGUID(90), new AmmoBoxDefinition(Ammo.shotgun_shell.id))
|
||||
obj.AmmoSlots.head.Box = box
|
||||
obj.AmmoSlots.head.Magazine = 30
|
||||
obj.AmmoSlot.Box.GUID = PlanetSideGUID(90)
|
||||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
|
|
@ -139,24 +138,22 @@ class ConverterTest extends Specification {
|
|||
Give the Player's Holster (2) the Tool
|
||||
Place the remaining AmmoBox into the Player's inventory in the third slot (8)
|
||||
*/
|
||||
val bullet_9mm = AmmoBoxDefinition(28)
|
||||
bullet_9mm.Capacity = 50
|
||||
val box1 = AmmoBox(PlanetSideGUID(90), bullet_9mm)
|
||||
val box2 = AmmoBox(PlanetSideGUID(91), bullet_9mm)
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Name = "sample_weapon"
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.bullet_9mm
|
||||
tdef.AmmoTypes += GlobalDefinitions.bullet_9mm
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
tdef.FireModes.head.Magazine = 18
|
||||
val tool = Tool(PlanetSideGUID(92), tdef)
|
||||
tool.AmmoSlots.head.Box = box1
|
||||
val tool = Tool(tdef)
|
||||
tool.GUID = PlanetSideGUID(92)
|
||||
tool.AmmoSlot.Box.GUID = PlanetSideGUID(90)
|
||||
val obj = Player(PlanetSideGUID(93), "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, 5)
|
||||
obj.Slot(2).Equipment = tool
|
||||
obj.Slot(5).Equipment.get.GUID = PlanetSideGUID(94)
|
||||
obj.Inventory += 8 -> box2
|
||||
obj.Inventory += 8 -> AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
obj.Slot(8).Equipment.get.GUID = PlanetSideGUID(91)
|
||||
obj
|
||||
}
|
||||
val converter = new CharacterSelectConverter
|
||||
|
|
@ -263,7 +260,7 @@ class ConverterTest extends Specification {
|
|||
|
||||
val fury_weapon_systema_def = ToolDefinition(ObjectClass.fury_weapon_systema)
|
||||
fury_weapon_systema_def.Size = EquipmentSize.VehicleWeapon
|
||||
fury_weapon_systema_def.AmmoTypes += Ammo.hellfire_ammo
|
||||
fury_weapon_systema_def.AmmoTypes += GlobalDefinitions.hellfire_ammo
|
||||
fury_weapon_systema_def.FireModes += new FireModeDefinition
|
||||
fury_weapon_systema_def.FireModes.head.AmmoTypeIndices += 0
|
||||
fury_weapon_systema_def.FireModes.head.AmmoSlotIndex = 0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import net.psforever.objects.GlobalDefinitions._
|
|||
import org.specs2.mutable._
|
||||
|
||||
class EquipmentTest extends Specification {
|
||||
|
||||
"AmmoBox" should {
|
||||
"define" in {
|
||||
val obj = AmmoBoxDefinition(86)
|
||||
|
|
@ -19,8 +18,8 @@ class EquipmentTest extends Specification {
|
|||
|
||||
obj.AmmoType mustEqual Ammo.aphelion_immolation_cannon_ammo
|
||||
obj.Capacity mustEqual 300
|
||||
obj.Tile.width mustEqual InventoryTile.Tile44.width
|
||||
obj.Tile.height mustEqual InventoryTile.Tile44.height
|
||||
obj.Tile.Width mustEqual InventoryTile.Tile44.Width
|
||||
obj.Tile.Height mustEqual InventoryTile.Tile44.Height
|
||||
obj.ObjectId mustEqual 86
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +57,8 @@ class EquipmentTest extends Specification {
|
|||
val obj = ToolDefinition(1076)
|
||||
obj.Name = "sample_weapon"
|
||||
obj.Size = EquipmentSize.Rifle
|
||||
obj.AmmoTypes += Ammo.shotgun_shell
|
||||
obj.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
obj.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
obj.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
obj.FireModes += new FireModeDefinition
|
||||
obj.FireModes.head.AmmoTypeIndices += 0
|
||||
obj.FireModes.head.AmmoTypeIndices += 1
|
||||
|
|
@ -74,9 +73,10 @@ class EquipmentTest extends Specification {
|
|||
obj.FireModes(1).Magazine = 18
|
||||
obj.Tile = InventoryTile.Tile93
|
||||
obj.ObjectId mustEqual 1076
|
||||
|
||||
obj.Name mustEqual "sample_weapon"
|
||||
obj.AmmoTypes.head mustEqual Ammo.shotgun_shell
|
||||
obj.AmmoTypes(1) mustEqual Ammo.shotgun_shell_AP
|
||||
obj.AmmoTypes.head mustEqual GlobalDefinitions.shotgun_shell
|
||||
obj.AmmoTypes(1) mustEqual GlobalDefinitions.shotgun_shell_AP
|
||||
obj.FireModes.head.AmmoTypeIndices.head mustEqual 0
|
||||
obj.FireModes.head.AmmoTypeIndices(1) mustEqual 1
|
||||
obj.FireModes.head.AmmoSlotIndex mustEqual 0
|
||||
|
|
@ -89,8 +89,8 @@ class EquipmentTest extends Specification {
|
|||
obj.FireModes(1).Chamber mustEqual 3
|
||||
obj.FireModes(1).Magazine mustEqual 18
|
||||
obj.FireModes(1).ResetAmmoIndexOnSwap mustEqual false
|
||||
obj.Tile.width mustEqual InventoryTile.Tile93.width
|
||||
obj.Tile.height mustEqual InventoryTile.Tile93.height
|
||||
obj.Tile.Width mustEqual InventoryTile.Tile93.Width
|
||||
obj.Tile.Height mustEqual InventoryTile.Tile93.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
@ -118,8 +118,8 @@ class EquipmentTest extends Specification {
|
|||
//explanation: sample_weapon has two fire modes; adjusting the FireMode changes between them
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
|
|
@ -149,8 +149,8 @@ class EquipmentTest extends Specification {
|
|||
//explanation: obj has one fire mode and two ammunitions; adjusting the AmmoType changes between them
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoTypeIndices += 1
|
||||
|
|
@ -168,14 +168,54 @@ class EquipmentTest extends Specification {
|
|||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.shotgun_shell
|
||||
}
|
||||
|
||||
"multiple ammo types and multiple fire modes, split (Punisher)" in {
|
||||
val obj = Tool(GlobalDefinitions.punisher)
|
||||
//ammo = 0, fmode = 0
|
||||
obj.FireModeIndex mustEqual 0
|
||||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm
|
||||
//ammo = 2, fmode = 1
|
||||
obj.NextFireMode
|
||||
obj.FireModeIndex mustEqual 1
|
||||
obj.AmmoTypeIndex mustEqual 2
|
||||
obj.AmmoType mustEqual Ammo.rocket
|
||||
//ammo = 3, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 3
|
||||
obj.AmmoType mustEqual Ammo.frag_cartridge
|
||||
//ammo = 4, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 4
|
||||
obj.AmmoType mustEqual Ammo.jammer_cartridge
|
||||
//ammo = 0, fmode = 0
|
||||
obj.NextFireMode
|
||||
obj.FireModeIndex mustEqual 0
|
||||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm
|
||||
//ammo = 1, fmode = 0
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 1
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm_AP
|
||||
//ammo = 5, fmode = 1
|
||||
obj.NextFireMode
|
||||
obj.NextAmmoType
|
||||
obj.FireModeIndex mustEqual 1
|
||||
obj.AmmoTypeIndex mustEqual 5
|
||||
obj.AmmoType mustEqual Ammo.plasma_cartridge
|
||||
//ammo = 2, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 2
|
||||
obj.AmmoType mustEqual Ammo.rocket
|
||||
}
|
||||
}
|
||||
|
||||
"Kit" should {
|
||||
"define" in {
|
||||
val sample = KitDefinition(Kits.medkit)
|
||||
sample.ObjectId mustEqual medkit.ObjectId
|
||||
sample.Tile.width mustEqual medkit.Tile.width
|
||||
sample.Tile.height mustEqual medkit.Tile.height
|
||||
sample.Tile.Width mustEqual medkit.Tile.Width
|
||||
sample.Tile.Height mustEqual medkit.Tile.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
@ -200,8 +240,8 @@ class EquipmentTest extends Specification {
|
|||
sample.Modes.head mustEqual DeployedItem.tank_traps
|
||||
sample.Modes(1) mustEqual DeployedItem.portable_manned_turret_tr
|
||||
sample.Modes(2) mustEqual DeployedItem.deployable_shield_generator
|
||||
sample.Tile.width mustEqual InventoryTile.Tile63.width
|
||||
sample.Tile.height mustEqual InventoryTile.Tile63.height
|
||||
sample.Tile.Width mustEqual InventoryTile.Tile63.Width
|
||||
sample.Tile.Height mustEqual InventoryTile.Tile63.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 0 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -91,8 +91,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 3 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(3, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -125,8 +125,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 0 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -159,8 +159,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 27 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(27, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -205,8 +205,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(12, 9)
|
||||
obj += 39 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 99 //108 - 9
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.isEmpty mustEqual true
|
||||
|
|
|
|||
110
common/src/test/scala/objects/VehicleSpawnPadTest.scala
Normal file
110
common/src/test/scala/objects/VehicleSpawnPadTest.scala
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import net.psforever.objects.serverobject.pad.{VehicleSpawnControl, VehicleSpawnPad}
|
||||
import net.psforever.objects.vehicles.VehicleControl
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
class VehicleSpawnPadTest extends Specification {
|
||||
"VehicleSpawnPadDefinition" should {
|
||||
"define" in {
|
||||
GlobalDefinitions.spawn_pad.ObjectId mustEqual 800
|
||||
}
|
||||
}
|
||||
|
||||
"VehicleSpawnPad" should {
|
||||
"construct" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor mustEqual ActorRef.noSender
|
||||
obj.Definition mustEqual GlobalDefinitions.spawn_pad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl1Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"construct" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
assert(obj.Actor != ActorRef.noSender)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl2Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"spawn a vehicle" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
player.Spawn
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Actor = system.actorOf(Props(classOf[VehicleControl], vehicle), "vehicle")
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply == VehicleSpawnPad.ConcealPlayer) //explicit: isInstanceOf does not work
|
||||
|
||||
val reply2 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
assert(reply2.asInstanceOf[VehicleSpawnPad.LoadVehicle].vehicle == vehicle)
|
||||
assert(reply2.asInstanceOf[VehicleSpawnPad.LoadVehicle].pad == obj)
|
||||
|
||||
player.VehicleOwned = vehicle
|
||||
val reply3 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply3.isInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle])
|
||||
assert(reply3.asInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle].vehicle == vehicle)
|
||||
|
||||
val reply4 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply4.isInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning])
|
||||
assert(reply4.asInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning].vehicle == vehicle)
|
||||
assert(reply4.asInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning].warning_count > 0)
|
||||
|
||||
vehicle.Position = Vector3(11f, 0f, 0f) //greater than 10m
|
||||
val reply5 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply5.isInstanceOf[VehicleSpawnPad.SpawnPadUnblocked])
|
||||
assert(reply5.asInstanceOf[VehicleSpawnPad.SpawnPadUnblocked].vehicle_guid == vehicle.GUID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl3Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"not spawn a vehicle if player is dead" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Actor = system.actorOf(Props(classOf[VehicleControl], vehicle), "vehicle")
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(5000, "ms"))
|
||||
assert(reply == null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl4Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"not spawn a vehicle if vehicle Actor is missing" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
player.Spawn
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(5000, "ms"))
|
||||
assert(reply == null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,8 +44,8 @@ class VehicleTest extends Specification {
|
|||
fury.Weapons.size mustEqual 1
|
||||
fury.Weapons.get(0) mustEqual None
|
||||
fury.Weapons.get(1) mustEqual Some(GlobalDefinitions.fury_weapon_systema)
|
||||
fury.TrunkSize.width mustEqual 11
|
||||
fury.TrunkSize.height mustEqual 11
|
||||
fury.TrunkSize.Width mustEqual 11
|
||||
fury.TrunkSize.Height mustEqual 11
|
||||
fury.TrunkOffset mustEqual 30
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Tool}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class AirVehicleTerminalTest extends Specification {
|
||||
"Air_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a reaver ('lightgunship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('reaver')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "reaver", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class DropshipVehicleTerminalTest extends Specification {
|
||||
"Dropship_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a galaxy ('dropship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "dropship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.dropship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('galaxy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "galaxy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class GroundVehicleTerminalTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a harasser ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,3 +71,40 @@ class CertTerminalControl3Test extends ActorTest() {
|
|||
assert(reply2.response == Terminal.SellCertification(CertificationType.MediumAssault, 2))
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleTerminalControl1Test extends ActorTest() {
|
||||
"TerminalControl can be used to buy a vehicle ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor = system.actorOf(Props(classOf[TerminalControl], terminal), "test-cert-term")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Actor ! Terminal.Request(player, msg)
|
||||
val reply = receiveOne(Duration.create(500, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal.TerminalMessage])
|
||||
val reply2 = reply.asInstanceOf[Terminal.TerminalMessage]
|
||||
assert(reply2.player == player)
|
||||
assert(reply2.msg == msg)
|
||||
assert(reply2.response.isInstanceOf[Terminal.BuyVehicle])
|
||||
val reply3 = reply2.response.asInstanceOf[Terminal.BuyVehicle]
|
||||
assert(reply3.vehicle.Definition == GlobalDefinitions.two_man_assault_buggy)
|
||||
assert(reply3.loadout == Nil) //TODO
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleTerminalControl2Test extends ActorTest() {
|
||||
"TerminalControl can be used to warn about not buy a vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor = system.actorOf(Props(classOf[TerminalControl], terminal), "test-cert-term")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Actor ! Terminal.Request(player, msg)
|
||||
val reply = receiveOne(Duration.create(500, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal.TerminalMessage])
|
||||
val reply2 = reply.asInstanceOf[Terminal.TerminalMessage]
|
||||
assert(reply2.player == player)
|
||||
assert(reply2.msg == msg)
|
||||
assert(reply2.response == Terminal.NoDeal())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class VehicleTerminalCombinedTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a ground vehicle, the harasser ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can buy a flying vehicle, the reaver ('lightgunship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue