File Flowerpicker.lua changed (mode: 100644) (index f617c8e..e40a7e3) |
... |
... |
local function isPermissibleSpellToProduceLoot(spellName) |
218 |
218 |
|
|
219 |
219 |
if 'Fishing' == n then |
if 'Fishing' == n then |
220 |
220 |
result = true |
result = true |
221 |
|
elseif 'Herbalism' == n then |
|
|
221 |
|
elseif 'Herb Gathering' == n then |
222 |
222 |
result = true |
result = true |
223 |
223 |
end |
end |
224 |
224 |
|
|
|
... |
... |
local function mapSpellNameToHarvestTypeDesignation(spellName) |
261 |
261 |
assert (validateAnyName(s)) |
assert (validateAnyName(s)) |
262 |
262 |
local t = nil |
local t = nil |
263 |
263 |
|
|
264 |
|
if 'Herbalism' == s then |
|
|
264 |
|
if 'Herb Gathering' == s then |
265 |
265 |
t = 'HERBALISM' |
t = 'HERBALISM' |
266 |
266 |
elseif 'Fishing' == s then |
elseif 'Fishing' == s then |
267 |
267 |
t = 'FISHING' |
t = 'FISHING' |
|
... |
... |
local function mapSpellNameToHarvestTypeDesignation(spellName) |
269 |
269 |
t = string.upper(s) |
t = string.upper(s) |
270 |
270 |
end |
end |
271 |
271 |
|
|
272 |
|
assert (validateEnum(s, getPermissibleHarvestTypeSet())) |
|
|
272 |
|
assert (validateEnum(t, getPermissibleHarvestTypeSet())) |
273 |
273 |
return t |
return t |
274 |
274 |
end |
end |
275 |
275 |
|
|
|
... |
... |
local function registerMoneyGainFromCorpse(moneyAmount, corpseName) |
416 |
416 |
persistEventHarvest(e) |
persistEventHarvest(e) |
417 |
417 |
end |
end |
418 |
418 |
|
|
|
419 |
|
local function registerLootGainFromResourceNode(itemName, itemQuantity, resourceNodeName, harvestTypeDesignation) |
|
420 |
|
local e = createEventHarvestWithDefaults(harvestTypeDesignation, resourceNodeName, itemName, itemQuantity) |
|
421 |
|
persistEventHarvest(e) |
|
422 |
|
end |
|
423 |
|
|
419 |
424 |
local function processLoot(lootCache, slotId, lastSpellCastName, lootedCorpseGuessedName, playerMoneyDiff) |
local function processLoot(lootCache, slotId, lastSpellCastName, lootedCorpseGuessedName, playerMoneyDiff) |
420 |
425 |
local spellName = sanitiseAnyName(lastSpellCastName) |
local spellName = sanitiseAnyName(lastSpellCastName) |
421 |
426 |
local d |
local d |
|
... |
... |
local function processLoot(lootCache, slotId, lastSpellCastName, lootedCorpseGue |
467 |
472 |
table.insert(FlowerpickerSavedVariables, e) |
table.insert(FlowerpickerSavedVariables, e) |
468 |
473 |
end |
end |
469 |
474 |
|
|
470 |
|
local function handleLootSlotCleared(lootCache, slotId, someSpellName, someCorpseName) |
|
|
475 |
|
local function handleLootSlotCleared(lootCache, slotId, someSpellName, someCorpseName, someVictimName) |
471 |
476 |
assert (lootCache ~= nil) |
assert (lootCache ~= nil) |
472 |
477 |
assert ('table' == type(lootCache)) |
assert ('table' == type(lootCache)) |
473 |
478 |
assert (slotId ~= nil) |
assert (slotId ~= nil) |
|
... |
... |
local function handleLootSlotCleared(lootCache, slotId, someSpellName, someCorps |
480 |
485 |
--[[ See `handlePlayerMoney` function. ]]-- |
--[[ See `handlePlayerMoney` function. ]]-- |
481 |
486 |
return |
return |
482 |
487 |
elseif isPermissibleSpellToProduceLoot(sp) then |
elseif isPermissibleSpellToProduceLoot(sp) then |
483 |
|
error('TODO') |
|
|
488 |
|
local lootedItem = getCachedItemInfo(lootCache, slotId) |
|
489 |
|
assert (lootedItem ~= nil) |
|
490 |
|
assert ('table' == type(lootedItem)) |
|
491 |
|
|
|
492 |
|
i = sanitiseAnyName(lootedItem[2]) |
|
493 |
|
assert (validateAnyName(i)) |
|
494 |
|
q = sanitiseShort(lootedItem[3]) |
|
495 |
|
assert (validatePositiveAndNonZero(q)) |
|
496 |
|
|
|
497 |
|
local d = mapSpellNameToHarvestTypeDesignation(sp) |
|
498 |
|
assert (validateAnyName(d)) |
|
499 |
|
assert (validateEnum(d, getPermissibleHarvestTypeSet())) |
|
500 |
|
local s = sanitiseAnyName(someVictimName) |
|
501 |
|
assert (validateAnyName(s)) |
|
502 |
|
|
|
503 |
|
registerLootGainFromResourceNode(i, q, s, d) |
484 |
504 |
elseif true == validateAnyName(cr) then |
elseif true == validateAnyName(cr) then |
485 |
505 |
local lootedItem = getCachedItemInfo(lootCache, slotId) |
local lootedItem = getCachedItemInfo(lootCache, slotId) |
486 |
506 |
assert (lootedItem ~= nil) |
assert (lootedItem ~= nil) |
|
... |
... |
local function main(self, event, arg1, arg2, arg3, arg4, arg5) |
530 |
550 |
local spellName = sanitiseAnyName(arg2) |
local spellName = sanitiseAnyName(arg2) |
531 |
551 |
self.api.lastSpellCastName = spellName |
self.api.lastSpellCastName = spellName |
532 |
552 |
end |
end |
|
553 |
|
elseif 'UNIT_SPELLCAST_SENT' == event then |
|
554 |
|
self.api.lastSpellTargetName = sanitiseAnyName(arg4) |
533 |
555 |
elseif 'LOOT_OPENED' == event then |
elseif 'LOOT_OPENED' == event then |
534 |
556 |
updateLootCache(FlowerpickerLootCache) |
updateLootCache(FlowerpickerLootCache) |
535 |
557 |
if (1 == UnitIsDead('target')) then |
if (1 == UnitIsDead('target')) then |
|
... |
... |
local function main(self, event, arg1, arg2, arg3, arg4, arg5) |
545 |
567 |
assert ('table' == type(lootCache)) |
assert ('table' == type(lootCache)) |
546 |
568 |
local lastSpellCastName = sanitiseAnyName(self.api.lastSpellCastName) |
local lastSpellCastName = sanitiseAnyName(self.api.lastSpellCastName) |
547 |
569 |
local corpseName = sanitiseAnyName(self.api.lastLootedCorpseName) |
local corpseName = sanitiseAnyName(self.api.lastLootedCorpseName) |
|
570 |
|
local nodeName = sanitiseAnyName(self.api.lastSpellTargetName) |
548 |
571 |
self.api.lootSlotId = slotId |
self.api.lootSlotId = slotId |
549 |
|
handleLootSlotCleared(lootCache, slotId, lastSpellCastName, corpseName) |
|
|
572 |
|
handleLootSlotCleared(lootCache, slotId, lastSpellCastName, corpseName, nodeName) |
550 |
573 |
elseif 'LOOT_CLOSED' == event then |
elseif 'LOOT_CLOSED' == event then |
551 |
574 |
clearLootCache(FlowerpickerLootCache) |
clearLootCache(FlowerpickerLootCache) |
552 |
575 |
self.api.lootSlotId = nil |
self.api.lootSlotId = nil |
|
... |
... |
local function init() |
610 |
633 |
|
|
611 |
634 |
addonFrame:UnregisterEvent('ADDON_LOADED') |
addonFrame:UnregisterEvent('ADDON_LOADED') |
612 |
635 |
addonFrame:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED') |
addonFrame:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED') |
|
636 |
|
addonFrame:RegisterEvent('UNIT_SPELLCAST_SENT') |
613 |
637 |
addonFrame:RegisterEvent('LOOT_OPENED') |
addonFrame:RegisterEvent('LOOT_OPENED') |
614 |
638 |
addonFrame:RegisterEvent('LOOT_SLOT_CLEARED') |
addonFrame:RegisterEvent('LOOT_SLOT_CLEARED') |
615 |
639 |
addonFrame:RegisterEvent('LOOT_CLOSED') |
addonFrame:RegisterEvent('LOOT_CLOSED') |