New release

Leandro Silva [11-06-18 - 10:15]
New release
Filename
LeoTrainer.txt
LeoTrainerConst.lua
LeoTrainerUI.lua
diff --git a/LeoTrainer.txt b/LeoTrainer.txt
index 7c643f6..48ba6d2 100644
--- a/LeoTrainer.txt
+++ b/LeoTrainer.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Trainer
 ## APIVersion: 100024 100025
-## Version: 1.2.1
-## AddOnVersion: 121
+## Version: 1.2.2
+## AddOnVersion: 122
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoTrainerSavedVariables
 ## DependsOn: LeoAltholic
diff --git a/LeoTrainerConst.lua b/LeoTrainerConst.lua
index bbabdc1..6aa629d 100644
--- a/LeoTrainerConst.lua
+++ b/LeoTrainerConst.lua
@@ -3,7 +3,7 @@ LeoTrainer = {}
 LeoTrainerUI = {}
 LeoTrainer.name = "LeoTrainer"
 LeoTrainer.displayName = "Leo's Trainer"
-LeoTrainer.version = "1.2.1"
+LeoTrainer.version = "1.2.2"
 LeoTrainer.chatPrefix = "|c39B027" .. LeoTrainer.name .. "|r: "
 LeoTrainer.setting = nil
 LeoTrainer.hidden = true
diff --git a/LeoTrainerUI.lua b/LeoTrainerUI.lua
index 871f53d..826b042 100644
--- a/LeoTrainerUI.lua
+++ b/LeoTrainerUI.lua
@@ -300,6 +300,17 @@ local function getTraitResearchData(research, craft, line, trait)
     return isKnown, isResearching, doneAt
 end

+local function isLineBeingResearched(research, craft, line)
+    for _, researching in pairs(research.doing[craft]) do
+        if researching.line == line then
+            if researching.doneAt and researching.doneAt - GetTimeStamp() > 0 then
+                return true
+            end
+        end
+    end
+    return false
+end
+
 local function getNumOngoingResearches(research, craft)
     local num = 0
     for _, researching in pairs(research.doing[craft]) do
@@ -671,7 +682,8 @@ function LeoTrainer.FillSlots(trainer, trainee)
                             line = line,
                             lineName = lineName,
                             count = knownCount[char.bio.name][craft][line],
-                            unknownTraits = unknownTraits[char.bio.name][craft][line]
+                            unknownTraits = unknownTraits[char.bio.name][craft][line],
+                            isResearching = isLineBeingResearched(char.research, craft, line)
                         })
                     end
                     table.sort(lineList, function(a, b)
@@ -681,7 +693,7 @@ function LeoTrainer.FillSlots(trainer, trainee)
                     local max = char.research.done[craft].max - getNumOngoingResearches(char.research, craft)
                     for i = 1, max do
                         for j, lineData in ipairs(lineList) do
-                            if not lineData.added then
+                            if not lineData.added and not lineData.isResearching then
                                 local trait, knownList = getFirstUnknownTraitCanBeTrained(craft, lineData.line, lineData.unknownTraits, trainer)
                                 local hasItem = false
                                 if trait ~= nil then