Skip to content
6 changes: 3 additions & 3 deletions 00.testing/tests.runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ end)()
_setfenv(1, {})

if U then
_print("Running VWoWUnit tests...\n ")
-- _print("Running VWoWUnit tests...\n ")

U.TestsEngine:RunAllTestGroups()
-- U.TestsEngine:RunAllTestGroups()

-- U.TestsEngine:RunTestGroupsByTag("grouplooting")

-- U.TestsEngine:RunTestGroupsByTag("grouplooting")
end
41 changes: 36 additions & 5 deletions 10.system/20.core/try/try.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ local ExceptionsDeserializationFactory = using "System.Try.ExceptionsDeserializa

local Class = using "[declare]" "System.Try [Partial]"


Class.ProtectedCall = B.ProtectedCall

Scopify(EScopes.Function, {})

Class.ExceptionsDeserializationFactorySingleton = ExceptionsDeserializationFactory:New()
Expand All @@ -32,6 +29,7 @@ function Class:New(action, exceptionsDeserializationFactory)

return self:Instantiate({
_action = action,
_finallyHandler = nil,
_allExceptionHandlers = {},
_exceptionsDeserializationFactory = exceptionsDeserializationFactory or Class.ExceptionsDeserializationFactorySingleton,
})
Expand All @@ -55,10 +53,20 @@ function Class:Catch(specificExceptionTypeOrExceptionNamespaceString, specificEx
return self
end

function Class:Finally(finallyHandler)
Scopify(EScopes.Function, self)

Guard.Assert.IsFunction(finallyHandler, "finallyHandler")

_finallyHandler = finallyHandler

return self
end

function Class:Run()
Scopify(EScopes.Function, self)

local returnedValuesArray = { Class.ProtectedCall(_action) }
local returnedValuesArray = { B.ProtectedCall(_action) }

local success = A.PopFirst(returnedValuesArray)
if success then
Expand All @@ -70,7 +78,30 @@ function Class:Run()

local properExceptionHandler = self:GetAppropriateExceptionHandler_(exception)
if properExceptionHandler ~= nil then
return properExceptionHandler(exception)
local returnedValuesArray2 = {
B.ProtectedCall(function()
properExceptionHandler(exception)
end)
}

if _finallyHandler ~= nil then
_finallyHandler()
end

local success2 = A.PopFirst(returnedValuesArray2)
if success2 then
return A.Unpack(returnedValuesArray2)
end

local exceptionMessage2 = A.PopFirst(returnedValuesArray2)
local exception2 = _exceptionsDeserializationFactory:DeserializeFromRawExceptionMessage(exceptionMessage2)

Rethrow(exception2)
return
end

if _finallyHandler ~= nil then
_finallyHandler()
end

Rethrow(exception) -- 10
Expand Down
2 changes: 0 additions & 2 deletions 10.system/21.core.tests/using.built.ins/using.built.ins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ local EScopes = using "System.EScopes"
local Validation = using "System.Validation"

-- DO NOT EMPLOY using "[built-in]" HERE BECAUSE IT IS WHAT WE ARE ACTUALLY TESTING!!
local _unpack = Validation.Assert(Global.unpack)

local U = Validation.Assert(Global.VWoWUnit)

local TestsGroup = U.TestsEngine:CreateOrUpdateGroup {
Expand Down
2 changes: 2 additions & 0 deletions 20.externals/20.standard/wow/.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../../Ui.xsd">
<Include file="enums\.xml"/>
<Include file="strenums\.xml"/>

<Include file="ui.parent\.xml"/>
<Include file="localization\.xml"/>
<Include file="create.frame\.xml"/>

<Include file="addons\.xml"/>
<Include file="popups\.xml"/>
<Include file="group.looting\.xml"/>

<Include file="is.alt.key.down\.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local WoWRollOnLoot = using "Pavilion.Warcraft.GroupLooting.BuiltIns.
local WoWGetLootRollItemInfo = using "Pavilion.Warcraft.GroupLooting.BuiltIns.GetLootRollItemInfo"

local GambledItemInfoDto = using "Pavilion.Warcraft.GroupLooting.Contracts.GambledItemInfoDto"
local EWowGamblingResponseType = using "Pavilion.Warcraft.Enums.EWowGamblingResponseType" -- @formatter:on
local EWowGamblingResponseType = using "Pavilion.Warcraft.Enums.EWowGamblingResponseType"

local Service = using "[declare]" "Pavilion.Warcraft.GroupLooting.GroupLootGamblingService"

Expand All @@ -22,9 +22,9 @@ function Service:New(rollOnLoot, getLootRollItemInfo)
Guard.Assert.IsNilOrFunction(rollOnLoot, "rollOnLoot")
Guard.Assert.IsNilOrFunction(getLootRollItemInfo, "getLootRollItemInfo")

return self:Instantiate({ -- @formatter:off
RollOnLoot_ = rollOnLoot or WoWRollOnLoot, -- to help unit testing
GetLootRollItemInfo_ = getLootRollItemInfo or WoWGetLootRollItemInfo, -- to help unit testing
return self:Instantiate({
RollOnLoot_ = rollOnLoot or WoWRollOnLoot, -- to help unit testing
GetLootRollItemInfo_ = getLootRollItemInfo or WoWGetLootRollItemInfo, -- to help unit testing
})
end -- @formatter:on

Expand Down Expand Up @@ -76,21 +76,10 @@ function Service:SubmitSameResponseToAllItemGamblingRequests(gamblingRequestIdsA

Guard.Assert.IsTable(gamblingRequestIdsArray, "gamblingRequestIdsArray")
Guard.Assert.IsEnumValue(EWowGamblingResponseType, wowRollMode, "wowRollMode")

for _, gamblingRequestId in T.GetIndexedPairs(gamblingRequestIdsArray) do
self.RollOnLoot_(gamblingRequestId, wowRollMode)
end
end

function Service:SubmitResponseToItemGamblingRequest(gamblingRequestId, wowRollMode)
Scopify(EScopes.Function, self)

Guard.Assert.IsEnumValue(EWowGamblingResponseType, wowRollMode, "wowRollMode")
Guard.Assert.IsPositiveIntegerOrZero(gamblingRequestId, "gamblingRequestId")

self.RollOnLoot_(gamblingRequestId, wowRollMode) --00

-- 00 https://wowpedia.fandom.com/wiki/API_RollOnLoot the rollid number increases with every
-- roll you have in a party till how high it counts is currently unknown blizzard uses
-- 0 to pass 1 to need an item 2 to greed an item and 3 to disenchant an item in later expansions

return self
end
5 changes: 5 additions & 0 deletions 20.externals/20.standard/wow/popups/.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../../../Ui.xsd">
<!-- ordering is important here -->
<Include file="built.ins\.xml"/>
<Include file="popups.handling.service.lua"/>
</Ui>
5 changes: 5 additions & 0 deletions 20.externals/20.standard/wow/popups/built.ins/.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../../../../Ui.xsd">
<Include file="confirm.loot.roll.lua"/>
<Include file="confirm.loot.slot.lua"/>
<Include file="hide.static.popup.lua"/>
</Ui>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- https://wowpedia.fandom.com/wiki/API_ConfirmLootRoll

local using = assert((_G or getfenv(0) or {}).pvl_namespacer_get)

local B = using "[built-ins]" [[ ConfirmLootRoll = ConfirmLootRoll ]]

local Namespacer = using "System.Namespacer"

Namespacer:Bind("Pavilion.Warcraft.Popups.BuiltIns.ConfirmLootRoll", B.ConfirmLootRoll)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- https://wowpedia.fandom.com/wiki/API_ConfirmLootSlot

local using = assert((_G or getfenv(0) or {}).pvl_namespacer_get)

-- unfortunately ConfirmLootSlot doesnt exist in vanilla wow 1.12
local B = using "[built-ins]" [[ ConfirmLootSlot = ConfirmLootSlot or (function() return false end) ]]

local Namespacer = using "System.Namespacer"

Namespacer:Bind("Pavilion.Warcraft.Popups.BuiltIns.ConfirmLootSlot", B.ConfirmLootSlot)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- https://wowpedia.fandom.com/wiki/API_StaticPopup_Hide

local using = assert((_G or getfenv(0) or {}).pvl_namespacer_get)

local B = using "[built-ins]" [[ HideStaticPopup = StaticPopup_Hide ]]

local Namespacer = using "System.Namespacer"

Namespacer:Bind("Pavilion.Warcraft.Popups.BuiltIns.HideStaticPopup", B.HideStaticPopup)
69 changes: 69 additions & 0 deletions 20.externals/20.standard/wow/popups/popups.handling.service.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
local using = assert((_G or getfenv(0) or {}).pvl_namespacer_get) -- @formatter:off

local Guard = using "System.Guard"
local Scopify = using "System.Scopify"
local EScopes = using "System.EScopes"

local WoWConfirmLootRoll = using "Pavilion.Warcraft.Popups.BuiltIns.ConfirmLootRoll"
local WoWConfirmLootSlot = using "Pavilion.Warcraft.Popups.BuiltIns.ConfirmLootSlot"
local WoWHideStaticPopup = using "Pavilion.Warcraft.Popups.BuiltIns.HideStaticPopup"

local EWowGamblingResponseType = using "Pavilion.Warcraft.Enums.EWowGamblingResponseType"

local Service = using "[declare]" "Pavilion.Warcraft.Popups.PopupsHandlingService"

Scopify(EScopes.Function, {})

function Service:New(confirmLootRoll, confirmLootSlot, hideStaticPopup)
Scopify(EScopes.Function, self)

Guard.Assert.IsNilOrFunction(confirmLootRoll, "confirmLootRoll")
Guard.Assert.IsNilOrFunction(confirmLootSlot, "confirmLootSlot")
Guard.Assert.IsNilOrFunction(hideStaticPopup, "hideStaticPopup")

return self:Instantiate({
ConfirmLootRoll_ = confirmLootRoll or WoWConfirmLootRoll, -- to help unit testing
ConfirmLootSlot_ = confirmLootSlot or WoWConfirmLootSlot, -- to help unit testing
HideStaticPopup_ = hideStaticPopup or WoWHideStaticPopup, -- to help unit testing
})
end -- @formatter:on

function Service:HandlePopupGamblingIntent(gamblingRequestId, intendedGamblingType)
Scopify(EScopes.Function, self)

Guard.Assert.IsPositiveIntegerOrZero(gamblingRequestId, "gamblingRequestId")
Guard.Assert.IsEnumValue(EWowGamblingResponseType, intendedGamblingType, "intendedGamblingType")

if self.ConfirmLootRoll_(gamblingRequestId, intendedGamblingType) ~= false then
self:HidePopupConfirmLootRoll_()
end
end

function Service:HandlePopupItemWillBindToYou(lootSlotIndex)
Scopify(EScopes.Function, self)

Guard.Assert.IsPositiveIntegerOrZero(lootSlotIndex, "lootSlotIndex")

-- todo refactor this drawing inspiration from pfui to have it work with wow 1.12
if self.ConfirmLootSlot_(lootSlotIndex) ~= false then -- 00
self:HidePopupItemWillBindToYou_()
end

-- 00 confirmlootslot() is not available in vanilla wow 1.12
end



-- private space

function Service:HidePopupConfirmLootRoll_()
Scopify(EScopes.Function, self)

HideStaticPopup_("CONFIRM_LOOT_ROLL")
end

function Service:HidePopupItemWillBindToYou_()
Scopify(EScopes.Function, self)

HideStaticPopup_("LOOT_BIND")
end
2 changes: 1 addition & 1 deletion 30.zen.module/zen.domain/engine/.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../../Ui.xsd">
<Include file="greenies.autolooter\.xml"/>
<Include file="greenies.group.autolooting\.xml"/>

<Include file="zen.engine.settings.lua"/>
<Include file="zen.engine.lua"/>
Expand Down
Loading