Update Scoring.lua

This commit is contained in:
Frank
2019-05-16 21:09:18 +02:00
parent 70bca0d142
commit 1e1335e2ed
+122 -97
View File
@@ -1727,37 +1727,43 @@ function SCORING:ReportScoreGroupSummary( PlayerGroup )
if PlayerName then if PlayerName then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local Player=self.Players[PlayerName] --#SCORING.PlayerData
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName ) if Player then
ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName ) local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName )
ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } ) self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName ) local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName )
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } )
PlayerMessage = local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName )
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )", ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
PlayerName, self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
PlayerScore - PlayerPenalty,
PlayerScore, local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
PlayerPenalty local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
)
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup ) PlayerMessage =
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
PlayerName,
PlayerScore - PlayerPenalty,
PlayerScore,
PlayerPenalty
)
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
end
end end
end end
@@ -1779,42 +1785,47 @@ function SCORING:ReportScoreGroupDetailed( PlayerGroup )
if PlayerName then if PlayerName then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local Player=self.Players[PlayerName] --#SCORING.PlayerData
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName ) if Player then
ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName ) local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName )
ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } ) self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName ) local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName )
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } )
PlayerMessage = local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName )
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s", ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
PlayerName, self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
PlayerScore - PlayerPenalty,
PlayerScore, local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
PlayerPenalty, local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
ReportHits,
ReportDestroys, PlayerMessage =
ReportCoalitionChanges, string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )%s%s%s%s%s",
ReportGoals, PlayerName,
ReportMissions PlayerScore - PlayerPenalty,
) PlayerScore,
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup ) PlayerPenalty,
ReportHits,
ReportDestroys,
ReportCoalitionChanges,
ReportGoals,
ReportMissions
)
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Detailed ):ToGroup( PlayerGroup )
end
end end
end end
@@ -1835,37 +1846,43 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
if PlayerName then if PlayerName then
local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName ) local Player=self.Players[PlayerName] --#SCORING.PlayerData
ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName ) if Player then
ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName ) local ReportHits, ScoreHits, PenaltyHits = self:ReportDetailedPlayerHits( PlayerName )
ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges ReportHits = ReportHits ~= "" and "\n- " .. ReportHits or ReportHits
self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } ) self:F( { ReportHits, ScoreHits, PenaltyHits } )
local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName ) local ReportDestroys, ScoreDestroys, PenaltyDestroys = self:ReportDetailedPlayerDestroys( PlayerName )
ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals ReportDestroys = ReportDestroys ~= "" and "\n- " .. ReportDestroys or ReportDestroys
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } ) self:F( { ReportDestroys, ScoreDestroys, PenaltyDestroys } )
local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName ) local ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges = self:ReportDetailedPlayerCoalitionChanges( PlayerName )
ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions ReportCoalitionChanges = ReportCoalitionChanges ~= "" and "\n- " .. ReportCoalitionChanges or ReportCoalitionChanges
self:F( { ReportMissions, ScoreMissions, PenaltyMissions } ) self:F( { ReportCoalitionChanges, ScoreCoalitionChanges, PenaltyCoalitionChanges } )
local PlayerScore = ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions local ReportGoals, ScoreGoals, PenaltyGoals = self:ReportDetailedPlayerGoals( PlayerName )
local PlayerPenalty = PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions ReportGoals = ReportGoals ~= "" and "\n- " .. ReportGoals or ReportGoals
self:F( { ReportGoals, ScoreGoals, PenaltyGoals } )
PlayerMessage = local ReportMissions, ScoreMissions, PenaltyMissions = self:ReportDetailedPlayerMissions( PlayerName )
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )", ReportMissions = ReportMissions ~= "" and "\n- " .. ReportMissions or ReportMissions
PlayerName, self:F( { ReportMissions, ScoreMissions, PenaltyMissions } )
PlayerScore - PlayerPenalty,
PlayerScore, local PlayerScore = Player.Score --ScoreHits + ScoreDestroys + ScoreCoalitionChanges + ScoreGoals + ScoreMissions
PlayerPenalty local PlayerPenalty = Player.Penalty --PenaltyHits + PenaltyDestroys + PenaltyCoalitionChanges + ScoreGoals + PenaltyMissions
)
MESSAGE:NewType( PlayerMessage, MESSAGE.Type.Overview ):ToGroup( PlayerGroup ) PlayerMessage =
string.format( "Player '%s' Score = %d ( %d Score, -%d Penalties )",
PlayerName,
PlayerScore - PlayerPenalty,
PlayerScore,
PlayerPenalty
)
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,21 +2126,21 @@ 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
) )