mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
fix resecure reward
This commit is contained in:
parent
d9c913e3ff
commit
3969543cde
|
|
@ -106,7 +106,7 @@ class HackCaptureActor extends Actor {
|
|||
NotifyHackStateChange(target, isResecured = true)
|
||||
building.Participation.RewardFacilityCapture(
|
||||
target.Faction,
|
||||
faction,
|
||||
HackCaptureActor.GetAttackingFaction(building, faction),
|
||||
hacker,
|
||||
facilityHackTime,
|
||||
hackTime,
|
||||
|
|
@ -347,6 +347,30 @@ object HackCaptureActor {
|
|||
.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] = {
|
||||
terminal.HackedBy.map { a => a.player.Faction }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue