mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
[GNT] implemented Avatar of Growth
This commit is contained in:
parent
0b089895a7
commit
a0e4791ad6
4 changed files with 149 additions and 51 deletions
|
|
@ -0,0 +1,52 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
public class SpellCostReductionSourceForOpponentsEffect extends CostModificationEffectImpl {
|
||||
|
||||
public SpellCostReductionSourceForOpponentsEffect() {
|
||||
this("undaunted <i>(This spell costs {1} less to cast for each opponent.)</i>");
|
||||
}
|
||||
|
||||
public SpellCostReductionSourceForOpponentsEffect(String newStaticText) {
|
||||
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
staticText = newStaticText;
|
||||
}
|
||||
|
||||
public SpellCostReductionSourceForOpponentsEffect(final SpellCostReductionSourceForOpponentsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
||||
Mana mana = spellAbility.getManaCostsToPay().getMana();
|
||||
if (mana.getGeneric() > 0) {
|
||||
int count = game.getOpponents(source.getControllerId()).size();
|
||||
int newCount = mana.getGeneric() - count;
|
||||
if (newCount < 0) {
|
||||
newCount = 0;
|
||||
}
|
||||
mana.setGeneric(newCount);
|
||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellCostReductionSourceForOpponentsEffect copy() {
|
||||
return new SpellCostReductionSourceForOpponentsEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,25 +5,17 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.effects.common.cost.SpellCostReductionSourceForOpponentsEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class UndauntedAbility extends SimpleStaticAbility {
|
||||
|
||||
public UndauntedAbility() {
|
||||
super(Zone.ALL, new UndauntedEffect());
|
||||
super(Zone.ALL, new SpellCostReductionSourceForOpponentsEffect("undaunted <i>(This spell costs {1} less to cast for each opponent.)</i>"));
|
||||
setRuleAtTheTop(true);
|
||||
}
|
||||
|
||||
|
|
@ -36,43 +28,4 @@ public class UndauntedAbility extends SimpleStaticAbility {
|
|||
return new UndauntedAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UndauntedEffect extends CostModificationEffectImpl {
|
||||
|
||||
public UndauntedEffect() {
|
||||
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
staticText = "undaunted <i>(This spell costs {1} less to cast for each opponent.)</i>";
|
||||
}
|
||||
|
||||
public UndauntedEffect(final UndauntedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
||||
Mana mana = spellAbility.getManaCostsToPay().getMana();
|
||||
if (mana.getGeneric() > 0) {
|
||||
int count = game.getOpponents(source.getControllerId()).size();
|
||||
int newCount = mana.getGeneric() - count;
|
||||
if (newCount < 0) {
|
||||
newCount = 0;
|
||||
}
|
||||
mana.setGeneric(newCount);
|
||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UndauntedEffect copy() {
|
||||
return new UndauntedEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue