mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
now use manaability child for adding mana of any color, some refactoring and switch to use new ability for that
This commit is contained in:
parent
b707d11aa4
commit
01b43b0d87
48 changed files with 181 additions and 186 deletions
|
|
@ -40,10 +40,10 @@ import mage.players.Player;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AddManaOfAnyColorEffect extends OneShotEffect<AddManaOfAnyColorEffect> {
|
||||
public class AddManaOfAnyColorEffect extends ManaEffect<AddManaOfAnyColorEffect> {
|
||||
|
||||
public AddManaOfAnyColorEffect() {
|
||||
super(Outcome.PutManaInPool);
|
||||
super();
|
||||
}
|
||||
|
||||
public AddManaOfAnyColorEffect(final AddManaOfAnyColorEffect effect) {
|
||||
|
|
|
|||
41
Mage/src/mage/abilities/effects/common/BasicManaEffect.java
Normal file
41
Mage/src/mage/abilities/effects/common/BasicManaEffect.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
public class BasicManaEffect extends ManaEffect<BasicManaEffect> {
|
||||
protected Mana mana;
|
||||
|
||||
public BasicManaEffect(Mana mana) {
|
||||
super();
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
public BasicManaEffect(final BasicManaEffect effect) {
|
||||
super(effect);
|
||||
this.mana = effect.mana.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicManaEffect copy() {
|
||||
return new BasicManaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
game.getPlayer(source.getControllerId()).getManaPool().changeMana(mana);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getText(Ability source) {
|
||||
return "Add " + mana.toString() + " to your mana pool";
|
||||
}
|
||||
|
||||
public Mana getMana() {
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ import mage.game.Game;
|
|||
*
|
||||
* @author North
|
||||
*/
|
||||
public class DynamicManaEffect extends ManaEffect {
|
||||
public class DynamicManaEffect extends BasicManaEffect {
|
||||
|
||||
private Mana computedMana;
|
||||
private DynamicValue amount;
|
||||
|
|
|
|||
|
|
@ -38,37 +38,14 @@ import mage.game.Game;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ManaEffect extends OneShotEffect<ManaEffect> {
|
||||
public abstract class ManaEffect<T extends ManaEffect<T>> extends OneShotEffect<T> {
|
||||
|
||||
protected Mana mana;
|
||||
|
||||
public ManaEffect(Mana mana) {
|
||||
public ManaEffect() {
|
||||
super(Outcome.PutManaInPool);
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
public ManaEffect(final ManaEffect effect) {
|
||||
super(effect);
|
||||
this.mana = effect.mana.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaEffect copy() {
|
||||
return new ManaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
game.getPlayer(source.getControllerId()).getManaPool().changeMana(mana);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Ability source) {
|
||||
return "Add " + mana.toString() + " to your mana pool";
|
||||
}
|
||||
|
||||
public Mana getMana() {
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Mage/src/mage/abilities/mana/AnyColorManaAbility.java
Normal file
27
Mage/src/mage/abilities/mana/AnyColorManaAbility.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
||||
public class AnyColorManaAbility extends ManaAbility<AnyColorManaAbility> {
|
||||
public AnyColorManaAbility() {
|
||||
this(new TapSourceCost());
|
||||
}
|
||||
|
||||
public AnyColorManaAbility(Cost cost) {
|
||||
super(Constants.Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost);
|
||||
this.addChoice(new ChoiceColor());
|
||||
}
|
||||
|
||||
public AnyColorManaAbility(final AnyColorManaAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnyColorManaAbility copy() {
|
||||
return new AnyColorManaAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class BlackManaAbility extends BasicManaAbility<BlackManaAbility> {
|
||||
|
||||
public BlackManaAbility() {
|
||||
super(new ManaEffect(Mana.BlackMana));
|
||||
super(new BasicManaEffect(Mana.BlackMana));
|
||||
this.netMana.setBlack(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class BlueManaAbility extends BasicManaAbility<BlueManaAbility> {
|
||||
|
||||
public BlueManaAbility() {
|
||||
super(new ManaEffect(Mana.BlueMana));
|
||||
super(new BasicManaEffect(Mana.BlueMana));
|
||||
this.netMana.setBlue(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +39,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class ColorlessManaAbility extends BasicManaAbility<ColorlessManaAbility> {
|
||||
|
||||
public ColorlessManaAbility() {
|
||||
super(new ManaEffect(Mana.ColorlessMana));
|
||||
super(new BasicManaEffect(Mana.ColorlessMana));
|
||||
this.netMana.setColorless(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class GreenManaAbility extends BasicManaAbility<GreenManaAbility> {
|
||||
|
||||
public GreenManaAbility() {
|
||||
super(new ManaEffect(Mana.GreenMana));
|
||||
super(new BasicManaEffect(Mana.GreenMana));
|
||||
this.netMana.setGreen(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class RedManaAbility extends BasicManaAbility<RedManaAbility> {
|
||||
|
||||
public RedManaAbility() {
|
||||
super(new ManaEffect(Mana.RedMana));
|
||||
super(new BasicManaEffect(Mana.RedMana));
|
||||
this.netMana.setRed(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.ManaEffect;
|
|||
public class WhiteManaAbility extends BasicManaAbility<WhiteManaAbility> {
|
||||
|
||||
public WhiteManaAbility() {
|
||||
super(new ManaEffect(Mana.WhiteMana));
|
||||
super(new BasicManaEffect(Mana.WhiteMana));
|
||||
this.netMana.setWhite(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import mage.Constants.Zone;
|
|||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.abilities.mana.SimpleManaAbility;
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +49,7 @@ public class EldraziSpawnToken extends Token {
|
|||
subtype.add("Spawn");
|
||||
power = new MageInt(0);
|
||||
toughness = new MageInt(1);
|
||||
addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new ManaEffect(Mana.ColorlessMana), new SacrificeSourceCost()));
|
||||
addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new BasicManaEffect(Mana.ColorlessMana), new SacrificeSourceCost()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue