mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-11 06:24:38 +00:00
changing from an Option[List[_] to an Option[InventoryData] in DLockerCont to match the existing LockerContainer object and the existing LockerContainerData Codec
This commit is contained in:
parent
a73e2f129c
commit
48e3f77d48
3 changed files with 17 additions and 19 deletions
|
|
@ -15,8 +15,12 @@ class LockerContainerConverter extends ObjectCreateConverter[LockerContainer]()
|
||||||
}
|
}
|
||||||
|
|
||||||
override def DetailedConstructorData(obj : LockerContainer) : Try[DetailedLockerContainerData] = {
|
override def DetailedConstructorData(obj : LockerContainer) : Try[DetailedLockerContainerData] = {
|
||||||
val contents : Option[List[InternalSlot]] = if(obj.Inventory.Size > 0) { Some(MakeInventory(obj.Inventory)) } else { None }
|
if(obj.Inventory.Size > 0) {
|
||||||
Success(DetailedLockerContainerData(8, contents))
|
Success(DetailedLockerContainerData(8, Some(InventoryData(MakeInventory(obj.Inventory)))))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Success(DetailedLockerContainerData(8, None))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,20 +15,14 @@ import shapeless.{::, HNil}
|
||||||
* Items are generally added and removed in the same way as with any other opened inventory.
|
* Items are generally added and removed in the same way as with any other opened inventory.
|
||||||
* Unlike other inventories, however, locker space is personal to an avatar and can not be accessed by other players.
|
* Unlike other inventories, however, locker space is personal to an avatar and can not be accessed by other players.
|
||||||
* @param unk na
|
* @param unk na
|
||||||
* @param contents the items in the inventory
|
* @param inventory the items in this inventory
|
||||||
*/
|
*/
|
||||||
final case class DetailedLockerContainerData(unk : Int,
|
final case class DetailedLockerContainerData(unk : Int,
|
||||||
contents : Option[List[InternalSlot]]
|
inventory : Option[InventoryData]
|
||||||
) extends ConstructorData {
|
) extends ConstructorData {
|
||||||
override def bitsize : Long = {
|
override def bitsize : Long = {
|
||||||
val base : Long = 40L
|
val base : Long = 40L
|
||||||
var invSize : Long = 0L //length of all items in inventory
|
val invSize : Long = if(inventory.isDefined) { inventory.get.bitsize } else { 0L }
|
||||||
if(contents.isDefined) {
|
|
||||||
invSize = InventoryData.BaseSize
|
|
||||||
for(item <- contents.get) {
|
|
||||||
invSize += item.bitsize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
base + invSize
|
base + invSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -45,11 +39,11 @@ object DetailedLockerContainerData extends Marshallable[DetailedLockerContainerD
|
||||||
/**
|
/**
|
||||||
* Overloaded constructor for creating `DetailedLockerContainerData` containing known items.
|
* Overloaded constructor for creating `DetailedLockerContainerData` containing known items.
|
||||||
* @param unk na
|
* @param unk na
|
||||||
* @param contents the items in the inventory
|
* @param inventory the items in the inventory
|
||||||
* @return a `DetailedLockerContainerData` object
|
* @return a `DetailedLockerContainerData` object
|
||||||
*/
|
*/
|
||||||
def apply(unk : Int, contents : List[InternalSlot]) : DetailedLockerContainerData =
|
def apply(unk : Int, inventory : List[InternalSlot]) : DetailedLockerContainerData =
|
||||||
new DetailedLockerContainerData(unk, Some(contents))
|
new DetailedLockerContainerData(unk, Some(InventoryData(inventory)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overloaded constructor for creating `DetailedLockerContainerData` while masking use of `InternalSlot`.
|
* Overloaded constructor for creating `DetailedLockerContainerData` while masking use of `InternalSlot`.
|
||||||
|
|
@ -73,8 +67,8 @@ object DetailedLockerContainerData extends Marshallable[DetailedLockerContainerD
|
||||||
case 0xC :: unk :: 0 :: 1 :: None :: HNil =>
|
case 0xC :: unk :: 0 :: 1 :: None :: HNil =>
|
||||||
Attempt.successful(DetailedLockerContainerData(unk, None))
|
Attempt.successful(DetailedLockerContainerData(unk, None))
|
||||||
|
|
||||||
case 0xC :: unk :: 0 :: 1 :: Some(InventoryData(list)) :: HNil =>
|
case 0xC :: unk :: 0 :: 1 :: Some(inv) :: HNil =>
|
||||||
Attempt.successful(DetailedLockerContainerData(unk, Some(list)))
|
Attempt.successful(DetailedLockerContainerData(unk, Some(inv)))
|
||||||
case _ =>
|
case _ =>
|
||||||
Attempt.failure(Err(s"invalid locker container data format"))
|
Attempt.failure(Err(s"invalid locker container data format"))
|
||||||
},
|
},
|
||||||
|
|
@ -82,8 +76,8 @@ object DetailedLockerContainerData extends Marshallable[DetailedLockerContainerD
|
||||||
case DetailedLockerContainerData(unk, None) =>
|
case DetailedLockerContainerData(unk, None) =>
|
||||||
Attempt.successful(0xC :: unk :: 0 :: 1 :: None :: HNil)
|
Attempt.successful(0xC :: unk :: 0 :: 1 :: None :: HNil)
|
||||||
|
|
||||||
case DetailedLockerContainerData(unk, Some(list)) =>
|
case DetailedLockerContainerData(unk, Some(inv)) =>
|
||||||
Attempt.successful(0xC :: unk :: 0 :: 1 :: Some(InventoryData(list)) :: HNil)
|
Attempt.successful(0xC :: unk :: 0 :: 1 :: Some(inv) :: HNil)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ class ObjectCreateDetailedMessageTest extends Specification {
|
||||||
inventory(3).guid mustEqual PlanetSideGUID(82)
|
inventory(3).guid mustEqual PlanetSideGUID(82)
|
||||||
inventory(3).parentSlot mustEqual 5
|
inventory(3).parentSlot mustEqual 5
|
||||||
inventory(3).obj.isInstanceOf[DetailedLockerContainerData] mustEqual true
|
inventory(3).obj.isInstanceOf[DetailedLockerContainerData] mustEqual true
|
||||||
inventory(3).obj.asInstanceOf[DetailedLockerContainerData].contents.isDefined mustEqual false
|
inventory(3).obj.asInstanceOf[DetailedLockerContainerData].inventory.isDefined mustEqual false
|
||||||
//4
|
//4
|
||||||
inventory(4).objectClass mustEqual ObjectClass.bullet_9mm
|
inventory(4).objectClass mustEqual ObjectClass.bullet_9mm
|
||||||
inventory(4).guid mustEqual PlanetSideGUID(83)
|
inventory(4).guid mustEqual PlanetSideGUID(83)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue