PSF-LoginServer/src/test/scala/objects/ExoSuitTest.scala

211 lines
7.7 KiB
Scala
Raw Normal View History

// Copyright (c) 2017 PSForever
package objects
ObjectCreateMessage Alterations, Class Object Adjustments (#243) * power outage failure resulting in the destruction of the original ocm-fixes branch; the git branch refs were corrupted during commit, but the up-to-date changed files remained intact * eliminating the need for CommonFieldData2 and CommonFieldData2WithPlacement * in the middle of integrating CommonFieldData into DetailedLockerContainerData (but not standard LockerContainerData); added field for final boolean in WeaponData * adding faction affinity to Equipment (to match functionality; not becuase I know what ends ...) * in the middle of integrating CommonFieldData into DetailedCommandDetonaterData * applying faction affinity to objects at time of terminal production (but to what ends?); required BoomerTrigger and AmmoBox to always report as NEUTRAL internally * completed the transition from using the old class-based order terminal system to the page-based order terminal system; unused terminal classes have been eliminated * more closely aligned TelepadDeployableData and InternalTelepadDeployableData * modifying TelepadDeployableData make it generic and eliminate the need for InternalTelepadDeployableData after fixing a packet converter to utilize DroppedItemData * modified Terminal operation to branch further outwards from Terminal.Request to the TerminalDefinition's Request method; modified tests to reflect update * loosening up matrix terminal definition limitations * modified ProximityTerminal to support a custom defintition class * rendered the message passing system for Terminals general (Any) in the full scale so it can be specific in instance cases * refactored and moved both EquipmentSlot and ExoSuitDefinition * (re)load Favorites each time player (re)spawns
2019-03-03 08:23:30 -05:00
import net.psforever.objects.definition.{ExoSuitDefinition, SpecialExoSuitDefinition}
import net.psforever.objects.equipment._
import net.psforever.objects.inventory.InventoryTile
import net.psforever.types.{ExoSuitType, PlanetSideEmpire}
import org.specs2.mutable._
class ExoSuitTest extends Specification {
"ExoSuitDefinition" should {
"construct" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.MaxArmor mustEqual 0
obj.InventoryScale mustEqual InventoryTile.Tile11
obj.InventoryOffset mustEqual 0
obj.SuitType mustEqual ExoSuitType.Standard
obj.Holsters.length mustEqual 5
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
obj.Holsters.foreach(slot => { if (slot != EquipmentSize.Blocked) { ko } })
ok
}
"produce the type of exo-suit that was provided as a clarified type" in {
ExoSuitDefinition(ExoSuitType.Standard).SuitType mustEqual ExoSuitType.Standard
ExoSuitDefinition(ExoSuitType.Agile).SuitType mustEqual ExoSuitType.Agile
}
"change the maximum armor value" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.MaxArmor mustEqual 0
obj.MaxArmor = 1
obj.MaxArmor mustEqual 1
}
"not change the maximum armor to an invalid value" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.MaxArmor mustEqual 0
obj.MaxArmor = -1
obj.MaxArmor mustEqual 0
obj.MaxArmor = 65536
obj.MaxArmor mustEqual 65535
}
"change the size of the inventory" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.InventoryScale mustEqual InventoryTile.Tile11
obj.InventoryScale = InventoryTile.Tile42
obj.InventoryScale mustEqual InventoryTile.Tile42
}
"change the start index of the inventory" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.InventoryOffset mustEqual 0
obj.InventoryOffset = 1
obj.InventoryOffset mustEqual 1
}
"not change the start index of the inventory to an invalid value" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.InventoryOffset mustEqual 0
obj.InventoryOffset = -1
obj.InventoryOffset mustEqual 0
obj.InventoryOffset = 65536
obj.InventoryOffset mustEqual 65535
}
"change specific holsters to specific values" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.Holster(0) mustEqual EquipmentSize.Blocked
obj.Holster(0, EquipmentSize.Pistol)
obj.Holster(0) mustEqual EquipmentSize.Pistol
obj.Holster(4) mustEqual EquipmentSize.Blocked
obj.Holster(4, EquipmentSize.Rifle)
obj.Holster(4) mustEqual EquipmentSize.Rifle
(0 to 4).foreach {
case 0 => obj.Holsters(0) mustEqual EquipmentSize.Pistol
case 4 => obj.Holsters(4) mustEqual EquipmentSize.Rifle
case x => obj.Holsters(x) mustEqual EquipmentSize.Blocked
}
ok
}
"can not change any slot that does not exist" in {
val obj = ExoSuitDefinition(ExoSuitType.Standard)
obj.Holster(9) mustEqual EquipmentSize.Blocked
obj.Holster(9, EquipmentSize.Pistol)
obj.Holster(9) mustEqual EquipmentSize.Blocked
}
"produce a copy of the definition" in {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
val obj = ExoSuitDefinition(ExoSuitType.Standard)
val obj2 = obj.Use
obj eq obj2
}
}
"SpecialExoSuitDefinition" should {
"construct" in {
val obj = SpecialExoSuitDefinition(ExoSuitType.Standard)
obj.MaxArmor mustEqual 0
obj.InventoryScale mustEqual InventoryTile.Tile11
obj.InventoryOffset mustEqual 0
obj.SuitType mustEqual ExoSuitType.Standard
obj.Holsters.length mustEqual 5
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
obj.Holsters.foreach(slot => { if (slot != EquipmentSize.Blocked) { ko } })
obj.UsingSpecial mustEqual SpecialExoSuitDefinition.Mode.Normal
}
"configure UsingSpecial to various values" in {
val obj = SpecialExoSuitDefinition(ExoSuitType.Standard)
obj.UsingSpecial = SpecialExoSuitDefinition.Mode.Anchored
obj.UsingSpecial mustEqual SpecialExoSuitDefinition.Mode.Anchored
obj.UsingSpecial = SpecialExoSuitDefinition.Mode.Overdrive
obj.UsingSpecial mustEqual SpecialExoSuitDefinition.Mode.Overdrive
obj.UsingSpecial = SpecialExoSuitDefinition.Mode.Shielded
obj.UsingSpecial mustEqual SpecialExoSuitDefinition.Mode.Shielded
obj.UsingSpecial = SpecialExoSuitDefinition.Mode.Normal
obj.UsingSpecial mustEqual SpecialExoSuitDefinition.Mode.Normal
}
"produce a separate copy of the definition" in {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
val obj = SpecialExoSuitDefinition(ExoSuitType.Standard)
val obj2 = obj.Use
obj ne obj2
}
}
"ExoSuitDefinition.Select" should {
"produce common, shared instances of exo suits" in {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
ExoSuitDefinition.Select(ExoSuitType.Standard, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Standard,
PlanetSideEmpire.VS
)
ExoSuitDefinition.Select(ExoSuitType.Agile, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Agile,
PlanetSideEmpire.VS
)
ExoSuitDefinition.Select(ExoSuitType.Reinforced, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Reinforced,
PlanetSideEmpire.VS
)
ExoSuitDefinition.Select(ExoSuitType.Infiltration, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Infiltration,
PlanetSideEmpire.VS
)
}
"produce common, shared instances of exo suits across factions" in {
Persistence #1 featuring quill (#508) * Add .scalafmt.conf * Adopt quill for database access * Removed postgresql-async * Refactored all instances of database access * Creating duplicate characters of the same account is no longer possible * Rewrote large parts of LoginSessionActor * Implement migrations * Move overrides into subdirectory * Make usernames case insensitive * Use LOWER(?) comparison instead of storing lowercased username * import scala.util.{Success, Failure} * Add config and joda-time dependencies * Add sbt-scalafmt * Use defaultWithAlign scalafmt preset * Format all * Add scalafix * Remove unused imports * Don't lowercase username when inserting * Update readme * Listen on worldserver.Hostname address * Remove database test on startup It could fail when the global thread pool is busy loading zone maps. Migrations run on the main thread and also serve the purpose of verifying the database configuration so it's fine to remove the test altogether. * Refactor chat message handlers, zones What started as a small change to how zones are stored turned into a pretty big effort of refactoring the chat message handler. The !hack command was removed, the /capturebase commandwas added. * Expose db ports in docker-compose.yml * Silence property override log * Rework configuration * Unify configuration using the typesafe.config library * Add configuration option for public address * Configuration is now loaded from application.conf rather than worldserver.ini * Refactor PsLogin and remove unnecessary logging * Move pslogin into net.psforever.pslogin namespace * Fix coverage
2020-07-14 05:54:05 +02:00
ExoSuitDefinition.Select(ExoSuitType.Standard, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Standard,
PlanetSideEmpire.TR
)
ExoSuitDefinition.Select(ExoSuitType.Standard, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Standard,
PlanetSideEmpire.NC
)
ExoSuitDefinition.Select(ExoSuitType.Agile, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Agile,
PlanetSideEmpire.TR
)
ExoSuitDefinition.Select(ExoSuitType.Agile, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Agile,
PlanetSideEmpire.NC
)
ExoSuitDefinition.Select(ExoSuitType.Reinforced, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Reinforced,
PlanetSideEmpire.TR
)
ExoSuitDefinition.Select(ExoSuitType.Reinforced, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Reinforced,
PlanetSideEmpire.NC
)
ExoSuitDefinition.Select(ExoSuitType.Infiltration, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Infiltration,
PlanetSideEmpire.TR
)
ExoSuitDefinition.Select(ExoSuitType.Infiltration, PlanetSideEmpire.VS) eq ExoSuitDefinition.Select(
ExoSuitType.Infiltration,
PlanetSideEmpire.NC
)
}
"can select max for TR" in {
val obj = ExoSuitDefinition.Select(ExoSuitType.MAX, PlanetSideEmpire.TR)
obj.isInstanceOf[SpecialExoSuitDefinition] mustEqual true
obj.MaxCapacitor mustEqual 300
}
"can select max for VS" in {
val obj = ExoSuitDefinition.Select(ExoSuitType.MAX, PlanetSideEmpire.VS)
obj.isInstanceOf[SpecialExoSuitDefinition] mustEqual true
obj.MaxCapacitor mustEqual 50
}
"can select max for NC" in {
val obj = ExoSuitDefinition.Select(ExoSuitType.MAX, PlanetSideEmpire.NC)
obj.isInstanceOf[SpecialExoSuitDefinition] mustEqual true
obj.MaxCapacitor mustEqual 400
}
"produces unique instances of the mechanized assault exo suit" in {
val obj = ExoSuitDefinition.Select(ExoSuitType.MAX, PlanetSideEmpire.VS)
obj ne ExoSuitDefinition.Select(ExoSuitType.MAX, PlanetSideEmpire.VS)
obj.isInstanceOf[SpecialExoSuitDefinition] mustEqual true
}
}
}