-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFights.lua
94 lines (77 loc) · 2.72 KB
/
Fights.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
local Recount = _G.Recount
local revision = tonumber(string.sub("$Revision: 1532 $", 12, -3))
if Recount.Version < revision then
Recount.Version = revision
end
local date = date
local math = math
local pairs = pairs
local string = string
local tonumber = tonumber
local Fights = {}
Recount.Fights = Fights
function Fights:CopyCurrentFights()
for _, v in pairs(Recount.db2.combatants) do
--v.Fights.LastFightData = v.Fights.CurrentFightData -- Copy current even for short fights
Recount:ResetFightData(v.Fights["CurrentFightData"])
end
end
function Fights:MoveFights()
local ReuseFight
if not Recount.db.profile.SegmentBosses or Recount.FightingLevel == -1 then
for i = math.min(#Recount.db2.FoughtWho, Recount.db.profile.MaxFights - 1), 1, -1 do
Recount.db2.FoughtWho[i + 1] = Recount.db2.FoughtWho[i]
end
Recount.db2.FoughtWho[1] = Recount.FightingWho.." "..Recount.InCombatF.."-"..date("%H:%M:%S")
end
for k, v in pairs(Recount.db2.combatants) do
--ReuseFight = v.Fights.LastFightData
ReuseFight = nil
v.Fights.LastFightData = v.Fights.CurrentFightData
if not Recount.db.profile.SegmentBosses or Recount.FightingLevel == -1 then
v.FightsSaved = v.FightsSaved or 0
if v.FightsSaved == Recount.db.profile.MaxFights then
ReuseFight = v.Fights["Fight"..v.FightsSaved]
end
v.FightsSaved = v.FightsSaved or 0
for i = math.min(v.FightsSaved, Recount.db.profile.MaxFights - 1), 1, -1 do
v.Fights["Fight"..i + 1] = v.Fights["Fight"..i]
end
if v.LastFightIn == Recount.db2.FightNum then
v.Fights["Fight1"] = v.Fights.CurrentFightData
else
v.Fights["Fight1"] = nil
end
if v.FightsSaved < Recount.db.profile.MaxFights then
v.FightsSaved = v.FightsSaved + 1
end
end
if not ReuseFight or ReuseFight == v.Fights.LastFightData then
v.Fights["CurrentFightData"] = Recount:GetTable()
Recount:InitFightData(v.Fights["CurrentFightData"])
else
Recount:ResetFightData(ReuseFight)
v.Fights["CurrentFightData"] = ReuseFight
end
end
if RecountDeathTrack then
RecountDeathTrack:CopyFight()
end
--Main Window Display Cache needs to be reset should fix several bugs
Recount:FullRefreshMainWindow() -- Elsia: Made a function for this as it's also needed for deleting combatants and refreshing when options change
local FightNum = tonumber(string.match(Recount.db.profile.CurDataSet, "Fight(%d+)"))
if FightNum then
Recount.FightName = Recount.db2.FoughtWho[FightNum]
end
end
function Fights:DeleteOverflowFights(newmax)
for k, v in pairs(Recount.db2.combatants) do
for i = newmax + 1, Recount.db.profile.MaxFights, 1 do
v.Fights["Fight"..i] = nil
Recount.db2.FoughtWho[i] = nil
if RecountDeathTrack then
RecountDeathTrack:DeleteDeathTrackEntry(i)
end
end
end
end