I want to practice java creating a LootBox Open System. I just tried this.
-Creating an Interface called Tier.
-Creating UltimateTier,PremiumTier,StandardTier classes that implements Tier Interface.
-Creating classes like Gold that extends UltimateTier,Titanium extends UltimateTier, Silver extends PremiumTier, etc.
Then I use org.reflections to find classes that inherits from another to create chances to get rare items like gold with this code
Tier[] tierItem = new Tier[3];
for (int i = 0; i < 3; i++) {
int itemQuality = (int)(1 + Math.random()* 10);
int itemQuality = 1;
if (itemQuality == 1) {
tierItem[i] = new UltimateItemTier().getItem();
}
if (itemQuality >= 2 && itemQuality <= 4) {
tierItem[i] = new PremiumItemTier();
}
if (itemQuality >= 5) {
tierItem[i] = new StandardItemTier();
}
}
return tierItem;
It returns me a list of 3 TIERITEMS, but I need to choose randomly 1 of those items for according to each tier on the list.
for example, if there is 10 PremiumItems and when I open the StandarBox, the list return "PremiumTier", "PremiumTier" , "StandardTier", the code must select any random item that inherits or match that Tier.
So list must return ( for example ) "Silver(PremiumTier), PremiumMetal(PremiumTier), Wood(StandardTier)
question from:
https://stackoverflow.com/questions/66054133/how-to-create-lootbox-system-like-videogames 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…