Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warband currency support #5229

Merged
merged 12 commits into from
Nov 12, 2024
Merged

Conversation

Boneshockx
Copy link
Contributor

@Boneshockx Boneshockx commented Jul 16, 2024

Description

TWW brings warband currencies that can be transferred over to other characters within your warband.
The C_CurrencyInfo API contains currencyData for all warband characters, and so we're able to create a cloning trigger that shows currency info for each character in the warband.

This is a full rework of the currency trigger prototype as this needs to use statesParameter = "full".

Several state values for account wide currencies have been added:

  • accountQuantity (sum of all account characters' quantity)
  • realAccountQuantity (total account quantity after transferring everything to your current character and paying the transfer cost)
  • realCharacterQuantity (remaining quantity if all this character's currency was transfered and paid the transfer cost)
  • transferPercentage (transfer cost %)
  • characterName (comes from currency API)
  • characterGUID (comes from currency API)
  • mainCharacter (bool value to check for the character you are currently playing on)

Example

image

!WA:2!vI1(ZTXv1FRikDy7dSLBstAsBvCE0MKwxhx7usN4o41psCX12zLSDzOG2v7EL2BYQDV9URSJDBhAfbW88lJPq4nfXB(2cfbL3qbZJodZKzoJg(damu6WRbM8paCU3DLLT1QqW)G0Q7EUN3NpNZXjMlLF)JswivPuwPSw5(vlY9wuD0PNFQ1Z7XTiCvdZZBX9ySovDOlVSb3kDwppNakJFHPluWNeCM3CLx7F)0D0rh8LACWt(YYdQuKtTYUeJ0J2Ovlu2Xzek30HOR5Zmmjxh3WmG656Fcn)adEGs(cuxQVTIk(vGsLaoTyrc3)2omp6X3tvls(Yfkiyj)mJn5mJp7KQb4p0mkZn6VIpJ44mHLVY6(LZtwG4gKbPMEHA5gz4mzZLj7WAzvlJmppZXyjcxZ1OeXxrtsA(ZqmCcS34QZWj4v1YmZyto5QLDJubLAMEoLl5MrybjZZnSOL9V4nUQHlTKHWAobCJJVgXWNKjGtClgyF9q3QUEUK6wOokOiNqJ5(etpxl)kcsf2dCq1sgu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orncTRiosKAvpF5Gap3PrWaCH6QIJd3pzN1ep3iFC1InUQmcVM4NJgTnCsjLnQRKArwBQ55Xzv9tkVyg52uQIhTLhmjfFzxsPPgUuvEBcTODWzH(MtoFReEYgoUyfwya5N3V8ZbfFY6ePz4Oz)LRcydzGSB)yQRnCgvX2dWFshEhkW4kWjXga3sJDcenyhL6BGDgTSH5Qn4PN8bgP)hD5PMFe1L98kLaE9jGPBS50TVL9A3imMEe5C5WXsctLuBrrBNZkh7VXaJ4mAAIAC40kCQRyDmITwZM5rBOl0L(vuuG3UsLg6N96mUxreLZpC9NJUVo2Xkdd67RduXQzr9f)xqexKrBSvNCn7hmnIoSTgwkdxqOSnYAtBItWlPlMbrdXvAnb)Po0Hos0AwS0Bs8TbJ8(IHKyLxJcNlhTF2nlwrJ1t7LWg4MWhWwesHpOTQaTeRw6Bo4p0(eNtgRkftPCmOa13YaVjH)Oi7suFdVQDywcMaGb5QnhC8I3ioYCGdMUdVcKFh13YeByu0uN1zZW)Sml0MG9U(whIbrUcxv9aaAWfSHf7FW(6dStauB4CYTjHZl2CeCGs6aM0Jt)Z0HNbQi2DkqhkdlalBlxMAf49j2Mcwk1PGlQdftnOyJqWxhEAKfVtD4jGNexPrStf8U0H39OC49IVqSriU9b8(F(oyhlwFyBMp6YSd3(W4wgne(xI07O1we7JGRLSP1w22j3ulNCV3gUQc8HGF)zH1TR0ym29WoX1K6gt8g(R6W)0M9GxZzXX154yT36BDog4Vh2a1yhW)yhiAf7aT)2BQzbcUn7LQ0yYF454nM19OWF5ScKR9Ev(pYHWElEUjk5FeT5OdmGafdrsHxlbR3R1sLnkE)B2S9gRchrX3V22xgdb7e4Yw2Pw439O)Nd

@Boneshockx Boneshockx force-pushed the feature/currency branch 3 times, most recently from ee62f78 to 995a03c Compare July 29, 2024 22:51
@Boneshockx Boneshockx marked this pull request as ready for review July 29, 2024 23:09
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
@Boneshockx
Copy link
Contributor Author

  • Added sharedStateValues which are applied to main state and clone states.
  • Removed the CopyTable from main state to clones as per result of the above
  • unitName and unitGUID renamed to characterName and characterGUID which is what the WoW API calls them too.
  • hide existing clones if primary checks fail (bugfix)

WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/GenericTrigger.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
@Boneshockx Boneshockx marked this pull request as draft August 26, 2024 17:46
@Boneshockx
Copy link
Contributor Author

I still plan on updating this with the feedback from code review, but I'm just enjoying playing the game a bit too much right now :D

@InfusOnWoW
Copy link
Contributor

That's not a problem. I can also take a look at some of the changes I suggested, but similarly not now..

@Boneshockx Boneshockx marked this pull request as ready for review November 6, 2024 19:08
@Boneshockx
Copy link
Contributor Author

I finaly had some time to come around to this PR again.
All checks are now built in the triggerfunc instead, and then inserted in the ret string.

@InfusOnWoW
Copy link
Contributor

Thanks, I'll take a look at it asap.

WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/GenericTrigger.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
if cloneActive and tostring(%s) ~= %q then cloneActive = false end
]]):format(check.condition, tristateValue))
end
end
Copy link
Contributor

@InfusOnWoW InfusOnWoW Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So while what you are doing for quantityConditions, tristateCondition and cloneConditions to generate the checks is fine, I do think that the code would be easier to understand if it weren't so data-driven, and instead used simple functions, e.g. (And I haven't tested this)

local function createQuantityCheck(property, operator, value, primary)
   local ret = [[   
     if not primaryCheckFailed and currencyInfo[%s] %s %s then
       active = false
       %s
    end
  ]]
  return ret:format(property, operator, value, primary and "primaryCheck = false" or "")
end

And then in triggerFunc

table.insert(quantityChecks, createQuantityCheck("quantity", trigger.value_operator, trigger.value, true))
table.insert(quantityChecks, createQuantityCheck("realCharacterQuantity", trigger.realCharacterQuantity_operator, trigger.realCharacterQuantity, true))
table.insert(quantityChecks, createQuantityCheck("accountQuantity", trigger.accountQuantity_operator, trigger.accountQuantity))

etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reworked the creation of checkstrings in a seperate commit, see bb422f6

WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
WeakAuras/Prototypes.lua Outdated Show resolved Hide resolved
Re-request the account data in the situation where API says the account data is ready but the fetch call returns nil.
@Boneshockx
Copy link
Contributor Author

The code is so much more readable now compared to a couple days ago 😄
I have done as many tests as I could, but I'd like others to check it too, to be sure. There are some things I couldn't test, like season/weekly caps as I don't have any currencies with those caps.

@InfusOnWoW InfusOnWoW merged commit 4722b15 into WeakAuras:main Nov 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants