use of mage.abilities.SpecialAction in project mage by magefree.
the class ImproviseEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
int canPayCount = untappedCount.calculate(game, source, null);
if (controller != null && canPayCount > 0) {
if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
SpecialAction specialAction = new ImproviseSpecialAction(unpaid, this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
// create filter for possible artifacts to tap
Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filterUntapped, true);
target.setTargetName("artifact to tap as Improvise's pay");
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
}
use of mage.abilities.SpecialAction in project mage by magefree.
the class CreateSpecialActionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
SpecialAction newAction = (SpecialAction) action.copy();
newAction.setSourceId(source.getSourceId());
newAction.setControllerId(source.getControllerId());
newAction.getTargets().addAll(source.getTargets());
game.getState().getSpecialActions().add(newAction);
return true;
}
use of mage.abilities.SpecialAction in project mage by magefree.
the class ConvokeEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && game.getBattlefield().containsControlled(filterUntapped, source, game, 1)) {
if (source.getAbilityType() == AbilityType.SPELL) {
SpecialAction specialAction = new ConvokeSpecialAction(unpaid, this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
// create filter for possible creatures to tap
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(TappedPredicate.UNTAPPED);
if (unpaid.getMana().getGeneric() == 0) {
List<ColorPredicate> colorPredicates = new ArrayList<>();
if (unpaid.getMana().getBlack() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (unpaid.getMana().getBlue() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (unpaid.getMana().getRed() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.RED));
}
if (unpaid.getMana().getGreen() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (unpaid.getMana().getWhite() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
}
filter.add(Predicates.or(colorPredicates));
}
Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
target.setTargetName("tap creature card as convoke's pay");
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
}
use of mage.abilities.SpecialAction in project mage by magefree.
the class DelveEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.getGraveyard().isEmpty()) {
if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
SpecialAction specialAction = new DelveSpecialAction(this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
int unpaidAmount = unpaid.getMana().getGeneric();
if (!controller.getManaPool().isAutoPayment() && unpaidAmount > 1) {
unpaidAmount = 1;
}
specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard("cards from your graveyard"), true)));
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
}
use of mage.abilities.SpecialAction in project mage by magefree.
the class AssistEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() >= 1 && game.getState().getValue(source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "_assisted") == null) {
SpecialAction specialAction = new AssistSpecialAction(unpaid, this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
Target target = new TargetPlayer(1, 1, true, filter);
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
Aggregations