mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-26 07:19:09 +00:00
* functions for certifcation ui updates (that don't work) * initialization of combat engineering deployables ui on load and certification change * representation classes for ACE and FDU; ability to pull ACE and FDU from equipment terminals * ammo change functionality and fire mode change functionality for ConstructionItems refactored from Tool operations and supported properly (switch between deployable options) * zone-specific structure for keeping track of deployables; abaility to dismiss deployables from the map screen (previous functionality); local client creation of explosive-type deployables * refactored MannedTurret into FacilityTurret and lesser traits to be used in the deployable spitfires and the OMFT's; all ACE deployables are available for placement; partial management of the construction items after the deployable is placed; boomers create boomer triggers * Avatar-specific storage for deployables and for updating UI elements * refactored quite a bit of code in WSA for the benefit of deployable management; refinements to deployable creation; server messages about deployable quantities; corrected the FDU encoding pattern; lots of work dedicated just to synchronizing BoomerTrigger objects * added RemoverActor for deployables and redistributed deconstruction functionality away from WSA to new DeployableRemover; added events to facilitate activities not inheritable with this model * refactored and distributed Deployables classes; copious amounts of testing and document-writing * boomers now explode from trigger; support for deployables being destroyed by weapon discharge, including individual health, soure identification, and damage model; shuffled deployable classes to build different hierarchy * sensor_shield was skipped by accident * identified stray object in Hanish, Ishundar, and added Irkalla, Ishundar's capture console; fixed issue with Warp command and 'Irkalla'; modified building amenity setup and setup testing in Zone; players load and die properly when seated in an omft; reserve ammunition in omft properly registered * added local service channel, capture consoles, fixed tests as much as posible * fixed LocalService tests by booting the ServiceManager; added avatar and local tests * a simple attempt to refactor Actor messages in a way that is acceptable to Travis CI * making the explosive deployables vanish upon explosion; sensor health bars are now supported
179 lines
6.2 KiB
Scala
179 lines
6.2 KiB
Scala
// Copyright (c) 2017 PSForever
|
|
package objects
|
|
|
|
import akka.actor.{ActorRef, Props}
|
|
import base.ActorTest
|
|
import net.psforever.objects.{Avatar, GlobalDefinitions, Player, Tool}
|
|
import net.psforever.objects.definition.ToolDefinition
|
|
import net.psforever.objects.serverobject.mount.Mountable
|
|
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
|
import net.psforever.objects.serverobject.turret._
|
|
import net.psforever.objects.zones.Zone
|
|
import net.psforever.packet.game.PlanetSideGUID
|
|
import net.psforever.types.{CharacterGender, CharacterVoice, PlanetSideEmpire}
|
|
import org.specs2.mutable.Specification
|
|
|
|
import scala.collection.mutable
|
|
import scala.concurrent.duration._
|
|
|
|
class FacilityTurretTest extends Specification {
|
|
"FacilityTurretTest" should {
|
|
"define" in {
|
|
val obj = new TurretDefinition(480)
|
|
obj.Weapons mustEqual mutable.HashMap.empty[TurretUpgrade.Value, ToolDefinition]
|
|
obj.ReserveAmmunition mustEqual false
|
|
obj.FactionLocked mustEqual true
|
|
obj.MaxHealth mustEqual 100
|
|
obj.MountPoints mustEqual mutable.HashMap.empty[Int,Int]
|
|
}
|
|
|
|
"construct" in {
|
|
val obj = FacilityTurret(GlobalDefinitions.manned_turret)
|
|
obj.Weapons.size mustEqual 1
|
|
obj.Weapons(1).Equipment match {
|
|
case Some(tool : Tool) =>
|
|
tool.Definition mustEqual GlobalDefinitions.phalanx_sgl_hevgatcan
|
|
case _ =>
|
|
ko
|
|
}
|
|
obj.Seats.size mustEqual 1
|
|
obj.Seats(0).ControlledWeapon mustEqual Some(1)
|
|
obj.MountPoints.size mustEqual 1
|
|
obj.MountPoints(1) mustEqual 0
|
|
obj.Health mustEqual 3600
|
|
obj.Upgrade mustEqual TurretUpgrade.None
|
|
obj.Jammered mustEqual false
|
|
|
|
obj.Health = 360
|
|
obj.Health mustEqual 360
|
|
obj.Jammered = true
|
|
obj.Jammered mustEqual true
|
|
}
|
|
|
|
"upgrade to a different weapon" in {
|
|
val obj = FacilityTurret(GlobalDefinitions.manned_turret)
|
|
obj.Upgrade = TurretUpgrade.None
|
|
obj.Weapons(1).Equipment match {
|
|
case Some(tool : Tool) =>
|
|
tool.Definition mustEqual GlobalDefinitions.phalanx_sgl_hevgatcan
|
|
tool.FireModeIndex mustEqual 0
|
|
tool.NextFireMode
|
|
tool.FireModeIndex mustEqual 0 //one fire mode
|
|
case _ =>
|
|
ko
|
|
}
|
|
//upgrade
|
|
obj.Upgrade = TurretUpgrade.AVCombo
|
|
obj.Weapons(1).Equipment match {
|
|
case Some(tool : Tool) =>
|
|
tool.Definition mustEqual GlobalDefinitions.phalanx_avcombo
|
|
tool.FireModeIndex mustEqual 0
|
|
tool.ProjectileType mustEqual GlobalDefinitions.phalanx_projectile.ProjectileType
|
|
tool.NextFireMode
|
|
tool.FireModeIndex mustEqual 1
|
|
tool.ProjectileType mustEqual GlobalDefinitions.phalanx_av_projectile.ProjectileType
|
|
case _ =>
|
|
ko
|
|
}
|
|
//revert
|
|
obj.Upgrade = TurretUpgrade.None
|
|
obj.Weapons(1).Equipment match {
|
|
case Some(tool : Tool) =>
|
|
tool.Definition mustEqual GlobalDefinitions.phalanx_sgl_hevgatcan
|
|
case _ =>
|
|
ko
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class FacilityTurretControl1Test extends ActorTest {
|
|
"FacilityTurretControl" should {
|
|
"construct" in {
|
|
val obj = FacilityTurret(GlobalDefinitions.manned_turret)
|
|
obj.Actor = system.actorOf(Props(classOf[FacilityTurretControl], obj), "turret-control")
|
|
assert(obj.Actor != ActorRef.noSender)
|
|
}
|
|
}
|
|
}
|
|
|
|
class FacilityTurretControl2Test extends ActorTest {
|
|
val player = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
|
val obj = FacilityTurret(GlobalDefinitions.manned_turret)
|
|
obj.GUID = PlanetSideGUID(1)
|
|
obj.Actor = system.actorOf(Props(classOf[FacilityTurretControl], obj), "turret-control")
|
|
val bldg = Building(0, Zone.Nowhere, StructureType.Building)
|
|
bldg.Amenities = obj
|
|
bldg.Faction = PlanetSideEmpire.TR
|
|
|
|
"FacilityTurretControl" should {
|
|
"seat on faction affiliation when FactionLock is true" in {
|
|
assert(player.Faction == PlanetSideEmpire.TR)
|
|
assert(obj.Faction == PlanetSideEmpire.TR)
|
|
assert(obj.Definition.FactionLocked)
|
|
|
|
obj.Actor ! Mountable.TryMount(player, 0)
|
|
val reply = receiveOne(300 milliseconds)
|
|
reply match {
|
|
case msg : Mountable.MountMessages =>
|
|
assert(msg.response.isInstanceOf[Mountable.CanMount])
|
|
case _ =>
|
|
assert(false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class FacilityTurretControl3Test extends ActorTest {
|
|
val player = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
|
val obj = FacilityTurret(GlobalDefinitions.manned_turret)
|
|
obj.GUID = PlanetSideGUID(1)
|
|
obj.Actor = system.actorOf(Props(classOf[FacilityTurretControl], obj), "turret-control")
|
|
val bldg = Building(0, Zone.Nowhere, StructureType.Building)
|
|
bldg.Amenities = obj
|
|
|
|
"FacilityTurretControl" should {
|
|
"block seating on mismatched faction affiliation when FactionLock is true" in {
|
|
assert(player.Faction == PlanetSideEmpire.TR)
|
|
assert(obj.Faction == PlanetSideEmpire.NEUTRAL)
|
|
assert(obj.Definition.FactionLocked)
|
|
|
|
obj.Actor ! Mountable.TryMount(player, 0)
|
|
val reply = receiveOne(300 milliseconds)
|
|
reply match {
|
|
case msg : Mountable.MountMessages =>
|
|
assert(msg.response.isInstanceOf[Mountable.CanNotMount])
|
|
case _ =>
|
|
assert(false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class FacilityTurretControl4Test extends ActorTest {
|
|
val player = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Mute))
|
|
val objDef = new TurretDefinition(480)
|
|
objDef.FactionLocked = false
|
|
val obj = FacilityTurret(objDef)
|
|
obj.GUID = PlanetSideGUID(1)
|
|
obj.Actor = system.actorOf(Props(classOf[FacilityTurretControl], obj), "turret-control")
|
|
val bldg = Building(0, Zone.Nowhere, StructureType.Building)
|
|
bldg.Amenities = obj
|
|
|
|
"FacilityTurretControl" should {
|
|
"seating even with mismatched faction affiliation when FactionLock is false" in {
|
|
assert(player.Faction == PlanetSideEmpire.TR)
|
|
assert(obj.Faction == PlanetSideEmpire.NEUTRAL)
|
|
assert(!obj.Definition.FactionLocked)
|
|
|
|
obj.Actor ! Mountable.TryMount(player, 0)
|
|
val reply = receiveOne(300 milliseconds)
|
|
reply match {
|
|
case msg : Mountable.MountMessages =>
|
|
assert(msg.response.isInstanceOf[Mountable.CanMount])
|
|
case _ =>
|
|
assert(false)
|
|
}
|
|
}
|
|
}
|
|
}
|