mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +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.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -92,14 +93,16 @@ class ElixerOfImmortalityEffect extends OneShotEffect<ElixerOfImmortalityEffect>
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.gainLife(5, game);
|
||||
player.removeFromBattlefield(game.getPermanent(source.getSourceId()), game);
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
|
||||
player.getGraveyard().clear();
|
||||
player.getLibrary().shuffle();
|
||||
return true;
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
player.gainLife(5, game);
|
||||
permanent.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
|
||||
player.getGraveyard().clear();
|
||||
player.getLibrary().shuffle();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -91,6 +91,8 @@ class EverflowingChaliceAbility extends ManaAbility<EverflowingChaliceAbility> {
|
|||
|
||||
@Override
|
||||
public Mana getNetMana(Game game) {
|
||||
if (game == null)
|
||||
return new Mana();
|
||||
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.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
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 void checkTriggers(Zone zone, GameEvent event, Game game);
|
||||
|
||||
public List<Mana> getMana();
|
||||
|
||||
@Override
|
||||
public Card copy();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.cards;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
@ -37,10 +38,12 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObjectImpl;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.PlayLandAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
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);
|
||||
Constructor<?> con = theClass.getConstructor(new Class[]{UUID.class});
|
||||
Card card = (Card) con.newInstance(new Object[] {null});
|
||||
// card.setZone(Zone.OUTSIDE);
|
||||
return card;
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -183,6 +185,15 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
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
|
||||
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
|
||||
Zone fromZone = game.getZone(objectId);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.game.stack;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.game.*;
|
||||
import java.util.List;
|
||||
|
@ -313,4 +314,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
public int getCardNumber() {
|
||||
return card.getCardNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getMana() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue