mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-13 09:00:32 +00:00
Test fix (#332)
* fix AvatarService tests * updated README section in regards to PSCrypto * better wording, imho * modifying the construction of Building entities so to properly register them with the zone GUID system * fixed tests
This commit is contained in:
parent
80af2e84a9
commit
e8fd09aad8
6 changed files with 29 additions and 44 deletions
|
|
@ -13,13 +13,12 @@ import net.psforever.objects.serverobject.terminals.CaptureTerminal
|
|||
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||
import net.psforever.objects.zones.Zone
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.types.{PlanetSideEmpire, PlanetSideGUID, Vector3}
|
||||
import net.psforever.types.{PlanetSideEmpire, Vector3}
|
||||
import scalax.collection.{Graph, GraphEdge}
|
||||
import services.Service
|
||||
import services.local.{LocalAction, LocalServiceMessage}
|
||||
|
||||
class Building(private val name: String,
|
||||
private val building_guid : Int,
|
||||
private val map_id : Int,
|
||||
private val zone : Zone,
|
||||
private val buildingType : StructureType.Value,
|
||||
|
|
@ -34,7 +33,12 @@ class Building(private val name: String,
|
|||
private var forceDomeActive : Boolean = false
|
||||
super.Zone_=(zone)
|
||||
|
||||
GUID = PlanetSideGUID(building_guid)
|
||||
/**
|
||||
* An overloaded constructor used for phasing out the need to define the building_guid parameter
|
||||
*/
|
||||
def this(name: String, building_guid : Int, map_id : Int, zone : Zone, buildingType : StructureType.Value, buildingDefinition : ObjectDefinition) = {
|
||||
this(name, map_id, zone, buildingType, buildingDefinition)
|
||||
}
|
||||
|
||||
override def toString = name
|
||||
|
||||
|
|
@ -45,7 +49,7 @@ class Building(private val name: String,
|
|||
def IsCapitol : Boolean = capitols.contains(name)
|
||||
def IsSubCapitol : Boolean = {
|
||||
Neighbours match {
|
||||
case Some(buildings: Set[Building]) => !buildings.filter(x => capitols.contains(x.name)).isEmpty
|
||||
case Some(buildings: Set[Building]) => buildings.exists(x => capitols.contains(x.name))
|
||||
case None => false
|
||||
}
|
||||
}
|
||||
|
|
@ -270,18 +274,19 @@ class Building(private val name: String,
|
|||
}
|
||||
|
||||
object Building {
|
||||
final val NoBuilding : Building = new Building(name = "", building_guid = 0, map_id = 0, Zone.Nowhere, StructureType.Platform, GlobalDefinitions.building) {
|
||||
final val NoBuilding : Building = new Building(name = "", map_id = 0, Zone.Nowhere, StructureType.Platform, GlobalDefinitions.building) {
|
||||
override def Faction_=(faction : PlanetSideEmpire.Value) : PlanetSideEmpire.Value = PlanetSideEmpire.NEUTRAL
|
||||
override def Amenities_=(obj : Amenity) : List[Amenity] = Nil
|
||||
GUID = net.psforever.types.PlanetSideGUID(0)
|
||||
}
|
||||
|
||||
def apply(name : String, guid : Int, map_id : Int, zone : Zone, buildingType : StructureType.Value) : Building = {
|
||||
new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
}
|
||||
|
||||
def Structure(buildingType : StructureType.Value, location : Vector3, definition: ObjectDefinition)(name : String, guid : Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, definition)
|
||||
val obj = new Building(name, map_id, zone, buildingType, definition)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
|
|
@ -290,7 +295,7 @@ object Building {
|
|||
def Structure(buildingType : StructureType.Value, location : Vector3)(name : String, guid : Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
val obj = new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
|
|
@ -298,14 +303,14 @@ object Building {
|
|||
|
||||
def Structure(buildingType : StructureType.Value)(name : String, guid: Int, map_id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
val obj = new Building(name, map_id, zone, buildingType, GlobalDefinitions.building)
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$map_id-$buildingType-building")
|
||||
obj
|
||||
}
|
||||
|
||||
def Structure(buildingType : StructureType.Value, buildingDefinition : ObjectDefinition, location : Vector3)(name: String, guid: Int, id : Int, zone : Zone, context : ActorContext) : Building = {
|
||||
import akka.actor.Props
|
||||
val obj = new Building(name, guid, id, zone, buildingType, buildingDefinition)
|
||||
val obj = new Building(name, id, zone, buildingType, buildingDefinition)
|
||||
obj.Position = location
|
||||
obj.Actor = context.actorOf(Props(classOf[BuildingControl], obj), s"$id-$buildingType-building")
|
||||
obj
|
||||
|
|
|
|||
|
|
@ -399,7 +399,12 @@ class Zone(private val zoneId : String, zoneMap : ZoneMap, zoneNumber : Int) {
|
|||
|
||||
private def MakeBuildings(implicit context : ActorContext) : PairMap[Int, Building] = {
|
||||
val buildingList = Map.LocalBuildings
|
||||
buildings = buildingList.map({case((name, building_guid, map_id), constructor) => building_guid -> constructor.Build(name, building_guid, map_id, this) })
|
||||
buildings = buildingList.map({
|
||||
case((name, building_guid, map_id), constructor) =>
|
||||
val building = constructor.Build(name, building_guid, map_id, this)
|
||||
guid.register(building, building_guid)
|
||||
building_guid -> building
|
||||
})
|
||||
buildings
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ class ResourceSiloControlNtuWarningTest extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
obj.Owner = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
obj.Owner.GUID = PlanetSideGUID(6)
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
|
||||
"Resource silo" should {
|
||||
|
|
@ -139,6 +140,7 @@ class ResourceSiloControlUpdate1Test extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
@ -204,6 +206,7 @@ class ResourceSiloControlUpdate2Test extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
@ -261,6 +264,7 @@ class ResourceSiloControlNoUpdateTest extends ActorTest {
|
|||
obj.Actor ! "startup"
|
||||
val zone = new Zone("nowhere", new ZoneMap("nowhere-map"), 0)
|
||||
val bldg = new Building("Building", building_guid = 6, map_id = 0, zone, StructureType.Building, GlobalDefinitions.building)
|
||||
bldg.GUID = PlanetSideGUID(6)
|
||||
obj.Owner = bldg
|
||||
val zoneEvents = TestProbe("zone-events")
|
||||
val buildingEvents = TestProbe("building-events")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue