fix resecure reward

This commit is contained in:
ScrawnyRonnie 2025-01-20 10:41:15 -05:00
parent d9c913e3ff
commit 3969543cde

View file

@ -106,7 +106,7 @@ class HackCaptureActor extends Actor {
NotifyHackStateChange(target, isResecured = true) NotifyHackStateChange(target, isResecured = true)
building.Participation.RewardFacilityCapture( building.Participation.RewardFacilityCapture(
target.Faction, target.Faction,
faction, HackCaptureActor.GetAttackingFaction(building, faction),
hacker, hacker,
facilityHackTime, facilityHackTime,
hackTime, hackTime,
@ -347,6 +347,30 @@ object HackCaptureActor {
.get .get
} }
def GetAttackingFaction(
building: Building,
excludeThisFaction: PlanetSideEmpire.Value
): PlanetSideEmpire.Value = {
// Use PlayerContributionRaw to calculate attacking faction
val factionEfforts = building.Participation
.PlayerContributionRaw
.values
.foldLeft(Array.fill(4)(0L)) { case (efforts, (player, duration, _)) =>
val factionId = player.Faction.id
efforts.update(factionId, efforts(factionId) + duration)
efforts
}
// Exclude the specified faction
factionEfforts.update(excludeThisFaction.id, Long.MinValue)
// Find the faction with the highest contribution
factionEfforts.indices
.maxByOption(factionEfforts)
.map(PlanetSideEmpire.apply)
.getOrElse(PlanetSideEmpire.NEUTRAL)
}
def GetHackingFaction(terminal: CaptureTerminal): Option[PlanetSideEmpire.Value] = { def GetHackingFaction(terminal: CaptureTerminal): Option[PlanetSideEmpire.Value] = {
terminal.HackedBy.map { a => a.player.Faction } terminal.HackedBy.map { a => a.player.Faction }
} }