forked from External/mage
1a. Make `costs`, `manaCosts`, and `manaCostsToPay` private in `AbilityImpl` with access through getters/setters 1b. fix cost adjuster for imprinted cards affected by the above 2a. Lazy instantiation for rarely used `data` field in `TargetPointerImpl` 3a. Pre-allocate certain array sizes in `Modes` and `CostsImpl` 4a. Make `manaTemplate` private in `BasicManaEffect`, copy when passing outside the class 4b. Don't copy `manaTemplate` in copy constructor since it doesn't change 4c. Add comments explaining copy usage for `manaTemplate` 4d. Remove redundant variable assignment and make fields final --------- Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
72 lines
2.1 KiB
Java
72 lines
2.1 KiB
Java
|
|
package mage.cards.d;
|
|
|
|
import java.util.UUID;
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.SpellAbility;
|
|
import mage.abilities.common.SimpleStaticAbility;
|
|
import mage.abilities.costs.mana.GenericManaCost;
|
|
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
|
import mage.cards.CardImpl;
|
|
import mage.cards.CardSetInfo;
|
|
import mage.constants.*;
|
|
import mage.game.Game;
|
|
|
|
/**
|
|
*
|
|
* @author Plopman
|
|
*/
|
|
public final class DefenseGrid extends CardImpl {
|
|
|
|
public DefenseGrid(UUID ownerId, CardSetInfo setInfo) {
|
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
|
|
|
// Each spell costs {3} more to cast except during its controller's turn.
|
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DefenseGridCostModificationEffect()));
|
|
|
|
}
|
|
|
|
private DefenseGrid(final DefenseGrid card) {
|
|
super(card);
|
|
}
|
|
|
|
@Override
|
|
public DefenseGrid copy() {
|
|
return new DefenseGrid(this);
|
|
}
|
|
}
|
|
|
|
class DefenseGridCostModificationEffect extends CostModificationEffectImpl {
|
|
|
|
DefenseGridCostModificationEffect() {
|
|
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
|
|
staticText = "Each spell costs {3} more to cast except during its controller's turn";
|
|
}
|
|
|
|
DefenseGridCostModificationEffect(DefenseGridCostModificationEffect effect) {
|
|
super(effect);
|
|
}
|
|
|
|
@Override
|
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
|
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
|
spellAbility.addManaCostsToPay(new GenericManaCost(3));
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
|
if (abilityToModify instanceof SpellAbility) {
|
|
if (!abilityToModify.isControlledBy(game.getActivePlayerId())) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public DefenseGridCostModificationEffect copy() {
|
|
return new DefenseGridCostModificationEffect(this);
|
|
}
|
|
|
|
}
|