mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-19 12:00:39 +00:00
Restructure repository
* Move /common/src to /src * Move services to net.psforever package * Move /pslogin to /server
This commit is contained in:
parent
89a30ae6f6
commit
f4fd78fc5d
958 changed files with 527 additions and 725 deletions
59
src/test/scala/objects/ContainerTest.scala
Normal file
59
src/test/scala/objects/ContainerTest.scala
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import net.psforever.objects.equipment.{EquipmentSize, EquipmentSlot}
|
||||
import net.psforever.objects.inventory.{Container, GridInventory, InventoryEquipmentSlot}
|
||||
import net.psforever.objects.{GlobalDefinitions, OffhandEquipmentSlot, Tool}
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
import org.specs2.mutable._
|
||||
|
||||
import scala.util.Success
|
||||
|
||||
class ContainerTest extends Specification {
|
||||
"Container" should {
|
||||
"construct" in {
|
||||
val obj = new ContainerTest.CObject
|
||||
obj.VisibleSlots mustEqual (0 until 9).toSet
|
||||
obj.Inventory.Size mustEqual 0
|
||||
obj.Inventory.Capacity mustEqual 9
|
||||
obj.Find(PlanetSideGUID(0)) mustEqual None
|
||||
obj.Slot(0).isInstanceOf[OffhandEquipmentSlot] mustEqual true
|
||||
obj.Slot(0).isInstanceOf[InventoryEquipmentSlot] mustEqual true
|
||||
obj.Slot(0).isInstanceOf[EquipmentSlot] mustEqual true
|
||||
obj.Slot(0).Size mustEqual EquipmentSize.Inventory
|
||||
obj.Slot(0).Equipment mustEqual None
|
||||
obj.Collisions(0, 2, 2) mustEqual Success(List())
|
||||
}
|
||||
|
||||
"Collisions can Find items in Inventory (default behavior)" in {
|
||||
val obj = new ContainerTest.CObject
|
||||
val weapon = Tool(GlobalDefinitions.beamer)
|
||||
weapon.GUID = PlanetSideGUID(1)
|
||||
|
||||
obj.Inventory += 0 -> weapon
|
||||
obj.Find(PlanetSideGUID(1)) match {
|
||||
case Some(index) =>
|
||||
obj.Inventory.Items(index).obj mustEqual weapon
|
||||
case None =>
|
||||
ko
|
||||
}
|
||||
obj.Collisions(1, 1, 1) match {
|
||||
case Success(items) =>
|
||||
items.length mustEqual 1
|
||||
items.head.obj mustEqual weapon
|
||||
case _ => ;
|
||||
ko
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object ContainerTest {
|
||||
class CObject extends Container {
|
||||
private val inv = GridInventory(3, 3)
|
||||
|
||||
def Inventory: GridInventory = inv
|
||||
|
||||
def VisibleSlots: Set[Int] = Set[Int](0, 1, 2, 3, 4, 5, 6, 7, 8)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue