Search in sources :

Example 6 with PermanentCard

use of mage.game.permanent.PermanentCard in project mage by magefree.

the class ModalDoubleFacesCardsTest method test_Zones_AfterCast_2.

@Test
public void test_Zones_AfterCast_2() {
    removeAllCardsFromHand(playerA);
    // possible bug: if you click on mdf card second side then keep in hand after cast (sorcery + land)
    // P.S. it works in GUI only, reason: user can sends UUID from wrong card side
    // Ondu Inversion {6}{W}{W} - sorcery
    // Ondu Skyruins - land
    addCard(Zone.HAND, playerA, "Ondu Inversion");
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 8);
    // prepare mdf permanent
    playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ondu Skyruins");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPermanentCount("prepare", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ondu Skyruins", 1);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.END_TURN);
    execute();
    assertAllCommandsUsed();
    assertHandCount(playerA, 0);
    Card card = currentGame.getState().getBattlefield().getAllPermanents().stream().filter(p -> CardUtil.haveSameNames(p, "Ondu Skyruins", currentGame)).findFirst().orElse(null);
    Assert.assertNotNull(card);
    Assert.assertEquals("permanent card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(card.getId()));
    Assert.assertEquals("main permanent card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(card.getMainCard().getId()));
    Assert.assertEquals("half card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(((PermanentCard) card).getCard().getId()));
    Assert.assertEquals("main card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(((PermanentCard) card).getCard().getMainCard().getId()));
}
Also used : ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) PermanentCard(mage.game.permanent.PermanentCard) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) Test(org.junit.Test)

Example 7 with PermanentCard

use of mage.game.permanent.PermanentCard in project mage by magefree.

the class TestGameType method createFaceDownCard.

private CardView createFaceDownCard(Game game, UUID controllerId, String code, String cardNumber, boolean isMorphed, boolean isManifested, boolean tapped) {
    CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
    ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
    CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(), new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
    Card newCard = CardImpl.createCard(cardInfo.getClassName(), testSet);
    Set<Card> cardsList = new HashSet<>();
    cardsList.add(newCard);
    game.loadCards(cardsList, controllerId);
    Card permCard = CardUtil.getDefaultCardSideForBattlefield(game, newCard);
    PermanentCard perm = new PermanentCard(permCard, controllerId, game);
    perm.setFaceDown(true, game);
    perm.setMorphed(isMorphed);
    perm.setManifested(isManifested);
    perm.removeSummoningSickness();
    perm.setTapped(tapped);
    if (perm.isTransformable()) {
        perm.setTransformed(true);
    }
    PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
    // must false for face down
    cardView.setInViewerOnly(false);
    return cardView;
}
Also used : CardInfo(mage.cards.repository.CardInfo) ExpansionInfo(mage.cards.repository.ExpansionInfo) BigCard(mage.client.cards.BigCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 8 with PermanentCard

use of mage.game.permanent.PermanentCard in project mage by magefree.

the class TestGameType method createPermanentCard.

private PermanentView createPermanentCard(Game game, UUID controllerId, String code, String cardNumber, int power, int toughness, int damage, boolean tapped, boolean transform, List<Ability> extraAbilities) {
    CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
    ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
    CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(), new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
    Card newCard = CardImpl.createCard(cardInfo.getClassName(), testSet);
    Set<Card> cardsList = new HashSet<>();
    cardsList.add(newCard);
    game.loadCards(cardsList, controllerId);
    Card permCard = CardUtil.getDefaultCardSideForBattlefield(game, newCard);
    if (extraAbilities != null) {
        extraAbilities.forEach(ability -> permCard.addAbility(ability));
    }
    PermanentCard perm = new PermanentCard(permCard, controllerId, game);
    if (transform) {
        // need direct transform call to keep other side info (original)
        TransformAbility.transformPermanent(perm, permCard.getSecondCardFace(), game, null);
    }
    if (damage > 0)
        perm.damage(damage, controllerId, null, game);
    if (power > 0)
        perm.getPower().setValue(power);
    if (toughness > 0)
        perm.getToughness().setValue(toughness);
    perm.removeSummoningSickness();
    perm.setTapped(tapped);
    PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
    return cardView;
}
Also used : CardInfo(mage.cards.repository.CardInfo) ExpansionInfo(mage.cards.repository.ExpansionInfo) BigCard(mage.client.cards.BigCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 9 with PermanentCard

use of mage.game.permanent.PermanentCard in project mage by magefree.

the class OlagLudevicsHubrisCopyApplier method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Cards cards = new CardsImpl(game.getExile().getExileZone(CardUtil.getExileZoneId(game, source)));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    if (cards.isEmpty()) {
        return false;
    }
    Card copyFromCard = getCard(cards, source, game);
    if (copyFromCard == null) {
        return false;
    }
    Permanent newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
    newBluePrint.assignNewId();
    CopyApplier applier = new OlagLudevicsHubrisCopyApplier();
    applier.apply(game, newBluePrint, source, source.getSourceId());
    CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, source.getSourceId());
    copyEffect.newId();
    copyEffect.setApplier(applier);
    Ability newAbility = source.copy();
    copyEffect.init(newAbility, game);
    game.addEffect(copyEffect, newAbility);
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) CopyApplier(mage.util.functions.CopyApplier) TargetCard(mage.target.TargetCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 10 with PermanentCard

use of mage.game.permanent.PermanentCard in project mage by magefree.

the class MageTestBase method parseLine.

private void parseLine(String line) {
    if (parserState == ParserState.EXPECTED) {
        // just remember for future use
        expectedResults.add(line);
        return;
    }
    Matcher m = pattern.matcher(line);
    if (m.matches()) {
        String zone = m.group(1);
        String nickname = m.group(2);
        if (nickname.equals("ComputerA") || nickname.equals("ComputerB")) {
            List<Card> cards = null;
            List<PermanentCard> perms = null;
            Zone gameZone;
            if ("hand".equalsIgnoreCase(zone)) {
                gameZone = Zone.HAND;
                cards = nickname.equals("ComputerA") ? handCardsA : handCardsB;
            } else if ("battlefield".equalsIgnoreCase(zone)) {
                gameZone = Zone.BATTLEFIELD;
                perms = nickname.equals("ComputerA") ? battlefieldCardsA : battlefieldCardsB;
            } else if ("graveyard".equalsIgnoreCase(zone)) {
                gameZone = Zone.GRAVEYARD;
                cards = nickname.equals("ComputerA") ? graveyardCardsA : graveyardCardsB;
            } else if ("library".equalsIgnoreCase(zone)) {
                gameZone = Zone.LIBRARY;
                cards = nickname.equals("ComputerA") ? libraryCardsA : libraryCardsB;
            } else if ("player".equalsIgnoreCase(zone)) {
                String command = m.group(3);
                if ("life".equals(command)) {
                    if (nickname.equals("ComputerA")) {
                        commandsA.put(Zone.OUTSIDE, "life:" + m.group(4));
                    } else {
                        commandsB.put(Zone.OUTSIDE, "life:" + m.group(4));
                    }
                }
                return;
            } else {
                // go parse next line
                return;
            }
            String cardName = m.group(3);
            Integer amount = Integer.parseInt(m.group(4));
            boolean tapped = m.group(5) != null && m.group(5).equals(":{tapped}");
            if (cardName.equals("clear")) {
                if (nickname.equals("ComputerA")) {
                    commandsA.put(gameZone, "clear");
                } else {
                    commandsB.put(gameZone, "clear");
                }
            } else {
                for (int i = 0; i < amount; i++) {
                    CardInfo cardInfo = CardRepository.instance.findCard(cardName);
                    Card newCard = cardInfo != null ? cardInfo.getCard() : null;
                    if (newCard != null) {
                        if (gameZone == Zone.BATTLEFIELD) {
                            Card permCard = CardUtil.getDefaultCardSideForBattlefield(currentGame, newCard);
                            PermanentCard p = new PermanentCard(permCard, null, currentGame);
                            p.setTapped(tapped);
                            perms.add(p);
                        } else {
                            cards.add(newCard);
                        }
                    } else {
                        logger.fatal("Couldn't find a card: " + cardName);
                        logger.fatal("line: " + line);
                    }
                }
            }
        } else {
            logger.warn("Unknown player: " + nickname);
        }
    } else {
        logger.warn("Init string wasn't parsed: " + line);
    }
}
Also used : Matcher(java.util.regex.Matcher) Zone(mage.constants.Zone) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Aggregations

PermanentCard (mage.game.permanent.PermanentCard)42 Card (mage.cards.Card)22 Permanent (mage.game.permanent.Permanent)16 Player (mage.players.Player)16 Ability (mage.abilities.Ability)11 MageObject (mage.MageObject)9 CardInfo (mage.cards.repository.CardInfo)9 CopyEffect (mage.abilities.effects.common.CopyEffect)8 FilterCard (mage.filter.FilterCard)6 CopyApplier (mage.util.functions.CopyApplier)6 UUID (java.util.UUID)5 PermanentMeld (mage.game.permanent.PermanentMeld)4 Test (org.junit.Test)4 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 PermanentToken (mage.game.permanent.PermanentToken)3 TargetCard (mage.target.TargetCard)3 Matcher (java.util.regex.Matcher)2