Quantcast

* Add slash command to automatically solve everything

Jesse Adams [02-25-11 - 11:34]
* Add slash command to automatically solve everything
* Click on race icon to solve artifact (when bar is yellow)
* Icon is dimmed until artifact is solvable
* Prevent sound and solvable message spam in various cases
* Changed color of notification text so it "stands out"
Filename
README
Solvent.lua
Solvent.toc
Solvent.xml
diff --git a/README b/README
index cb860b6..8002771 100644
--- a/README
+++ b/README
@@ -1,14 +1,13 @@
 Solvent - A simple, attractive Archaeology display and helper for World of Warcraft

 Special Thanks:
+Kitsuki, my wife and forever in-game love
 daihenka and Archy
 Ludus of Naz'jatar-US
 The trollers of #wowuidev on irc.freenode.net

 Upcoming Changes:
 * Double right-click surveying
-* Click on artifact bar to solve (when yellow)
-* Add slash command to automatically solve everything that is possible to solve, no matter what it takes
 * Make a configuration dialog
 * Make the window position persist
 * For Brainh: Arrow on minimap that points to closest dig site
@@ -18,6 +17,12 @@ Things to Test:
 * Ensure new race shows up upon first survey

 Changelog:
+2011-02-25:
+* Add slash command to automatically solve everything
+* Click on race icon to solve artifact (when bar is yellow)
+* Icon is dimmed until artifact is solvable
+* Prevent sound and solvable message spam in various cases
+* Changed color of notification text so it "stands out"

 2011-02-23:
 * Display archaeology skill level next to title
diff --git a/Solvent.lua b/Solvent.lua
index 8de48c3..106126d 100644
--- a/Solvent.lua
+++ b/Solvent.lua
@@ -4,6 +4,10 @@ solventDefaultEnabled = 'yes'
 solventDefaultScale = 1.0
 solventDefaultAlpha = 1.0

+function SolventMessage(text)
+  DEFAULT_CHAT_FRAME:AddMessage("[Solvent]: " .. text, 0, 0.6, 0.6)
+end
+
 function TotalKeystonesFromBags()
   keystones = {
     { -- Dwarf
@@ -91,12 +95,19 @@ function GetCurrentArtifactInfoByRace(raceId)
 end

 statusBars = {}
+needToTrainWarningSent = false
+keystones = {}
+solvableWarningSent = {}
 function SolventGetCurrentArtifacts()
   keystones = TotalKeystonesFromBags()

   prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
   if not archaeology then
-    DEFAULT_CHAT_FRAME:AddMessage("Solvent: You need to train Archaeology before I can function!")
+    if not needToTrainWarningSent then
+      SolventMessage("Solvent: You need to train Archaeology before I can function!")
+      needToTrainWarningSent = true
+    end
+
     return
   end
   name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(archaeology)
@@ -111,8 +122,11 @@ function SolventGetCurrentArtifacts()
     print("Race Count: " .. raceCount)
   end

-  soundHasPlayed = false
   for i=1,raceCount do
+    if not solvableWarningSent[i] then
+      solvableWarningSent[i] = 'no'
+    end
+
     local raceName, raceTexture, raceItemID, numFragmentsCollected, numFragmentsRequired = GetArchaeologyRaceInfo(i);
     SetSelectedArtifact(i)
     local artifactName, artifactDescription, artifactRarity, artifactIcon, hoverDescription, keystoneCount, bgTexture = GetSelectedArtifactInfo()
@@ -160,20 +174,30 @@ function SolventGetCurrentArtifacts()
         statusBar = _G["SolventSolveFrameRow" .. raceName .. "StatusBar"]
       end

-      --print(statusBar)
+
+      _G["SolventSolveFrameRow" .. raceName .. "Icon"]:SetFrameLevel(i+1)
+      _G["SolventSolveFrameRow" .. raceName .. "Icon"]:SetAlpha(0.5)
+      _G["SolventSolveFrameRow" .. raceName .. "Icon"]:RegisterForClicks('LeftButtonDown')
+      _G["SolventSolveFrameRow" .. raceName .. "Icon"]:SetScript('OnClick', function(self, statusBar)
+        SolventSolveByRaceId(i)
+      end)
+
       if solvable then
-        if soundHasPlayed == false then
+        if solvableWarningSent[i] == 'no' then
           PlaySoundFile("Interface\\Addons\\Solvent\\sounds\\shooting_star.mp3")
-          DEFAULT_CHAT_FRAME:AddMessage("Archaeology: " .. raceName .. " Artifact '".. artifactName .. "' is now solvable!")
-          soundHasPlayed = true
+          SolventMessage("Archaeology: " .. raceName .. " Artifact '".. artifactName .. "' is now solvable!")
+          solvableWarningSent[i] = 'yes'
         end
         statusBar:SetStatusBarColor(1,1,0)
+        _G["SolventSolveFrameRow" .. raceName .. "Icon"]:SetAlpha(1)
+
       elseif artifactRarity == 0 then
         statusBar:SetStatusBarColor(0,1,0)
       else
         statusBar:SetStatusBarColor(0,0.44,0.87)
       end

+
       statusBar:SetMinMaxValues(0, numFragmentsRequired)
       statusBar:SetValue(numFragmentsCollected)
       statusBar.fragments:SetText(numFragmentsCollected .. ' / ' .. numFragmentsRequired)
@@ -198,7 +222,7 @@ function SolventGetCurrentArtifacts()
 end

 function SolventStartup()
- DEFAULT_CHAT_FRAME:AddMessage("Solvent Archaeology Addon Loaded!")
+ SolventMessage("Archaeology Addon Loaded!")
  RequestArtifactCompletionHistory()
 end

@@ -259,6 +283,75 @@ function SolventProcessVariables()
 	processConfigChange();
 end

+function SolventSolveByRaceId(raceId, useKeystones)
+  local raceName, raceTexture, raceItemID, numFragmentsCollected, numFragmentsRequired = GetArchaeologyRaceInfo(raceId);
+  SetSelectedArtifact(raceId)
+  local artifactName, artifactDescription, artifactRarity, artifactIcon, hoverDescription, keystoneCount, bgTexture = GetSelectedArtifactInfo()
+
+  if SOLVENT_DEBUG then
+    print("Attempting to solve " .. raceName .. " artifact: " .. artifactName)
+  end
+
+  usableKeystones = 0
+  if not keystones[raceId] then return end
+
+  if keystones[raceId]["count"] > keystoneCount then
+    usableKeystones = keystoneCount
+  else
+    usableKeystones = keystones[raceId]["count"]
+  end
+  possibleFragmentsFromKeystones = usableKeystones * 12
+  solvable = false
+  if (possibleFragmentsFromKeystones + numFragmentsCollected) >= numFragmentsRequired then
+    solvable = true
+  end
+
+  if solvable then
+    for stoneCount=1,usableKeystones do
+      if SOLVENT_DEBUG then
+        print("Adding Keystone " .. stoneCount)
+      end
+      SocketItemToArtifact()
+    end
+
+    if CanSolveArtifact() then
+      if SOLVENT_DEBUG then
+        print("Solving!")
+      end
+      SolveArtifact()
+      solvableWarningSent[raceId] = 'no'
+      return true
+    else
+      if SOLVENT_DEBUG then
+        print("Error! Couldn't solve :(")
+      end
+    end
+  else
+    if SOLVENT_DEBUG then
+      print("Could not solve! You only have " .. (possibleFragmentsFromKeystones + numFragmentsCollected) .. " fragments, need " .. numFragmentsRequired)
+    end
+  end
+
+  return false
+end
+
+function SolventSolveAllPossible()
+  local raceCount = GetNumArchaeologyRaces();
+
+  solveCount = 0
+  for raceId=1,raceCount do
+    if SolventSolveByRaceId(raceId) == true then
+      solveCount = solveCount + 1
+    end
+  end
+
+  if solveCount > 0 then
+    SolventMessage("Solved " .. solveCount .. " artifact(s).")
+  else
+    SolventMessage("Could not solve any artifacts.")
+  end
+end
+
 function processConfigChange()
   if not variablesLoaded then return end

@@ -311,3 +404,13 @@ local function modify_display(msg, editbox)
 end
 SlashCmdList["SOLVENT"] = modify_display;

+SLASH_SOLVE1 = '/solve';
+local function solve(command, editbox)
+  command = tonumber(command)
+  if command then
+    SolventSolveByRaceId(command)
+  else
+    SolventSolveAllPossible()
+  end
+end
+SlashCmdList["SOLVE"] = solve;
diff --git a/Solvent.toc b/Solvent.toc
index 5edf0df..7a217e4 100644
--- a/Solvent.toc
+++ b/Solvent.toc
@@ -2,6 +2,7 @@
 ## Name: Solvent
 ## Notes: Arch surveying and solving tool
 ## Author: techno-geek
+## Version: 1.0.3b
 ## SavedVariables: solventConfig
 Solvent.lua
 Solvent.xml
diff --git a/Solvent.xml b/Solvent.xml
index a11b35b..0139d0a 100644
--- a/Solvent.xml
+++ b/Solvent.xml
@@ -8,9 +8,6 @@
 	</Font>

   <Frame name="SolventRowTemplate" virtual="true">
-    <Size>
-      <AbsDimension x="50" y="50" />
-    </Size>
 		<Frames>
 			<Button name="$parentIcon">
 				<Size x="50" y="50" />
@@ -18,7 +15,7 @@
 					<Layer level="OVERLAY">
 						<Texture name="$parentTexture" parentKey="texture" file="Interface\Icons\Ability_ThunderClap">
 							<Size>
-                <AbsDimension x="36" y="36" />
+                <AbsDimension x="50" y="50" />
               </Size>
 						</Texture>
 					</Layer>