Search in sources :

Example 1 with ClueArtifactToken

use of mage.game.permanent.token.ClueArtifactToken in project mage by magefree.

the class WillTheWiseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int count = 1;
    Token token = new ClueArtifactToken();
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        if (opponent.chooseUse(outcome, "Investigate?", source, game)) {
            count++;
            token.putOntoBattlefield(1, game, source, playerId);
            game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, playerId));
        } else {
            opponent.loseLife(1, game, source, false);
        }
    }
    token.putOntoBattlefield(count, game, source, source.getControllerId());
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, source.getControllerId()));
    return true;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Player(mage.players.Player) ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID)

Example 2 with ClueArtifactToken

use of mage.game.permanent.token.ClueArtifactToken in project mage by magefree.

the class DeclarationInStoneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (targetPermanent != null) {
            Set<Card> cardsToExile = new HashSet<>();
            int nonTokenCount = 0;
            if (CardUtil.haveEmptyName(targetPermanent)) {
                // face down creature
                cardsToExile.add(targetPermanent);
                if (!(targetPermanent instanceof PermanentToken)) {
                    nonTokenCount++;
                }
            } else {
                if (cardsToExile.add(targetPermanent) && !(targetPermanent instanceof PermanentToken)) {
                    nonTokenCount++;
                }
                for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, targetPermanent.getControllerId(), game)) {
                    if (!permanent.getId().equals(targetPermanent.getId()) && CardUtil.haveSameNames(permanent, targetPermanent)) {
                        cardsToExile.add(permanent);
                        // exiled count only matters for non-tokens
                        if (!(permanent instanceof PermanentToken)) {
                            nonTokenCount++;
                        }
                    }
                }
            }
            controller.moveCards(cardsToExile, Zone.EXILED, source, game);
            game.getState().processAction(game);
            if (nonTokenCount > 0) {
                new ClueArtifactToken().putOntoBattlefield(nonTokenCount, game, source, targetPermanent.getControllerId(), false, false);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MageObject(mage.MageObject) PermanentToken(mage.game.permanent.PermanentToken) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 3 with ClueArtifactToken

use of mage.game.permanent.token.ClueArtifactToken in project mage by magefree.

the class FatefulAbsenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    UUID controllerId = permanent.getControllerId();
    permanent.destroy(source, game, false);
    new ClueArtifactToken().putOntoBattlefield(1, game, source, controllerId);
    return true;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID)

Example 4 with ClueArtifactToken

use of mage.game.permanent.token.ClueArtifactToken in project mage by magefree.

the class InvestigateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int value = this.amount.calculate(game, source, this);
    if (value < 1) {
        return false;
    }
    new ClueArtifactToken().putOntoBattlefield(value, game, source, source.getControllerId());
    for (int i = 0; i < value; i++) {
        game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, source.getControllerId()));
    }
    return true;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken)

Example 5 with ClueArtifactToken

use of mage.game.permanent.token.ClueArtifactToken in project mage by magefree.

the class AcademyManufactorEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    int amount = 0;
    Map<Token, Integer> tokens = ((CreateTokenEvent) event).getTokens();
    for (Iterator<Map.Entry<Token, Integer>> iter = tokens.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry<Token, Integer> entry = iter.next();
        Token token = entry.getKey();
        if (token.hasSubtype(SubType.CLUE, game) || token.hasSubtype(SubType.FOOD, game) || token.hasSubtype(SubType.TREASURE, game)) {
            amount += entry.getValue();
            iter.remove();
        }
    }
    tokens.put(new ClueArtifactToken(), amount);
    tokens.put(new FoodToken(), amount);
    tokens.put(new TreasureToken(), amount);
    return false;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) TreasureToken(mage.game.permanent.token.TreasureToken) FoodToken(mage.game.permanent.token.FoodToken) ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Token(mage.game.permanent.token.Token) TreasureToken(mage.game.permanent.token.TreasureToken) Map(java.util.Map) CreateTokenEvent(mage.game.events.CreateTokenEvent) FoodToken(mage.game.permanent.token.FoodToken)

Aggregations

ClueArtifactToken (mage.game.permanent.token.ClueArtifactToken)5 UUID (java.util.UUID)2 Permanent (mage.game.permanent.Permanent)2 Token (mage.game.permanent.token.Token)2 Player (mage.players.Player)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 MageObject (mage.MageObject)1 Card (mage.cards.Card)1 CreateTokenEvent (mage.game.events.CreateTokenEvent)1 PermanentToken (mage.game.permanent.PermanentToken)1 FoodToken (mage.game.permanent.token.FoodToken)1 TreasureToken (mage.game.permanent.token.TreasureToken)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1