PSF-BotServer/common/src/test/scala/objects/terminal/DropshipVehicleTerminalTest.scala
FateJH eefe4d2e20 Building:
Replaces class object/serverobject/door/Base.scala.  It performs nearly the exact same purpose but now has a list of owned objects called Amenities.  Buildings are now a PlanetSideServerObject (PSSO), which allows them to have accept a *Control Actor and possess FactionAffinity.

FoundationBuilder:
FoundationBuilder : Building :: ServerObjectBuilder : [T <: PlanetSideServerObject]

Amenity:
Most PSSO's now accept Amenity as their parent in class hierarchy.  Flagged PSSO's like Building and Vehicle are, on the other hand, capable of becoming the owner for these Amenity PSSOs, which allows them to inherit the same FactionAffinity.

FactionAffinity:
A trait that connects objects that are intended to communicate PlanetSideEmpire values.

MountableBhevaior:
Split between Mount and Dismount behavior.  Passes appropriate messages to ensure coherent workflows.

Control Actors:
FactionAffinityBehavior and MountableBehavior are PartialFunctions that get processed in series.

VehicleControl:
Distinguished behavior allowed between an operational vehicle and a deactivated one.

WSA:
Tightened up DismountVehicleMsg handling code, since MountableBehavior has been enhanced.

Minor:
Shotgun shell stacking goes from 32 to 16.  Various PSSO classes now have reliable Definition objects.

Tests:
We now have 1012 tests, some of them useful.
2018-02-08 14:22:05 -05:00

54 lines
2.7 KiB
Scala

// Copyright (c) 2017 PSForever
package objects.terminal
import akka.actor.ActorRef
import net.psforever.objects.serverobject.structures.Building
import net.psforever.objects.{GlobalDefinitions, Player}
import net.psforever.objects.serverobject.terminals.Terminal
import net.psforever.objects.zones.Zone
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
import org.specs2.mutable.Specification
class DropshipVehicleTerminalTest extends Specification {
"Dropship_Vehicle_Terminal" should {
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
terminal.Owner = new Building(0, Zone.Nowhere)
terminal.Owner.Faction = PlanetSideEmpire.TR
"construct" in {
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
terminal.Actor mustEqual ActorRef.noSender
}
"player can buy a galaxy ('dropship')" in {
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "dropship", 0, PlanetSideGUID(0))
val reply = terminal.Request(player, msg)
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
reply2.vehicle.Definition mustEqual GlobalDefinitions.dropship
reply2.weapons mustEqual Nil
reply2.inventory.length mustEqual 12
reply2.inventory.head.obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(1).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(2).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(3).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(4).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(5).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(6).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(7).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(8).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(9).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(10).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
reply2.inventory(11).obj.Definition mustEqual GlobalDefinitions.bullet_20mm
}
"player can not buy a fake vehicle ('galaxy')" in {
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "galaxy", 0, PlanetSideGUID(0))
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
}
}
}