Updates on goal logic

This commit is contained in:
FlightControl 2019-03-23 10:45:14 +01:00
parent 4c72496599
commit bfb11b6f79
3 changed files with 27 additions and 9 deletions

View File

@ -968,18 +968,19 @@ function MISSION:ReportPlayersProgress( ReportGroup )
-- Determine how many tasks are remaining.
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
local TaskGoalTotal = Task:GetGoalTotal() or 0
local TaskName = Task:GetName()
local Goal = Task:GetGoal()
PlayerList[TaskName] = PlayerList[TaskName] or {}
if TaskGoalTotal ~= 0 then
local PlayerNames = self:GetPlayerNames()
for PlayerName, PlayerData in pairs( PlayerNames ) do
PlayerList[TaskName][PlayerName] = string.format( 'Player (%s): Task "%s": %d%%', PlayerName, TaskName, Task:GetPlayerProgress( PlayerName ) * 100 / TaskGoalTotal )
if Goal then
local TotalContributions = Goal:GetTotalContributions()
local PlayerContributions = Goal:GetPlayerContributions()
self:F( { TotalContributions = TotalContributions, PlayerContributions = PlayerContributions } )
for PlayerName, PlayerContribution in pairs( PlayerContributions ) do
PlayerList[TaskName][PlayerName] = string.format( 'Player (%s): Task "%s": %d%%', PlayerName, TaskName, PlayerContributions[PlayerName] * 100 / TotalContributions )
end
else
PlayerList[TaskName]["_"] = string.format( 'Player (---): Task "%s": %d%%', TaskName, 0 )
end
end
end
for TaskName, TaskData in pairs( PlayerList ) do

View File

@ -1709,6 +1709,23 @@ end
do -- Links
--- Set goal of a task
-- @param #TASK self
-- @param Core.Goal#GOAL Goal
-- @return #TASK
function TASK:SetGoal( Goal )
self.Goal = Goal
end
--- Get goal of a task
-- @param #TASK self
-- @return Core.Goal#GOAL The Goal
function TASK:GetGoal()
return self.Goal
end
--- Set dispatcher of a task
-- @param #TASK self
-- @param Tasking.DetectionManager#DETECTION_MANAGER Dispatcher

View File

@ -213,7 +213,7 @@ do -- TASK_CAPTURE_ZONE
self:UpdateTaskInfo( true )
self:SetGoalTotal( 1 )
self:SetGoal( self.ZoneGoal.Goal )
return self
end
@ -232,7 +232,7 @@ do -- TASK_CAPTURE_ZONE
self.TaskInfo:AddText( "Zone Coalition", self.ZoneGoal:GetCoalitionName(), 11, "MOD", Persist )
local SetUnit = self.ZoneGoal.Zone:GetScannedSetUnit()
local ThreatLevel, ThreatText = SetUnit:CalculateThreatLevelA2G()
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MSOD", Persist )
self.TaskInfo:AddThreat( ThreatText, ThreatLevel, 20, "MOD", Persist )
end