-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #639 from WowRarity/635-holiday-texture-fix
Fix the availability check for items that require holiday events
- Loading branch information
Showing
6 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local _, addonTable = ... | ||
|
||
local CONSTANTS = Rarity.Enum | ||
local pairs = pairs | ||
|
||
local HolidayEvents = { | ||
fileDataTexturesToLegacyIconPath = { | ||
[CONSTANTS.ART_TEXTURES.BREWFEST] = CONSTANTS.HOLIDAY_TEXTURES.BREWFEST, | ||
[CONSTANTS.ART_TEXTURES.BREWFEST_END] = CONSTANTS.HOLIDAY_TEXTURES.BREWFEST, | ||
[CONSTANTS.ART_TEXTURES.BREWFEST_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.BREWFEST, | ||
[CONSTANTS.ART_TEXTURES.BREWFEST_START] = CONSTANTS.HOLIDAY_TEXTURES.BREWFEST, | ||
|
||
[CONSTANTS.ART_TEXTURES.DMF_ELWYNN_END] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_ELWYNN_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_ELWYNN_START] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_MULGORE_END] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_MULGORE_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_MULGORE_START] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_TEROKKAR_END] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_TEROKKAR_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
[CONSTANTS.ART_TEXTURES.DMF_TEROKKAR_START] = CONSTANTS.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
|
||
[CONSTANTS.ART_TEXTURES.HALLOWS_END] = CONSTANTS.HOLIDAY_TEXTURES.HALLOWS_END, | ||
[CONSTANTS.ART_TEXTURES.HALLOWS_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.HALLOWS_END, | ||
[CONSTANTS.ART_TEXTURES.HALLOWS_START] = CONSTANTS.HOLIDAY_TEXTURES.HALLOWS_END, | ||
|
||
[CONSTANTS.ART_TEXTURES.HARVEST_END] = CONSTANTS.HOLIDAY_TEXTURES.PILGRIMS_BOUNTY, | ||
[CONSTANTS.ART_TEXTURES.HARVEST_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.PILGRIMS_BOUNTY, | ||
[CONSTANTS.ART_TEXTURES.HARVEST_START] = CONSTANTS.HOLIDAY_TEXTURES.PILGRIMS_BOUNTY, | ||
|
||
[CONSTANTS.ART_TEXTURES.LOVE_END] = CONSTANTS.HOLIDAY_TEXTURES.LOVE_IS_IN_THE_AIR, | ||
[CONSTANTS.ART_TEXTURES.LOVE_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.LOVE_IS_IN_THE_AIR, | ||
[CONSTANTS.ART_TEXTURES.LOVE_START] = CONSTANTS.HOLIDAY_TEXTURES.LOVE_IS_IN_THE_AIR, | ||
|
||
[CONSTANTS.ART_TEXTURES.MIDSUMMER_END] = CONSTANTS.HOLIDAY_TEXTURES.MIDSUMMER_FESTIVAL, | ||
[CONSTANTS.ART_TEXTURES.MIDSUMMER_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.MIDSUMMER_FESTIVAL, | ||
[CONSTANTS.ART_TEXTURES.MIDSUMMER_START] = CONSTANTS.HOLIDAY_TEXTURES.MIDSUMMER_FESTIVAL, | ||
|
||
[CONSTANTS.ART_TEXTURES.WINTERVEIL_END] = CONSTANTS.HOLIDAY_TEXTURES.WINTERS_VEIL, | ||
[CONSTANTS.ART_TEXTURES.WINTERVEIL_IEND] = CONSTANTS.HOLIDAY_TEXTURES.WINTERS_VEIL, | ||
[CONSTANTS.ART_TEXTURES.WINTERVEIL_ONGOING] = CONSTANTS.HOLIDAY_TEXTURES.WINTERS_VEIL, | ||
[CONSTANTS.ART_TEXTURES.WINTERVEIL_START] = CONSTANTS.HOLIDAY_TEXTURES.WINTERS_VEIL, | ||
}, | ||
} | ||
|
||
function HolidayEvents.IsItemAvailableToday(item) | ||
if not item.holidayTexture then | ||
return true | ||
end | ||
|
||
for artTextureID, _ in pairs(Rarity.holiday_textures) do | ||
local legacyTextureIconPath = HolidayEvents.fileDataTexturesToLegacyIconPath[artTextureID] | ||
local isRequiredHolidayEventActive = (legacyTextureIconPath == item.holidayTexture) | ||
if isRequiredHolidayEventActive then | ||
return true | ||
end | ||
end | ||
|
||
return false | ||
end | ||
|
||
Rarity.HolidayEvents = HolidayEvents | ||
return HolidayEvents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local SharedConstants = loadfile("DB/SharedConstants.lua")("Rarity", {}) | ||
local HolidayEvents = loadfile("Core/HolidayEvents.lua")("Rarity", {}) | ||
|
||
describe("HolidayEvents", function() | ||
describe("IsItemAvailableToday", function() | ||
before(function() | ||
Rarity.holiday_textures = {} | ||
end) | ||
|
||
local DARKMOON_FAIRE_ITEM = { | ||
holidayTexture = SharedConstants.HOLIDAY_TEXTURES.DARKMOON_FAIRE, | ||
} | ||
local ITEM_WITHOUT_HOLIDAY_TEXTURE = {} | ||
|
||
it("should return true if the item requires an active holiday event that is currently enabled", function() | ||
Rarity.holiday_textures[SharedConstants.ART_TEXTURES.DMF_ONGOING] = true | ||
assertTrue(HolidayEvents.IsItemAvailableToday(DARKMOON_FAIRE_ITEM)) | ||
end) | ||
|
||
it("should return false if the item requires a specific holiday event to be active, but it is not", function() | ||
assertFalse(HolidayEvents.IsItemAvailableToday(DARKMOON_FAIRE_ITEM)) | ||
end) | ||
|
||
it( | ||
"should return false if only holiday events other than the one required by the item are currently active", | ||
function() | ||
Rarity.holiday_textures[SharedConstants.ART_TEXTURES.LOVE_ONGOING] = true | ||
assertFalse(HolidayEvents.IsItemAvailableToday(DARKMOON_FAIRE_ITEM)) | ||
end | ||
) | ||
|
||
it("should return true if there are active holiday events other than the one required by the item", function() | ||
Rarity.holiday_textures[SharedConstants.ART_TEXTURES.LOVE_ONGOING] = true | ||
Rarity.holiday_textures[SharedConstants.ART_TEXTURES.DMF_ONGOING] = true | ||
assertTrue(HolidayEvents.IsItemAvailableToday(DARKMOON_FAIRE_ITEM)) | ||
end) | ||
|
||
it("should return true if the item doesn't require any holiday event to be active", function() | ||
assertTrue(HolidayEvents.IsItemAvailableToday(ITEM_WITHOUT_HOLIDAY_TEXTURE)) | ||
end) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters