Closed kodawah closed 1 month ago
@axxroytovu can correct me if I'm wrong, but I think we cannot add chance
and weight
to the underlying content data type because it would break the configurations where you have multiple products in the same config, while in the new system it would be just a separate entry in the variable_config
How are you handling card_count
which is currently an integer?
I'm working through how to make this work, but distributing the weight correctly into nested variable maps is proving tricky.
I don't use card_count
but from what i can tell, it gets exposed as a plain field outside of contents
no?
Ah, it gets pre-processed by MTGJson.
that could be another option, having an array of variable config outside of contents to be read only in case the sealed product contains variable stuff
We introduced the
chance
variable to accommodate for variable items appearing with a different drop rate (see https://github.com/mtgjson/mtg-sealed-content/issues/209)Previously, the variable.configs could be marshaled to json as an array containing the list of possible items described as a key:value pair, where the value matched the data type of the parent level
contents
. This has a few upsides, namely being able to unmarshal the data as amap[string]content
and make the code forward compatible with any new sealed type we might introduce.The introduction of the
chance
variable broke this assumption and requires custom handling for each data type, and introduce a separate data type for each sealed product type. We also have the minor drawback that we don't see the total weight of the variable configuration, which makes us parse the whole variable configuration to understand the correct drop rate.My proposal is: instead of introducing just a
chance
variable add a new sealed data type,variable_config
containingchance
andweight
, for each element of the variable section. In other wordsThis makes the
variable.configs
data type consistent with itself, exposesweight
(albeit in a redundant way, tho very human readable) and heavily simplifies the parsing of both variables.Thoughts? @axxroytovu @ZeldaZach and @staghouse