Update Scoring.lua

This commit is contained in:
Frank
2019-05-16 21:09:18 +02:00
parent 70bca0d142
commit 1e1335e2ed
+46 -21
View File
@@ -1727,6 +1727,10 @@ function SCORING:ReportScoreGroupSummary( PlayerGroup )
if PlayerName then if PlayerName then
local Player=self.Players[PlayerName] --#SCORING.PlayerData
if Player then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
@@ -1747,8 +1751,8 @@ function SCORING:ReportScoreGroupSummary( PlayerGroup )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
PlayerMessage = PlayerMessage =
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )", string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
@@ -1758,6 +1762,8 @@ function SCORING:ReportScoreGroupSummary( PlayerGroup )
PlayerPenalty PlayerPenalty
) )
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup ) MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
end
end end
end end
@@ -1779,6 +1785,10 @@ function SCORING:ReportScoreGroupDetailed( PlayerGroup )
if PlayerName then if PlayerName then
local Player=self.Players[PlayerName] --#SCORING.PlayerData
if Player then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
@@ -1799,8 +1809,8 @@ function SCORING:ReportScoreGroupDetailed( PlayerGroup )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
PlayerMessage = PlayerMessage =
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s", string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s",
@@ -1817,6 +1827,7 @@ function SCORING:ReportScoreGroupDetailed( PlayerGroup )
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup ) MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
end end
end end
end
end end
@@ -1835,6 +1846,10 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
if PlayerName then if PlayerName then
local Player=self.Players[PlayerName] --#SCORING.PlayerData
if Player then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
@@ -1855,8 +1870,8 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
PlayerMessage = PlayerMessage =
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )", string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
@@ -1866,6 +1881,8 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
PlayerPenalty PlayerPenalty
) )
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Overview ):ToGroup( PlayerGroup ) MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Overview ):ToGroup( PlayerGroup )
end
end end
end end
@@ -1994,9 +2011,9 @@ function SCORING:LoadCSV(filename)
-- Create player array if necessary. -- Create player array if necessary.
self.CSVdata[result.PlayerName]=self.CSVdata[result.PlayerName] or {} self.CSVdata[result.PlayerName]=self.CSVdata[result.PlayerName] or {}
local Player=self.Players[PlayerName] --#SCORING.PlayerData
if Player == nil then -- I believe this is the place where a Player gets a life in a mission when he enters a unit ... -- Init player array if it does not exist.
if self.Players[PlayerName] == nil then
self.Players[PlayerName] = {} self.Players[PlayerName] = {}
self.Players[PlayerName].Hit = {} self.Players[PlayerName].Hit = {}
self.Players[PlayerName].Destroy = {} self.Players[PlayerName].Destroy = {}
@@ -2009,8 +2026,12 @@ function SCORING:LoadCSV(filename)
self.Players[PlayerName].PenaltyWarning = 0 self.Players[PlayerName].PenaltyWarning = 0
end end
local Player=self.Players[PlayerName] --#SCORING.PlayerData
-- Restore player scores. -- Restore player scores.
if result.ScoreType then if result.ScoreType then
if result.ScoreType:find("PENALTY") then if result.ScoreType:find("PENALTY") then
-- Penalty -- Penalty
@@ -2021,11 +2042,15 @@ function SCORING:LoadCSV(filename)
Player.PenaltyCoalition=Player.PenaltyCoalition+1 Player.PenaltyCoalition=Player.PenaltyCoalition+1
end end
end end
if result.ScoreType:find("SCORE") then if result.ScoreType:find("SCORE") then
Player.Score=Player.Score+result.Score Player.Score=Player.Score+result.Score
end end
end end
self:E(string.format("Player %s score = %d %d", PlayerName, Player.Score, self.Players[PlayerName].Score))
--self.Players[PlayerName].Score=self.Players[PlayerName].Score+result.Score --self.Players[PlayerName].Score=self.Players[PlayerName].Score+result.Score
-- Add result to table. -- Add result to table.
@@ -2101,20 +2126,20 @@ function SCORING:ScoreCSV( PlayerName, TargetPlayerName, ScoreType, ScoreTimes,
if lfs and io and os then if lfs and io and os then
self.CSVFile:write( self.CSVFile:write(
'"' .. self.GameName .. '"' .. ',' .. '' .. self.GameName .. '' .. ',' ..
'"' .. self.RunTime .. '"' .. ',' .. '' .. self.RunTime .. '' .. ',' ..
'' .. ScoreTime .. '' .. ',' .. '' .. ScoreTime .. '' .. ',' ..
'"' .. PlayerName .. '"' .. ',' .. '' .. PlayerName .. '' .. ',' ..
'"' .. TargetPlayerName .. '"' .. ',' .. '' .. TargetPlayerName .. '' .. ',' ..
'"' .. ScoreType .. '"' .. ',' .. '' .. ScoreType .. '' .. ',' ..
'"' .. PlayerUnitCoalition .. '"' .. ',' .. '' .. PlayerUnitCoalition .. '' .. ',' ..
'"' .. PlayerUnitCategory .. '"' .. ',' .. '' .. PlayerUnitCategory .. '' .. ',' ..
'"' .. PlayerUnitType .. '"' .. ',' .. '' .. PlayerUnitType .. '' .. ',' ..
'"' .. PlayerUnitName .. '"' .. ',' .. '' .. PlayerUnitName .. '' .. ',' ..
'"' .. TargetUnitCoalition .. '"' .. ',' .. '' .. TargetUnitCoalition .. '' .. ',' ..
'"' .. TargetUnitCategory .. '"' .. ',' .. '' .. TargetUnitCategory .. '' .. ',' ..
'"' .. TargetUnitType .. '"' .. ',' .. '' .. TargetUnitType .. '' .. ',' ..
'"' .. TargetUnitName .. '"' .. ',' .. '' .. TargetUnitName .. '' .. ',' ..
'' .. ScoreTimes .. '' .. ',' .. '' .. ScoreTimes .. '' .. ',' ..
'' .. ScoreAmount '' .. ScoreAmount
) )