use of mage.abilities.SpellAbility in project mage by magefree.
the class TargetPriorityTest method test_targetAmount_BadCase.
@Test
public void test_targetAmount_BadCase() {
// choose targets as enters battlefield (e.g. can't be canceled)
SpellAbility spell = new SpellAbility(new ManaCostsImpl("R"), "damage 3", Zone.HAND);
Ability ability = new EntersBattlefieldTriggeredAbility(new DamageMultiEffect(3));
ability.addTarget(new TargetCreaturePermanentAmount(3));
addCustomCardWithSpell(playerA, spell, ability, CardType.ENCHANTMENT);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
//
// 1/1
addCard(Zone.BATTLEFIELD, playerA, "Memnite", 3);
// 2/2
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 3);
// 2/2 with ability
addCard(Zone.BATTLEFIELD, playerA, "Ashcoat Bear", 3);
// 4/3
addCard(Zone.BATTLEFIELD, playerA, "Golden Bear", 3);
// 4/4 with ability
addCard(Zone.BATTLEFIELD, playerA, "Battering Sliver", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "damage 3");
// must damage x3 Balduvian Bears by -1 to keep alive
checkDamage("pt after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", 1);
// showBattlefield("after", 1, PhaseStep.BEGIN_COMBAT, playerA);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "damage 3", 1);
assertPermanentCount(playerA, "Memnite", 3);
assertPermanentCount(playerA, "Balduvian Bears", 3);
assertPermanentCount(playerA, "Ashcoat Bear", 3);
assertPermanentCount(playerA, "Golden Bear", 3);
assertPermanentCount(playerA, "Battering Sliver", 3);
}
use of mage.abilities.SpellAbility in project mage by magefree.
the class PolukranosUnchainedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
permanent = game.getPermanentEntering(source.getSourceId());
}
if (permanent == null) {
return false;
}
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
int counters = 12;
if (!(spellAbility instanceof EscapeAbility) || !spellAbility.getSourceId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
counters = 6;
}
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
permanent.addCounters(CounterType.P1P1.createInstance(counters), source.getControllerId(), source, game, appliedEffects);
return true;
}
use of mage.abilities.SpellAbility in project mage by magefree.
the class ValkmiraProtectorsShieldTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
CardUtil.adjustCost(spellAbility, -2);
return true;
}
use of mage.abilities.SpellAbility in project mage by magefree.
the class SealOfTheGuildpactCostReductionEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
MageObject sourceObject = game.getObject(abilityToModify.getSourceId());
if (sourceObject != null) {
ObjectColor color1 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color1");
ObjectColor color2 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color2");
int amount = 0;
if (color1 != null && sourceObject.getColor(game).contains(color1)) {
amount++;
}
if (color2 != null && sourceObject.getColor(game).contains(color2)) {
amount++;
}
if (amount > 0) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
CardUtil.adjustCost(spellAbility, amount);
}
return true;
}
return false;
}
use of mage.abilities.SpellAbility in project mage by magefree.
the class DackFaydenEmblemEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
boolean returnValue = false;
List<UUID> targetedPermanentIds = new ArrayList<>(0);
Player player = game.getPlayer(this.getControllerId());
if (player != null) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null) {
SpellAbility spellAbility = spell.getSpellAbility();
for (Mode mode : spellAbility.getModes().values()) {
for (Target target : mode.getTargets()) {
if (!target.isNotTarget()) {
for (UUID targetId : target.getTargets()) {
if (game.getBattlefield().containsPermanent(targetId)) {
returnValue = true;
targetedPermanentIds.add(targetId);
}
}
}
}
}
for (Effect effect : spellAbility.getEffects()) {
for (UUID targetId : effect.getTargetPointer().getTargets(game, spellAbility)) {
if (game.getBattlefield().containsPermanent(targetId)) {
returnValue = true;
targetedPermanentIds.add(targetId);
}
}
}
}
}
}
for (Effect effect : this.getEffects()) {
if (effect instanceof DackFaydenEmblemEffect) {
DackFaydenEmblemEffect dackEffect = (DackFaydenEmblemEffect) effect;
List<Permanent> permanents = new ArrayList<>();
for (UUID permanentId : targetedPermanentIds) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanents.add(permanent);
}
}
dackEffect.setTargets(permanents, game);
}
}
return returnValue;
}
Aggregations