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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations