-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.lua
40 lines (32 loc) · 984 Bytes
/
Game.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local Game = ArenaLog.Game
local Team = ArenaLog.Team
local Logger = ArenaLog.Logger
Game.__index = Game
function Game.New()
local self = setmetatable({}, Game)
self.date = nil
self.duration = nil
self.type = nil --[2 - 2x2, 3 - 3x3] - other types and bg are not supported
self.score = nil
self.zone = nil
self.alliedTeam = Team.New()
self.enemyTeam = Team.New()
return self
end
function Game:UpdateTeamsInfo()
Logger:Debug("UPDATING TEAMS")
self.alliedTeam:UpdateTeamInfo()
self.enemyTeam:UpdateTeamInfo()
end
function Game:UpdateZone()
self.zone = GetRealZoneText()
end
function Game:Finish(winner, duration)
Logger:Debug("FINISHING THE GAME")
self:UpdateTeamsInfo()
self:UpdateZone()
self.score = winner
self.date = C_DateAndTime.GetCurrentCalendarTime()
self.duration = string.format("%dm%ds", duration / 60, duration % 60)
self.type = math.max(self.alliedTeam.size, self.enemyTeam.size)
end