mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-20 23:23:35 +00:00
added utility filtering so that only valid indexed utilities are assigned GUIDs and are translated into OCM
This commit is contained in:
parent
860edf9a97
commit
62b2c54b67
7 changed files with 61 additions and 6 deletions
|
|
@ -298,7 +298,7 @@ class ConverterTest extends Specification {
|
|||
}
|
||||
|
||||
"Vehicle" should {
|
||||
"convert to packet" in {
|
||||
"convert to packet (1)" in {
|
||||
val hellfire_ammo = AmmoBoxDefinition(Ammo.hellfire_ammo.id)
|
||||
|
||||
val fury_weapon_systema_def = ToolDefinition(ObjectClass.fury_weapon_systema)
|
||||
|
|
@ -333,5 +333,16 @@ class ConverterTest extends Specification {
|
|||
fury.Definition.Packet.ConstructorData(fury).isSuccess mustEqual true
|
||||
ok //TODO write more of this test
|
||||
}
|
||||
|
||||
"convert to packet (2)" in {
|
||||
val
|
||||
ams = Vehicle(GlobalDefinitions.ams)
|
||||
ams.GUID = PlanetSideGUID(413)
|
||||
ams.Utilities(3)().GUID = PlanetSideGUID(414)
|
||||
ams.Utilities(4)().GUID = PlanetSideGUID(415)
|
||||
|
||||
ams.Definition.Packet.ConstructorData(ams).isSuccess mustEqual true
|
||||
ok //TODO write more of this test
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ class UtilityTest extends Specification {
|
|||
"Utility" should {
|
||||
"create an order_terminala object" in {
|
||||
val obj = Utility(UtilityType.order_terminala, UtilityTest.vehicle)
|
||||
obj.UtilType mustEqual UtilityType.order_terminala
|
||||
obj().isInstanceOf[Terminal] mustEqual true
|
||||
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 613
|
||||
obj().asInstanceOf[Terminal].Actor == ActorRef.noSender
|
||||
|
|
@ -21,6 +22,7 @@ class UtilityTest extends Specification {
|
|||
|
||||
"create an order_terminalb object" in {
|
||||
val obj = Utility(UtilityType.order_terminalb, UtilityTest.vehicle)
|
||||
obj.UtilType mustEqual UtilityType.order_terminalb
|
||||
obj().isInstanceOf[Terminal] mustEqual true
|
||||
obj().asInstanceOf[Terminal].Definition.ObjectId mustEqual 614
|
||||
obj().asInstanceOf[Terminal].Actor == ActorRef.noSender
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package objects
|
|||
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.objects.definition.SeatDefinition
|
||||
import net.psforever.objects.definition.{SeatDefinition, VehicleDefinition}
|
||||
import net.psforever.objects.serverobject.mount.Mountable
|
||||
import net.psforever.objects.vehicles._
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
|
@ -256,6 +256,26 @@ class VehicleTest extends Specification {
|
|||
harasser_vehicle.WeaponControlledFromSeat(0) mustEqual None
|
||||
harasser_vehicle.WeaponControlledFromSeat(1) mustEqual chaingun_p
|
||||
}
|
||||
|
||||
"can filter utilities with indices that are natural numbers" in {
|
||||
val objDef = VehicleDefinition(1)
|
||||
objDef.Utilities += -1 -> UtilityType.order_terminala
|
||||
objDef.Utilities += 0 -> UtilityType.order_terminalb
|
||||
objDef.Utilities += 2 -> UtilityType.order_terminalb
|
||||
val obj = Vehicle(objDef)
|
||||
|
||||
obj.Utilities.size mustEqual 3
|
||||
obj.Utilities(-1).UtilType mustEqual UtilityType.order_terminala
|
||||
obj.Utilities(0).UtilType mustEqual UtilityType.order_terminalb
|
||||
obj.Utilities.get(1) mustEqual None
|
||||
obj.Utilities(2).UtilType mustEqual UtilityType.order_terminalb
|
||||
|
||||
val filteredMap = Vehicle.EquipmentUtilities(obj.Utilities)
|
||||
filteredMap.size mustEqual 2
|
||||
filteredMap.get(-1) mustEqual None
|
||||
filteredMap(0).UtilType mustEqual UtilityType.order_terminalb
|
||||
filteredMap(2).UtilType mustEqual UtilityType.order_terminalb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue