1
0
Bifurcation 0

Initial implementation of enhancement in issue 266.

Cette révision appartient à :
Nathanial.C.Jones 2011-01-23 22:45:14 +00:00
Parent 05d2e23463
révision 626a79e0f0
1 fichiers modifiés avec 207 ajouts et 84 suppressions

Voir le fichier

@ -230,6 +230,193 @@ function search_frame:AddResult(cat, what, w)
end
end
local function searchNPC(input, yield_countdown, yield_countdown_max)
local list = QuestHelper_Objectives_Local["monster"]
if list then
for n in pairs(list) do
self:AddResult("monster", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_LOCAL", QHText("SEARCHING_NPCS"))))
end
end
end
list = QuestHelper_StaticData[QuestHelper.locale].objective
list = list and list.monster
if list then
for n in pairs(list) do
self:AddResult("monster", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_STATIC", QHText("SEARCHING_NPCS"))))
end
end
end
return yield_countdown
end
local elders = {
["Alliance"] = {
["Bladeswift"] = "DARNASSUS 39 32",
["Bronzebeard"] = "IRONFORGE 29 16",
["Hammershout"] = "Elwynn Forest 34 50"
},
["Horde"] = {
["Darkhorn"] = "Orgrimmar 52 60",
["Wheathoof"] = "Thunder Bluff 72 33",
["Darkcore"] = "Undercity 67 38"
},
["Kalimdor"] = {
["Riversong"] = "Ashenvale 35 48",
["Skygleam"] = "Azshara 64 79",
["High Mountain"] = "Southern Barrens 41 47", -- 41.5 47.5
["Moonwarden"] = "Northern Barrens 48 59", -- 48.5 59.2
["Windtotem"] = "Northern Barrens 68 69",
["Starweave"] = "Darkshore 49 19", -- 49.5 19.0
["Runetotem"] = "Durotar 54 44",
["Nightwind"] = "Felwood 37 52",
["Grimtotem"] = "Feralas 76 37",
["Mistwalker"] = "Feralas 62 31",
["Bloodhoof"] = "Mulgore 48 53",
["Bladesing"] = "Silithus 53 35",
["Primestone"] = "Silithus 30 13", -- 30.7 13.3
["Dreamseer"] = "Tanaris 50 28",
["Ragetotem"] = "Tanaris 36 80",
["Bladeleaf"] = "Teldrassil 57 53",
["Skyseer"] = "Thousand Needles 45 50",
["Morningdew"] = "Thousand Needles 77 75", -- 77.0 75.6
["Thunderhorn"] = "Un'Goro Crater 51 75",
["Brightspear"] = "Winterspring 53 56", -- 53.0 56.7
["Stonespire"] = "Winterspring 60 50", -- 60.0 50.0
},
["Eastern Kingdoms"] = {
["Bellowrage"] = "Blasted Lands 54 49",
["Rumblerock"] = "Burning Steppes 70 45",
["Dawnstrider"] = "Burning Steppes 53 24",
["Goldwell"] = "Dun Morogh 53 49",
["Windrun"] = "Eastern Plaguelands 35 68",
["Snowcrown"] = "Eastern Plaguelands 75 54",
["Stormbrow"] = "Elwynn Forest 40 63",
["Highpeak"] = "Hinterlands 50 48",
["Silvervein"] = "Loch Modan 33 46",
["Ironband"] = "Searing Gorge 21 79",
["Obsidian"] = "Silverpine Forest 45 41",
["Starglade"] = "Stranglethorn Vale 63 22", -- Jungle 71 34
["Winterhoof"] = "Stranglethorn Vale 37 79", -- Cape 39 72
["Graveborn"] = "Tirisfal Glades 61 53",
["Moonstrike"] = "Western Plaguelands 69 73",
["Meadowrun"] = "Western Plaguelands 63 36",
["Skychaser"] = "Westfall 56 47"
},
["Northrend"] = {
["Arp"] = "Borean Tundra 57 44",
["Northal"] = "Borean Tundra 34 34",
["Pamuya"] = "Borean Tundra 43 50",
["Sardis"] = "Borean Tundra 59 66",
["Morthie"] = "Dragonblight 30 56",
["Skywarden"] = "Dragonblight 35 48",
["Thoim"] = "Dragonblight 49 78",
["Beldak"] = "Grizzly Hills 61 28",
["Lunaro"] = "Grizzly Hills 81 37",
["Whurain"] = "Grizzly Hills 64 47",
["Bluewolf"] = "Lake Wintergrasp 49 14",
["Sandrene"] = "Sholazar Basin 50 64",
["Wanikaya"] = "Sholazar Basin 64 49",
["Fargal"] = "Storm Peaks 29 74",
["Graymane"] = "Storm Peaks 41 85",
["Muraco"] = "Storm Peaks 64 51",
["Stonebeard"] = "Storm Peaks 31 38",
["Tauros"] = "Zul'Drak 59 56"
}
}
local function searchItem(input, yield_countdown, yield_countdown_max)
local list = QuestHelper_Objectives_Local["item"]
if list then
for n in pairs(list) do
self:AddResult("item", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_LOCAL", QHText("SEARCHING_ITEMS"))))
end
end
end
list = QuestHelper_StaticData[QuestHelper.locale].objective
list = list and list.item
if list then
for n in pairs(list) do
self:AddResult("item", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_STATIC", QHText("SEARCHING_ITEMS"))))
end
end
end
return yield_countdown
end
local function searchLoc(input, yield_countdown, yield_countdown_max)
local _, _, region, x, y = string.find(input, "^%s*([^%d%.]-)%s*([%d%.]+)%s*[,;:]?%s*([%d%.]+)%s*$")
if region then
x, y = tonumber(x), tonumber(y)
if x and y then
x, y = x*0.01, y*0.01
if region == "" then
self:AddResult("loc", string.format("%d,%.3f,%.3f", QuestHelper.i, x, y), 0)
else
for i, name in pairs(QuestHelper_NameLookup) do
self:AddResult("loc", string.format("%d,%.3f,%.3f", i, x, y), fuzzyCompare(region, string.upper(name)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHText("SEARCHING_ZONES")))
end
end
end
end
end
return yield_countdown
end
local function searchElders(input, yield_countdown, yield_countdown_max)
local yc = yield_countdown
local achievement_match, elder_match = false, false
for achievement, eldrs in pairs(elders) do
if input and input ~= "" then
if input == achievement then achievement_match = true end
end
for elder, elder_loc in pairs(eldrs) do
if input and input ~= "" then
if achievement_match then -- just add it
yc = searchLoc(elder_loc, yc, yield_countdown_max)
elseif input == elder then -- We have input and it's not an achievement, so it must be an elder.
elder_match = true
yc = searchLoc(elder_loc, yc, yield_countdown_max)
break -- We've found him or her.
end -- No need for else here. We've got input so we either have an achievement or we have an elder.
else -- We came in without an input, therefore we add all.
yc = searchLoc(elder_loc, yc, yield_countdown_max)
end
end
if achievement_match or elder_match then break end -- We've done our match.
end
return yc
end
function search_frame:SearchRoutine(input)
if input == "" then
for obj in pairs(QuestHelper.user_objectives) do
@ -241,95 +428,31 @@ function search_frame:SearchRoutine(input)
input = string.upper(input)
local _, _, command, argument = string.find(input, "^%s*([^%s]-)%s+(.-)%s*$")
local search_item, search_npc, search_loc = false, false, false
if command and argument then
if command == "ITEM" then
search_item, input = true, argument
elseif command == "NPC" or command == "MONSTER" then
search_npc, input = true, argument
elseif command == "LOCATION" or command == "LOC" then
search_loc, input = true, argument
else
search_item, search_npc, search_loc = true, true, true
end
else
search_item, search_npc, search_loc = true, true, true
end
local search_item, search_npc, search_loc, search_elders = false, false, false, false
local yield_countdown_max = math.max(1, math.floor(2000/string.len(input)+0.5))
local yield_countdown = yield_countdown_max
if search_item then
local list = QuestHelper_Objectives_Local["item"]
if list then for n in pairs(list) do
self:AddResult("item", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_LOCAL", QHText("SEARCHING_ITEMS"))))
end
end end
list = QuestHelper_StaticData[QuestHelper.locale].objective
list = list and list.item
if list then for n in pairs(list) do
self:AddResult("item", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_STATIC", QHText("SEARCHING_ITEMS"))))
end
end end
end
if search_npc then
local list = QuestHelper_Objectives_Local["monster"]
if list then for n in pairs(list) do
self:AddResult("monster", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_LOCAL", QHText("SEARCHING_NPCS"))))
end
end end
list = QuestHelper_StaticData[QuestHelper.locale].objective
list = list and list.monster
if list then for n in pairs(list) do
self:AddResult("monster", n, fuzzyCompare(input, string.upper(n)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHFormat("SEARCHING_STATIC", QHText("SEARCHING_NPCS"))))
end
end end
end
if search_loc then
local _, _, region, x, y = string.find(input, "^%s*([^%d%.]-)%s*([%d%.]+)%s*[,;:]?%s*([%d%.]+)%s*$")
if region then
x, y = tonumber(x), tonumber(y)
if x and y then
x, y = x*0.01, y*0.01
if region == "" then
self:AddResult("loc", string.format("%d,%.3f,%.3f", QuestHelper.i, x, y), 0)
else
for i, name in pairs(QuestHelper_NameLookup) do
self:AddResult("loc", string.format("%d,%.3f,%.3f", i, x, y), fuzzyCompare(region, string.upper(name)))
yield_countdown = yield_countdown - 1
if yield_countdown == 0 then
yield_countdown = yield_countdown_max
coroutine.yield(QHFormat("SEARCHING_STATE", QHText("SEARCHING_ZONES")))
end
end
end
end
if command and argument then
if command == "ITEM" then
searchItem(argument, yield_countdown, yield_countdown_max)
elseif command == "NPC" or command == "MONSTER" then
searchNPC(argument, yield_countdown, yield_countdown_max)
elseif command == "LOCATION" or command == "LOC" then
searchLoc(argument, yield_countdown, yield_countdown_max)
elseif command == "ELDER" or command == "ELDERS" then
searchElders(argument, yield_countdown, yield_countdown_max)
else
yield_countdown = searchItem(input, yield_countdown, yield_countdown_max)
yield_countdown = searchNPC(input, yield_countdown, yield_countdown_max)
searchLoc(input, yield_countdown, yield_countdown_max)
end
else
yield_countdown = searchItem(input, yield_countdown, yield_countdown_max)
yield_countdown = searchNPC(input, yield_countdown, yield_countdown_max)
searchLoc(input, yield_countdown, yield_countdown_max)
end
return QHText("SEARCHING_DONE")
end