mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
added getMana method to card
This commit is contained in:
parent
6d589abe6d
commit
79eb8cede7
5 changed files with 34 additions and 9 deletions
|
@ -44,6 +44,7 @@ import mage.abilities.effects.common.GainLifeEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,14 +93,16 @@ class ElixerOfImmortalityEffect extends OneShotEffect<ElixerOfImmortalityEffect>
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
player.gainLife(5, game);
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
player.removeFromBattlefield(game.getPermanent(source.getSourceId()), game);
|
if (player != null && permanent != null) {
|
||||||
Card card = game.getCard(source.getSourceId());
|
player.gainLife(5, game);
|
||||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
permanent.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||||
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
|
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
|
||||||
player.getGraveyard().clear();
|
player.getGraveyard().clear();
|
||||||
player.getLibrary().shuffle();
|
player.getLibrary().shuffle();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,6 +91,8 @@ class EverflowingChaliceAbility extends ManaAbility<EverflowingChaliceAbility> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mana getNetMana(Game game) {
|
public Mana getNetMana(Game game) {
|
||||||
|
if (game == null)
|
||||||
|
return new Mana();
|
||||||
return Mana.ColorlessMana(game.getPermanent(this.getSourceId()).getCounters().getCount("charge"));
|
return Mana.ColorlessMana(game.getPermanent(this.getSourceId()).getCounters().getCount("charge"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -60,6 +61,8 @@ public interface Card extends MageObject {
|
||||||
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId);
|
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId);
|
||||||
public void checkTriggers(Zone zone, GameEvent event, Game game);
|
public void checkTriggers(Zone zone, GameEvent event, Game game);
|
||||||
|
|
||||||
|
public List<Mana> getMana();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card copy();
|
public Card copy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -37,10 +38,12 @@ import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageObjectImpl;
|
import mage.MageObjectImpl;
|
||||||
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.PlayLandAbility;
|
import mage.abilities.PlayLandAbility;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
|
import mage.abilities.mana.ManaAbility;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
@ -97,7 +100,6 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
Class<?> theClass = Class.forName(name);
|
Class<?> theClass = Class.forName(name);
|
||||||
Constructor<?> con = theClass.getConstructor(new Class[]{UUID.class});
|
Constructor<?> con = theClass.getConstructor(new Class[]{UUID.class});
|
||||||
Card card = (Card) con.newInstance(new Object[] {null});
|
Card card = (Card) con.newInstance(new Object[] {null});
|
||||||
// card.setZone(Zone.OUTSIDE);
|
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -183,6 +185,15 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
this.expansionSetCode = expansionSetCode;
|
this.expansionSetCode = expansionSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getMana() {
|
||||||
|
List<Mana> mana = new ArrayList<Mana>();
|
||||||
|
for (ManaAbility ability: this.abilities.getManaAbilities(Zone.BATTLEFIELD)) {
|
||||||
|
mana.add(ability.getNetMana(null));
|
||||||
|
}
|
||||||
|
return mana;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
|
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
|
||||||
Zone fromZone = game.getZone(objectId);
|
Zone fromZone = game.getZone(objectId);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.game.stack;
|
package mage.game.stack;
|
||||||
|
|
||||||
|
import mage.Mana;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.game.*;
|
import mage.game.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -313,4 +314,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
public int getCardNumber() {
|
public int getCardNumber() {
|
||||||
return card.getCardNumber();
|
return card.getCardNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mana> getMana() {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue