added xp for current/last/before last dolmens and only rebuff/dismiss assistant when started

Leandro Silva [04-12-20 - 14:25]
added xp for current/last/before last dolmens and only rebuff/dismiss assistant when started
Filename
LeoDolmenRunner.lua
LeoDolmenRunner.txt
LeoDolmenRunner.xml
Runner.lua
Ui.lua
diff --git a/LeoDolmenRunner.lua b/LeoDolmenRunner.lua
index b00130c..36d5359 100644
--- a/LeoDolmenRunner.lua
+++ b/LeoDolmenRunner.lua
@@ -1,7 +1,7 @@
 LeoDolmenRunner = {
     name = "LeoDolmenRunner",
     displayName = "Leo's Dolmen Runner",
-    version = "1.1.7",
+    version = "1.2.0",
     chatPrefix = "|c39B027LeoDolmenRunner|r: ",
     isDebug = false,
     defaults = {
diff --git a/LeoDolmenRunner.txt b/LeoDolmenRunner.txt
index 9729c3d..551c52a 100644
--- a/LeoDolmenRunner.txt
+++ b/LeoDolmenRunner.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Dolmen Runner
 ## APIVersion: 100029 100030
-## Version: 1.1.7
-## AddOnVersion: 117
+## Version: 1.2.0
+## AddOnVersion: 120
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoDolmenRunner_Data
 ## DependsOn: LibFeedback LibAddonMenu-2.0 LibSavedVars
diff --git a/LeoDolmenRunner.xml b/LeoDolmenRunner.xml
index 4a591bd..7efc767 100644
--- a/LeoDolmenRunner.xml
+++ b/LeoDolmenRunner.xml
@@ -4,7 +4,7 @@
     <Controls>

         <TopLevelControl name="LeoDolmenRunnerWindow" movable="true" mouseEnabled="true" clampedToScreen="true" hidden="true" tier="MEDIUM">
-            <Dimensions x="300" y="250" />
+            <Dimensions x="300" y="370" />
             <Anchor point="TOP" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="100" />

             <OnMoveStop> LeoDolmenRunner.ui:OnWindowMoveStop() </OnMoveStop>
@@ -50,7 +50,7 @@

                 <Backdrop name="LeoDolmenRunnerWindowPanel" tier="1" centerColor="000000" edgeColor="202020" hidden="false" clampedToScreen="true" movable="false" mouseEnabled="true">
                     <Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="LeoDolmenRunnerWindow" offsetX="0" offsetY="42"/>
-                    <Dimensions x="300" y="200"/>
+                    <Dimensions x="300" y="290"/>
                     <Edge edgeSize="1"/>
                     <Controls>

@@ -99,6 +99,33 @@
                             <Anchor point="TOPLEFT" relativeTo="$(parent)DolmensClosedLabel" relativePoint="TOPRIGHT" offsetX="10" offsetY="0" />
                         </Label>

+                        <Label name="$(parent)CurrentDolmenLabel" text="Current Dolmen" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="RIGHT">
+                            <Dimensions x="120" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="5" offsetY="160" />
+                        </Label>
+                        <Label name="$(parent)CurrentDolmen" text="0" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="LEFT">
+                            <Dimensions x="100" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)CurrentDolmenLabel" relativePoint="TOPRIGHT" offsetX="10" offsetY="0" />
+                        </Label>
+
+                        <Label name="$(parent)LastDolmenLabel" text="Last Dolmen" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="RIGHT">
+                            <Dimensions x="120" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="5" offsetY="190" />
+                        </Label>
+                        <Label name="$(parent)LastDolmen" text="0" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="LEFT">
+                            <Dimensions x="100" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)LastDolmenLabel" relativePoint="TOPRIGHT" offsetX="10" offsetY="0" />
+                        </Label>
+
+                        <Label name="$(parent)BeforeLastDolmenLabel" text="Before Last" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="RIGHT">
+                            <Dimensions x="120" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="5" offsetY="220" />
+                        </Label>
+                        <Label name="$(parent)BeforeLastDolmen" text="0" font="LeoDolmenRunnerNormalFont" verticalAlignment="CENTER" horizontalAlignment="LEFT">
+                            <Dimensions x="100" y="35" />
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)BeforeLastDolmenLabel" relativePoint="TOPRIGHT" offsetX="10" offsetY="0" />
+                        </Label>
+
                         <Button name="$(parent)StartStop" clickSound="Click">
                             <Anchor point="BOTTOMLEFT" relativeTo="$(parent)Panel" relativePoint="BOTTOMLEFT" offsetX="5" offsetY="-5" />
                             <Dimensions x="75" y="30"/>
diff --git a/Runner.lua b/Runner.lua
index ed84461..e663f09 100644
--- a/Runner.lua
+++ b/Runner.lua
@@ -9,6 +9,9 @@ local Runner = {
         xpPerMinute = 0,
         minutesToLevel = 0,
         hoursToLevel = 0,
+        currentDolmen = 0,
+        lastDomen = 0,
+        beforeLastDolmen = 0,
         events = {}
     },
     defaultData = {
@@ -18,6 +21,9 @@ local Runner = {
         xpPerMinute = 0,
         minutesToLevel = 0,
         hoursToLevel = 0,
+        currentDolmen = 0,
+        lastDolmen = 0,
+        beforeLastDolmen = 0,
         events = {}
     },
     directions = {
@@ -77,9 +83,13 @@ local Runner = {
 function Runner:Start()
     LeoDolmenRunner.log("Starting runner")
     local direction = Runner.data.direction
+    local lastDolmen = Runner.data.lastDolmen or 0
+    local beforeLastDolmen = Runner.data.beforeLastDolmen or 0
     ZO_ShallowTableCopy(Runner.defaultData, Runner.data)
     Runner.data.startedTime = GetTimeStamp()
     Runner.data.direction = direction
+    Runner.data.lastDolmen = lastDolmen
+    Runner.data.beforeLastDolmen = beforeLastDolmen
     Runner.started = true
     LeoDolmenRunnerWindowPanelStartStopLabel:SetText("Stop")
     LeoDolmenRunner.ui:CreateUI()
@@ -135,6 +145,7 @@ function Runner:OnFastTravelInteraction(currentWayshrine)
         LeoDolmenRunner.log("Can't fast travel: " .. name .. " not discovered yet.")
         return
     end
+
     FastTravelToNode(nextWayshrine)
 end

@@ -232,6 +243,8 @@ function Runner:IsBuffActive(collectible)
 end

 function Runner:OnCombatState(inCombat)
+    if not Runner.started then return end
+
     if IsUnitDead("player") then
         zo_callLater(function() Runner:OnCombatState(inCombat) end, 500)
         return
@@ -266,13 +279,22 @@ function Runner:OnCombatState(inCombat)
 end

 function Runner:OnExperienceGain(reason, level, previousExperience, currentExperience, championPoints)
+    if not Runner.started then return end
+
     local event = {
         timestamp = GetTimeStamp(),
         xp = currentExperience - previousExperience
     }
     table.insert(Runner.data.events, event)

-    if reason == 7 then Runner.data.dolmensClosed = Runner.data.dolmensClosed + 1 end
+    Runner.data.currentDolmen = Runner.data.currentDolmen + event.xp
+
+    if reason == 7 then
+        Runner.data.dolmensClosed = Runner.data.dolmensClosed + 1
+        Runner.data.beforeLastDolmen = Runner.data.lastDolmen
+        Runner.data.lastDolmen = Runner.data.currentDolmen
+        Runner.data.currentDolmen = 0
+    end

     self:UpdateData()
 end
diff --git a/Ui.lua b/Ui.lua
index 05659d1..f0f0c19 100644
--- a/Ui.lua
+++ b/Ui.lua
@@ -128,6 +128,9 @@ function Ui:Update(tick)
     end

     LeoDolmenRunnerWindowPanelDolmensClosed:SetText(LDR.runner.data.dolmensClosed)
+    LeoDolmenRunnerWindowPanelCurrentDolmen:SetText(FormatNumber(LDR.runner.data.currentDolmen))
+    LeoDolmenRunnerWindowPanelLastDolmen:SetText(FormatNumber(LDR.runner.data.lastDolmen))
+    LeoDolmenRunnerWindowPanelBeforeLastDolmen:SetText(FormatNumber(LDR.runner.data.beforeLastDolmen))
     LeoDolmenRunnerWindowPanelXP:SetText(FormatNumber(math.ceil(LDR.runner.data.xpPerMinute)) .. " / min")

     LeoDolmenRunnerWindowPanelXPNext:SetText(ZO_CachedStrFormat(GetString(SI_TIME_FORMAT_HHMM_DESC_SHORT), LDR.runner.data.hoursToLevel, LDR.runner.data.minutesToLevel))