mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 15:34:42 +00:00
fix resecure reward
This commit is contained in:
parent
d9c913e3ff
commit
3969543cde
1 changed files with 25 additions and 1 deletions
|
|
@ -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 }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue