PSF-LoginServer/common/src/test/scala/objects/EquipmentSlotTest.scala
Fate-JH 337cfbe5d2
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

148 lines
4 KiB
Scala

// Copyright (c) 2017 PSForever
package objects
import net.psforever.objects.{OffhandEquipmentSlot, Tool}
import net.psforever.objects.equipment.{EquipmentSize, EquipmentSlot}
import net.psforever.objects.GlobalDefinitions.{beamer, repeater, suppressor}
import org.specs2.mutable._
class EquipmentSlotTest extends Specification {
"EquipmentSlot" should {
"construct" in {
val obj = new EquipmentSlot()
obj.Size mustEqual EquipmentSize.Blocked
obj.Equipment mustEqual None
}
"construct with a default size" in {
val obj = EquipmentSlot(EquipmentSize.Pistol)
obj.Size mustEqual EquipmentSize.Pistol
}
"change size" in {
val obj = new EquipmentSlot()
obj.Size mustEqual EquipmentSize.Blocked
obj.Size = EquipmentSize.Pistol
obj.Size mustEqual EquipmentSize.Pistol
}
"hold equipment" in {
val obj = new EquipmentSlot()
val equipment = Tool(beamer)
obj.Equipment = None
beamer.Size mustEqual EquipmentSize.Pistol
obj.Size = EquipmentSize.Pistol
obj.Equipment = equipment
obj.Equipment match {
case Some(item) =>
item.Definition mustEqual beamer
case None =>
ko
}
}
"put down previously held equipment" in {
val obj = EquipmentSlot(EquipmentSize.Pistol)
obj.Equipment = Tool(beamer)
obj.Equipment match {
case Some(item) =>
item.Definition mustEqual beamer
case None =>
ko
}
obj.Equipment = None
obj.Equipment match {
case Some(_) =>
ko
case None =>
ok
}
}
"not change size when holding equipment" in {
val obj = new EquipmentSlot()
obj.Size mustEqual EquipmentSize.Blocked
obj.Size = EquipmentSize.Pistol
obj.Equipment = Tool(beamer)
obj.Equipment match {
case Some(_) => ;
case None => ko
}
obj.Size mustEqual EquipmentSize.Pistol
obj.Size = EquipmentSize.Rifle
obj.Size mustEqual EquipmentSize.Pistol
}
"not hold wrong-sized equipment" in {
val obj = new EquipmentSlot()
val equipment = Tool(suppressor)
obj.Equipment = None
beamer.Size mustEqual EquipmentSize.Pistol
obj.Size = EquipmentSize.Pistol
obj.Equipment = equipment
obj.Equipment mustEqual None
}
"not switch to holding a second item in place of a first one" in {
val obj = EquipmentSlot(EquipmentSize.Pistol)
obj.Equipment = Tool(beamer)
obj.Equipment match {
case Some(item) =>
item.Definition mustEqual beamer
case None =>
ko
}
repeater.Size mustEqual EquipmentSize.Pistol
obj.Equipment = Tool(repeater) //also a pistol
obj.Equipment match {
case Some(item) =>
item.Definition mustEqual beamer
case None =>
ko
}
}
}
"OffhandEquipmentSLot" should {
"construct" in {
val obj = new OffhandEquipmentSlot(EquipmentSize.Pistol)
obj.Size mustEqual EquipmentSize.Pistol
obj.Equipment mustEqual None
}
"hold equipment" in {
val obj = new OffhandEquipmentSlot(EquipmentSize.Pistol)
val equipment = Tool(beamer)
obj.Equipment = None
beamer.Size mustEqual EquipmentSize.Pistol
obj.Equipment = equipment
obj.Equipment match {
case Some(item) =>
item.Definition mustEqual beamer
case None =>
ko
}
}
"not change size after being constructed" in {
//see above test "EquipmentSlot should/not change size when holding equipment"
val obj = new OffhandEquipmentSlot(EquipmentSize.Pistol)
obj.Equipment mustEqual None
obj.Size mustEqual EquipmentSize.Pistol
obj.Size = EquipmentSize.Rifle
obj.Size mustEqual EquipmentSize.Pistol
}
"special Blocked size default" in {
OffhandEquipmentSlot.BlockedSlot.Size mustEqual EquipmentSize.Blocked
OffhandEquipmentSlot.BlockedSlot.Equipment mustEqual None
}
}
}