Hello I’m working with custom inventories and items. The player has multiple inventories, where items can be placed and in some UI’s Like a sell/buy I want to get the items count of them by rarity.
I solved this by checking item rarities with the next code:
IsRarityValid(Rarity:rarity, RarityType:concrete_subtype(rarity), IncludeSubRarities:logic)<decides>:void=
if:
IncludeSubRarities?
RarityType[Rarity]
then:
true?
else if:
not IncludeSubRarities?
Type : concrete_subtype(rarity) = RarityType
Instance := Type{}
TryGetRarityAsInt[Rarity] = TryGetRarityAsInt[Instance]
then:
true?
else:
false?
TryGetRarityAsInt<public>(Rarity:rarity)<decides><reads>:int=
if(legendary_rarity[Rarity]):
4
else if(epic_rarity[Rarity]):
3
else if(rare_rarity[Rarity]):
2
else if(uncommon_rarity[Rarity]):
1
else if(common_rarity[Rarity]):
0
else:
false?
-1
Is there a simpler way to approach this? I would like to use just subtype(rarity) but that doesn’t seem feasible as it’s not posible to compare.