samedi 12 janvier 2019

Select item with rarity - Java

i have a question about selecting items with specified rarity.

I have a Class "Card"

class Card {
    String name;
    int seltenheit;
    ArrayList<String> lore;
    String full_id;
    int id_int;
    byte id_byte;

    Card(String name, int seltenheit, ArrayList<String> lore, String id) {
        this.name = name;
        this.lore = lore;
        this.full_id = id;
        this.id_int = (id.contains(":")) ? Integer.parseInt(id.substring(0, id.indexOf(":")))
                : Integer.parseInt(id);
        this.id_byte = (id.contains(":"))
                ? Byte.parseByte(id.substring(id.indexOf(":") + 1, id.length()))
                : 0;
        this.seltenheit = seltenheit;
    }
}

and i've created a ArrayList with some Cards and every Card has it own "rarity" in this Class it is named "Seltenheit" because I am from Austria.

And i want to select 5 items from this ArrayList with the specified rarity. The rarity is a range between 1 and 100, 100 means it is very common and 1 means it is very rare and so on. So i need a function were it selects random 5 items with the rarity.

Sorry for my bad english :P I hope anyone can help me. Thanks.




Aucun commentaire:

Enregistrer un commentaire