PSF-LoginServer/src/test/scala/objects/VitalityTest.scala
Fate-JH e9dbd5f259 importing controlled implementation changes from original exp-for-kda branch; assist kill experience rewarded
importing controlled implementation changes from original exp-for-kda branch; code for contributions from prior activity, but will be adjusting to new contribution methods

kill contributions should work; even if they don't, need to put this away for now

extensivwe changes to the way OwnableByPlayer manages owner user information due to uniqueness, that changes a lot of vehicle and deployable code; fleshing out experience calculation procedure for future testing

events for mounting and dismounting of both passenger and cargo; id'ing the installation of an amenity (vehicle or facility); separation of kill/assist experience and support experience calculations; retention of kill record which allows for the calculation of menace

support experience accumulates and is given to the user in gradual provisions

rewarding facility capture through cep; not fully tested yet; math sucks

sort of cep to bep consditions for squad facility capture; bep deposit for ntu silo activity

early reivision for v010; recording ongoing shots fired and landed

restored bep from ntu deposits into resource silos; updating statistics in the database regarding kills and related stats including weapons; updated history management; basic experience calculation changes

all rewarded support events are accounted for

command experience calculations upon facility capture or resecure

corrected database migrations

most of the code for the play or progress system

statistics window updates for exosuits to report kills; killing an llu runner gives cep; moving play or progress functionality to a bang command rather than piggybacking setbr; bep is no longer too high by error
2023-10-17 14:06:21 -04:00

113 lines
4.9 KiB
Scala

// Copyright (c) 2017 PSForever
package objects
import net.psforever.objects.ballistics._
import net.psforever.objects._
import net.psforever.objects.avatar.Avatar
import net.psforever.objects.serverobject.terminals.Terminal
import net.psforever.objects.sourcing.{AmenitySource, PlayerSource, SourceEntry, VehicleSource}
import net.psforever.objects.vital._
import net.psforever.objects.vital.base.DamageResolution
import net.psforever.objects.vital.interaction.DamageInteraction
import net.psforever.objects.vital.projectile.ProjectileReason
import net.psforever.types._
import org.specs2.mutable.Specification
class VitalityTest extends Specification {
"Vitality" should {
val wep = GlobalDefinitions.galaxy_gunship_cannon
val wep_fmode = Tool(wep).FireMode
val proj = wep.ProjectileTypes.head
val vehicle = Vehicle(GlobalDefinitions.fury)
val vSource = VehicleSource(vehicle)
"accept a variety of events" in {
val player = Player(Avatar(0, "TestCharacter", PlanetSideEmpire.TR, CharacterSex.Male, 0, CharacterVoice.Mute))
val pSource = PlayerSource(player)
val projectile = Projectile(proj, wep, wep_fmode, player, Vector3(2, 2, 0), Vector3.Zero)
val resprojectile = DamageInteraction(
SourceEntry(player),
ProjectileReason(
DamageResolution.Hit,
projectile,
player.DamageModel
),
Vector3(50, 50, 0)
)
val result = resprojectile.calculate()(player)
val term = AmenitySource(new Terminal(GlobalDefinitions.order_terminal) { GUID = PlanetSideGUID(1) })
player.LogActivity(result) //DamageResult, straight-up
player.LogActivity(DamageFromProjectile(result))
player.LogActivity(HealFromKit(GlobalDefinitions.medkit, 10))
player.LogActivity(HealFromTerminal(term, 10))
player.LogActivity(HealFromImplant(ImplantType.AdvancedRegen, 10))
player.LogActivity(RepairFromExoSuitChange(ExoSuitType.Standard, 10))
player.LogActivity(RepairFromTerminal(term, 10))
player.LogActivity(ShieldCharge(10, Some(vSource)))
player.LogActivity(PlayerSuicide(PlayerSource(player)))
ok
}
"return and clear the former list of vital activities" in {
val player = Player(Avatar(0, "TestCharacter", PlanetSideEmpire.TR, CharacterSex.Male, 0, CharacterVoice.Mute))
val pSource = PlayerSource(player)
val term = AmenitySource(new Terminal(GlobalDefinitions.order_terminal) { GUID = PlanetSideGUID(1) })
player.LogActivity(HealFromKit(GlobalDefinitions.medkit, 10))
player.LogActivity(HealFromTerminal(term, 10))
player.LogActivity(HealFromImplant(ImplantType.AdvancedRegen, 10))
player.LogActivity(RepairFromExoSuitChange(ExoSuitType.Standard, 10))
player.LogActivity(RepairFromTerminal(term, 10))
player.LogActivity(ShieldCharge(10, Some(vSource)))
player.LogActivity(PlayerSuicide(PlayerSource(player)))
player.History.size mustEqual 7
val list = player.ClearHistory()
player.History.size mustEqual 0
list.head.isInstanceOf[PlayerSuicide] mustEqual true
list(1).isInstanceOf[ShieldCharge] mustEqual true
list(2).isInstanceOf[RepairFromTerminal] mustEqual true
list(3).isInstanceOf[RepairFromExoSuitChange] mustEqual true
list(4).isInstanceOf[HealFromImplant] mustEqual true
list(5).isInstanceOf[HealFromTerminal] mustEqual true
list(6).isInstanceOf[HealFromKit] mustEqual true
}
"get exactly one entry that was caused by projectile damage" in {
val player = Player(Avatar(0, "TestCharacter", PlanetSideEmpire.TR, CharacterSex.Male, 0, CharacterVoice.Mute))
val pSource = PlayerSource(player)
val projectile = Projectile(proj, wep, wep_fmode, player, Vector3(2, 2, 0), Vector3.Zero)
val resprojectile = DamageInteraction(
SourceEntry(player),
ProjectileReason(
DamageResolution.Hit,
projectile,
player.DamageModel
),
Vector3(50, 50, 0)
)
val result = resprojectile.calculate()(player)
val term = AmenitySource(new Terminal(GlobalDefinitions.order_terminal) { GUID = PlanetSideGUID(1) })
player.LogActivity(DamageFromProjectile(result))
player.LogActivity(HealFromKit(GlobalDefinitions.medkit, 10))
player.LogActivity(HealFromTerminal(term, 10))
player.LogActivity(HealFromImplant(ImplantType.AdvancedRegen, 10))
player.LogActivity(RepairFromExoSuitChange(ExoSuitType.Standard, 10))
player.LogActivity(RepairFromTerminal(term, 10))
player.LogActivity(ShieldCharge(10, Some(vSource)))
player.LogActivity(PlayerSuicide(PlayerSource(player)))
player.LastShot match {
case Some(resolved_projectile) =>
resolved_projectile.interaction.cause match {
case o: ProjectileReason => o.projectile mustEqual projectile
case _ => ko
}
case None =>
ko
}
}
}
}