|
| 1 | +local _, ADDON = ... |
| 2 | + |
| 3 | +------------------------------------------------------------ |
| 4 | + |
| 5 | +local function GetEP(group, account, raid, id) |
| 6 | + local points = 0 |
| 7 | + local kills = 0 |
| 8 | + |
| 9 | + -- get effort points |
| 10 | + for _,kill in ipairs(raid.kills) do |
| 11 | + local multi = kill.multi or 1 |
| 12 | + for _,player in ipairs(kill.players) do |
| 13 | + if player == id then |
| 14 | + local boss = ADDON.Groups[group].Bosses[kill.boss] |
| 15 | + if boss then |
| 16 | + for _,a in ipairs(boss.accounts) do |
| 17 | + if a == account then |
| 18 | + points = points + boss.points * multi |
| 19 | + kills = kills + 1 |
| 20 | + end |
| 21 | + end |
| 22 | + else |
| 23 | + print("Error: Unknown boss " .. kill.boss .. " (" .. kill.timestamp .. ")") |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + return points, kills |
| 30 | +end |
| 31 | + |
| 32 | +------------------------------------------------------------ |
| 33 | + |
| 34 | +local function GetGP(group, account, raid, id) |
| 35 | + local points = 0 |
| 36 | + local items = 0 |
| 37 | + |
| 38 | + -- get gear points |
| 39 | + for _,line in ipairs(raid.drops) do |
| 40 | + local multi = line.multi or 1 |
| 41 | + if line.player == id then |
| 42 | + local item = ADDON.Groups[group].Items[line.item] |
| 43 | + if item then |
| 44 | + if item.account == account then |
| 45 | + points = points + item.cost * multi |
| 46 | + items = items + 1 |
| 47 | + end |
| 48 | + else |
| 49 | + print("Error: Unknown item " .. line.item .. " (" .. line.timestamp .. ")") |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + return points, items |
| 55 | +end |
| 56 | + |
| 57 | +------------------------------------------------------------ |
| 58 | + |
| 59 | +local function GetCorrections(group, account, name) |
| 60 | + |
| 61 | + local t = ADDON.Groups[group].Corrections |
| 62 | + local id = 0 |
| 63 | + local ep = 0 |
| 64 | + local gp = 0 |
| 65 | + |
| 66 | + -- find player id |
| 67 | + for k,player in pairs(t.players) do |
| 68 | + if player == name then |
| 69 | + id = k |
| 70 | + end |
| 71 | + end |
| 72 | + |
| 73 | + -- get corrections |
| 74 | + if id > 0 then |
| 75 | + for i,line in ipairs(t.list) do |
| 76 | + if type(line.players) == "table" and line.account == account then |
| 77 | + if ADDON.Contains(line.players, id) then |
| 78 | + ep = ep + line.ep |
| 79 | + gp = gp + line.gp |
| 80 | + end |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + return ep, gp |
| 86 | +end |
| 87 | + |
| 88 | +------------------------------------------------------------ |
| 89 | + |
| 90 | +local function GetPoints(group, account, name) |
| 91 | + |
| 92 | + local raids = {} |
| 93 | + for k,v in pairs(ADDON.GetStoredRaids(group)) do |
| 94 | + table.insert(raids, v) |
| 95 | + end |
| 96 | + for k,v in pairs(ADDON.Groups[group].Raids) do |
| 97 | + table.insert(raids, v) |
| 98 | + end |
| 99 | + |
| 100 | + local ep = 0 |
| 101 | + local gp = ADDON.Groups[group].Accounts[account].basegp |
| 102 | + local kills = 0 |
| 103 | + local items = 0 |
| 104 | + |
| 105 | + for _,raid in ipairs(raids) do |
| 106 | + for id,player in pairs(raid.players) do |
| 107 | + if player == name then |
| 108 | + local a, b = GetEP(group, account, raid, id) |
| 109 | + local c, d = GetGP(group, account, raid, id) |
| 110 | + ep = ep + a |
| 111 | + gp = gp + c |
| 112 | + kills = kills + b |
| 113 | + items = items + d |
| 114 | + end |
| 115 | + end |
| 116 | + end |
| 117 | + |
| 118 | + -- apply corrections |
| 119 | + local e, f = GetCorrections(group, account, name) |
| 120 | + ep = ep + e |
| 121 | + gp = gp + f |
| 122 | + |
| 123 | + return math.floor(1000 * ep / gp) / 1000, ep, gp, kills, items |
| 124 | +end |
| 125 | + |
| 126 | +------------------------------------------------------------ |
| 127 | + |
| 128 | +-- exports |
| 129 | +ADDON.GetPoints = GetPoints |
0 commit comments