Search in sources :

Example 6 with Rarity

use of mage.constants.Rarity in project mage by magefree.

the class CardPanelTypeComparator method compare.

@Override
public int compare(MageCard o1, MageCard o2) {
    Rarity r1 = o1.getOriginal().getRarity();
    Rarity r2 = o2.getOriginal().getRarity();
    int val = Integer.compare(r1 == null ? 0 : r1.getSorting(), r2 == null ? 0 : r2.getSorting());
    if (val == 0) {
        return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
    } else {
        return val;
    }
}
Also used : Rarity(mage.constants.Rarity)

Example 7 with Rarity

use of mage.constants.Rarity in project mage by magefree.

the class VintageMasters method addSpecialCards.

@Override
protected void addSpecialCards(List<Card> booster, int number) {
    // number is here always 1
    Rarity rarity;
    // You will open a Power Nine card about once in 53 packs
    if (RandomUtil.nextInt(53) == 0) {
        rarity = Rarity.BONUS;
    } else {
        // assuming same distribution as foils in paper Masters sets, 10:3:1 C:U:R
        int rarityKey = RandomUtil.nextInt(112);
        if (rarityKey < 80) {
            rarity = Rarity.COMMON;
        } else if (rarityKey < 104) {
            rarity = Rarity.UNCOMMON;
        } else if (rarityKey < 111) {
            rarity = Rarity.RARE;
        } else {
            rarity = Rarity.MYTHIC;
        }
    }
    addToBooster(booster, getCardsByRarity(rarity));
}
Also used : Rarity(mage.constants.Rarity)

Example 8 with Rarity

use of mage.constants.Rarity in project mage by magefree.

the class ExpansionSet method addDoubleFace.

/* add double faced card for Innistrad booster
     * rarity near as the normal distribution
     */
protected void addDoubleFace(List<Card> booster) {
    Rarity rarity;
    for (int i = 0; i < numBoosterDoubleFaced; i++) {
        int rarityKey = RandomUtil.nextInt(121);
        if (rarityKey < 66) {
            rarity = Rarity.COMMON;
        } else if (rarityKey < 108) {
            rarity = Rarity.UNCOMMON;
        } else if (rarityKey < 120) {
            rarity = Rarity.RARE;
        } else {
            rarity = Rarity.MYTHIC;
        }
        addToBooster(booster, getSpecialCardsByRarity(rarity));
    }
}
Also used : Rarity(mage.constants.Rarity)

Example 9 with Rarity

use of mage.constants.Rarity in project mage by magefree.

the class ExpansionSet method tryBooster.

public List<Card> tryBooster() {
    List<Card> booster = new ArrayList<>();
    if (!hasBoosters) {
        return booster;
    }
    if (numBoosterLands > 0) {
        List<CardInfo> specialLands = getSpecialCardsByRarity(Rarity.LAND);
        List<CardInfo> basicLands = getCardsByRarity(Rarity.LAND);
        for (int i = 0; i < numBoosterLands; i++) {
            if (ratioBoosterSpecialLand > 0 && RandomUtil.nextInt(ratioBoosterSpecialLand) < ratioBoosterSpecialLandNumerator) {
                addToBooster(booster, specialLands);
            } else {
                addToBooster(booster, basicLands);
            }
        }
    }
    int numCommonsToGenerate = numBoosterCommon;
    int numSpecialToGenerate = numBoosterSpecial;
    if (ratioBoosterSpecialCommon > 0 && RandomUtil.nextInt(ratioBoosterSpecialCommon) < 1) {
        --numCommonsToGenerate;
        ++numSpecialToGenerate;
    }
    List<CardInfo> commons = getCardsByRarity(Rarity.COMMON);
    for (int i = 0; i < numCommonsToGenerate; i++) {
        addToBooster(booster, commons);
    }
    int numUncommonsToGenerate = numBoosterUncommon;
    int numRaresToGenerate = numBoosterRare;
    if (ratioBoosterSpecialRare > 0) {
        Rarity specialRarity = Rarity.UNCOMMON;
        if (ratioBoosterSpecialRare * RandomUtil.nextDouble() <= 1) {
            specialRarity = (checkSpecialMythic() ? Rarity.MYTHIC : Rarity.RARE);
            --numRaresToGenerate;
        } else {
            --numUncommonsToGenerate;
        }
        addToBooster(booster, getSpecialCardsByRarity(specialRarity));
    }
    List<CardInfo> uncommons = getCardsByRarity(Rarity.UNCOMMON);
    for (int i = 0; i < numUncommonsToGenerate; i++) {
        addToBooster(booster, uncommons);
    }
    if (numRaresToGenerate > 0) {
        List<CardInfo> rares = getCardsByRarity(Rarity.RARE);
        List<CardInfo> mythics = getCardsByRarity(Rarity.MYTHIC);
        for (int i = 0; i < numRaresToGenerate; i++) {
            addToBooster(booster, checkMythic() ? mythics : rares);
        }
    }
    if (numBoosterDoubleFaced > 0) {
        addDoubleFace(booster);
    }
    if (numSpecialToGenerate > 0) {
        addSpecialCards(booster, numSpecialToGenerate);
    }
    return booster;
}
Also used : Rarity(mage.constants.Rarity) CardInfo(mage.cards.repository.CardInfo)

Example 10 with Rarity

use of mage.constants.Rarity in project mage by magefree.

the class EldritchMoonCollator method addSpecialCards.

// Then about an eighth of the packs will have a second double-faced card, which will be a rare or mythic rare
// 10/12 of such packs contain one of 5 rare DFCs and 2/12 packs contain one of 2 mythic DFCs
@Override
protected void addSpecialCards(List<Card> booster, int number) {
    // number is here always 1
    Rarity rarity;
    if (RandomUtil.nextInt(12) < 10) {
        rarity = Rarity.RARE;
    } else {
        rarity = Rarity.MYTHIC;
    }
    addToBooster(booster, getSpecialCardsByRarity(rarity));
}
Also used : Rarity(mage.constants.Rarity)

Aggregations

Rarity (mage.constants.Rarity)16 CardInfo (mage.cards.repository.CardInfo)4 CardType (mage.constants.CardType)3 SubType (mage.constants.SubType)3 java.util (java.util)2 SuperType (mage.constants.SuperType)2 SelectArg (com.j256.ormlite.stmt.SelectArg)1 Where (com.j256.ormlite.stmt.Where)1 BufferedImage (java.awt.image.BufferedImage)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 PartnerWithAbility (mage.abilities.keyword.PartnerWithAbility)1 Card (mage.cards.Card)1 ExpansionSet (mage.cards.ExpansionSet)1 ModalDoubleFacesCard (mage.cards.ModalDoubleFacesCard)1 CardScanner (mage.cards.repository.CardScanner)1 mage.sets (mage.sets)1 CardView (mage.view.CardView)1