Search in sources :

Example 1 with Rarity

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

the class DarkAscensionCollator method addDoubleFace.

@Override
protected void addDoubleFace(List<Card> booster) {
    Rarity rarity;
    for (int i = 0; i < numBoosterDoubleFaced; i++) {
        int rarityKey = RandomUtil.nextInt(121);
        if (rarityKey < 72) {
            rarity = Rarity.COMMON;
        } else if (rarityKey < 108) {
            rarity = Rarity.UNCOMMON;
        } else if (rarityKey < 117) {
            rarity = Rarity.RARE;
        } else {
            rarity = Rarity.MYTHIC;
        }
        List<CardInfo> doubleFacedCards = getSpecialCardsByRarity(rarity);
        addToBooster(booster, doubleFacedCards);
    }
}
Also used : Rarity(mage.constants.Rarity) CardInfo(mage.cards.repository.CardInfo)

Example 2 with Rarity

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

the class ModernHorizons2Collator method addSpecialCards.

@Override
protected void addSpecialCards(List<Card> booster, int number) {
    // number is here always 1
    Rarity rarity;
    int rarityKey = RandomUtil.nextInt(120);
    if (rarityKey < 4) {
        rarity = Rarity.MYTHIC;
    } else if (rarityKey < 40) {
        rarity = Rarity.RARE;
    } else {
        rarity = Rarity.UNCOMMON;
    }
    List<CardInfo> reprintCards = getSpecialCardsByRarity(rarity);
    addToBooster(booster, reprintCards);
}
Also used : Rarity(mage.constants.Rarity) CardInfo(mage.cards.repository.CardInfo)

Example 3 with Rarity

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

the class DragonsMazeCollator method addSpecialCards.

@Override
protected void addSpecialCards(List<Card> booster, int number) {
    // number is here always 1
    // the land print sheets are believed to contain 23 copies of each Guildgate,
    // one copy of each RTR and GTC shockland, and two copies of Maze's End
    Rarity rarity;
    int rarityKey = RandomUtil.nextInt(242);
    if (rarityKey < 230) {
        rarity = Rarity.COMMON;
    } else if (rarityKey < 240) {
        rarity = Rarity.RARE;
    } else {
        rarity = Rarity.MYTHIC;
    }
    addToBooster(booster, getSpecialCardsByRarity(rarity));
}
Also used : Rarity(mage.constants.Rarity)

Example 4 with Rarity

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

the class ShadowsOverInnistradCollator method addSpecialCards.

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

Example 5 with Rarity

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

the class BoosterGenerationTest method testKaldheim_SnowLandAndMDFC.

@Test
public void testKaldheim_SnowLandAndMDFC() {
    boolean foundVale = false;
    boolean foundMDFC = false;
    boolean foundNoMDFC = false;
    for (int i = 1; i <= 100; i++) {
        List<Card> booster = Kaldheim.getInstance().createBooster();
        assertEquals("Booster does not have 15 cards", 15, booster.size());
        assertTrue("Booster contains cards from another set", booster.stream().map(Card::getExpansionSetCode).allMatch("KHM"::equals));
        assertFalse("Booster cannot contain non-snow basic lands", booster.stream().anyMatch(card -> card.isBasic() && !card.isSnow()));
        assertEquals("Booster must contain exactly 1 rare or mythic", 1, booster.stream().map(Card::getRarity).filter(rarity -> rarity == Rarity.RARE || rarity == Rarity.MYTHIC).count());
        assertEquals("Booster must contain exactly 3 uncommons", 3, booster.stream().map(Card::getRarity).filter(Rarity.UNCOMMON::equals).count());
        List<Card> snowLands = booster.stream().filter(card -> card.isSnow() && card.isLand(currentGame)).collect(Collectors.toList());
        switch(snowLands.size()) {
            case 0:
                fail("Booster must have snow lands");
            case 1:
                Card snowLand = snowLands.get(0);
                assertTrue("Only one snow land, must be basic or common", snowLand.isBasic() || snowLand.getRarity() == Rarity.COMMON);
                assertNotEquals("Only one snow land, can't be Shimmerdrift Vale", "Shimmerdrift Vale", snowLand.getName());
                assertNotEquals("Only one snow land, can't be Faceless Haven", "Faceless Haven", snowLand.getName());
                break;
            case 2:
                assertEquals("Booster can't have two snow lands unless one is Shimmerdrift Vale or Faceless Haven", 1, snowLands.stream().filter(card -> card.getName().equals("Shimmerdrift Vale") || card.getName().equals("Faceless Haven")).count());
                assertEquals("Booster can't have two snow lands unless one is not Shimmerdrift Vale or Faceless Haven", 1, snowLands.stream().filter(card -> !card.getName().equals("Shimmerdrift Vale") && !card.getName().equals("Faceless Haven")).count());
                break;
            case 3:
                assertEquals("Booster can't have three snow lands unless one is Shimmerdrift Vale", 1, snowLands.stream().filter(card -> card.getName().equals("Shimmerdrift Vale")).count());
                assertEquals("Booster can't have three snow lands unless one is Faceless Haven", 1, snowLands.stream().filter(card -> card.getName().equals("Faceless Haven")).count());
                assertEquals("Booster can't have three snow lands unless one is not Shimmerdrift Vale or Faceless Haven", 1, snowLands.stream().filter(card -> !card.getName().equals("Shimmerdrift Vale") && !card.getName().equals("Faceless Haven")).count());
                break;
            default:
                fail("Booster can't have more than three snow lands");
        }
        long mdfcCount = booster.stream().filter(card -> card instanceof ModalDoubleFacesCard).count();
        assertTrue("Booster can't have more than one MDFC", mdfcCount < 2);
        foundMDFC |= mdfcCount > 0;
        foundNoMDFC |= mdfcCount == 0;
        foundVale |= booster.stream().map(MageObject::getName).anyMatch("Shimmerdrift Vale"::equals);
        if (foundVale && foundMDFC && foundNoMDFC && i > 20) {
            break;
        }
    }
    assertTrue("No booster contained Shimmerdrift Vale", foundVale);
    assertTrue("No booster contained an MDFC", foundMDFC);
    assertTrue("Every booster contained an MDFC", foundNoMDFC);
}
Also used : MageTestBase(org.mage.test.serverside.base.MageTestBase) java.util(java.util) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) mage.sets(mage.sets) CardScanner(mage.cards.repository.CardScanner) PartnerWithAbility(mage.abilities.keyword.PartnerWithAbility) Test(org.junit.Test) SubType(mage.constants.SubType) Collectors(java.util.stream.Collectors) ExpansionSet(mage.cards.ExpansionSet) Ignore(org.junit.Ignore) CardInfo(mage.cards.repository.CardInfo) CardType(mage.constants.CardType) MageObject(mage.MageObject) Rarity(mage.constants.Rarity) Card(mage.cards.Card) Assert(org.junit.Assert) Ability(mage.abilities.Ability) Before(org.junit.Before) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) MageObject(mage.MageObject) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) Card(mage.cards.Card) Test(org.junit.Test)

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