mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
fixed implementation of Phyrexian Processor
This commit is contained in:
parent
6e49f4a21c
commit
c9de200b04
1 changed files with 37 additions and 26 deletions
|
@ -1,18 +1,20 @@
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.common.PayLifeCost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.MinionToken;
|
import mage.game.permanent.token.MinionToken;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
@ -28,14 +30,17 @@ public final class PhyrexianProcessor extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||||
|
|
||||||
// As {this} enters the battlefield, pay any amount of life.
|
// As {this} enters the battlefield, pay any amount of life.
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new PhyrexianProcessorEffect()));
|
this.addAbility(new AsEntersBattlefieldAbility(new PhyrexianProcessorPayLifeEffect()));
|
||||||
|
|
||||||
// {4}, {tap}: Create an X/X black Minion creature token, where X is the life paid as {this} entered the battlefield.
|
// {4}, {tap}: Create an X/X black Minion creature token, where X is the life paid as {this} entered the battlefield.
|
||||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PhyrexianProcessorCreateTokenEffect(), new ManaCostsImpl("{4}"));
|
Ability ability = new SimpleActivatedAbility(
|
||||||
|
new PhyrexianProcessorCreateTokenEffect(), new GenericManaCost(4)
|
||||||
|
);
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhyrexianProcessor(final PhyrexianProcessor card) {
|
private PhyrexianProcessor(final PhyrexianProcessor card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,47 +50,53 @@ public final class PhyrexianProcessor extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PhyrexianProcessorEffect extends OneShotEffect {
|
class PhyrexianProcessorPayLifeEffect extends OneShotEffect {
|
||||||
|
|
||||||
public PhyrexianProcessorEffect() {
|
PhyrexianProcessorPayLifeEffect() {
|
||||||
super(Outcome.LoseLife);
|
super(Outcome.LoseLife);
|
||||||
staticText = "Pay any amount of life.";
|
staticText = "pay any amount of life.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhyrexianProcessorEffect(final PhyrexianProcessorEffect effect) {
|
private PhyrexianProcessorPayLifeEffect(final PhyrexianProcessorPayLifeEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PhyrexianProcessorEffect copy() {
|
public PhyrexianProcessorPayLifeEffect copy() {
|
||||||
return new PhyrexianProcessorEffect(this);
|
return new PhyrexianProcessorPayLifeEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||||
int payAmount = controller.getAmount(0, controller.getLife(), staticText, game);
|
if (controller == null || permanent == null) {
|
||||||
controller.loseLife(payAmount, game, false);
|
return false;
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
|
||||||
game.informPlayers((sourceCard != null ? sourceCard.getName() : "") + ": " + controller.getLogName() +
|
|
||||||
" pays " + payAmount + " life.");
|
|
||||||
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
|
|
||||||
game.getState().setValue(key, payAmount);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
|
||||||
|
Cost cost = new PayLifeCost(payAmount);
|
||||||
|
if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
|
game.informPlayers((sourceCard != null ? sourceCard.getName() : "") + ": " + controller.getLogName() +
|
||||||
|
" pays " + payAmount + " life.");
|
||||||
|
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
|
||||||
|
game.getState().setValue(key, payAmount);
|
||||||
|
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PhyrexianProcessorCreateTokenEffect extends OneShotEffect {
|
class PhyrexianProcessorCreateTokenEffect extends OneShotEffect {
|
||||||
|
|
||||||
public PhyrexianProcessorCreateTokenEffect() {
|
PhyrexianProcessorCreateTokenEffect() {
|
||||||
super(Outcome.PutCreatureInPlay);
|
super(Outcome.PutCreatureInPlay);
|
||||||
staticText = "Create an X/X black Minion creature token";
|
staticText = "Create an X/X black Minion creature token, " +
|
||||||
|
"where X is the life paid as {this} entered the battlefield.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhyrexianProcessorCreateTokenEffect(PhyrexianProcessorCreateTokenEffect ability) {
|
private PhyrexianProcessorCreateTokenEffect(PhyrexianProcessorCreateTokenEffect ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +107,7 @@ class PhyrexianProcessorCreateTokenEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game);
|
String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game, true);
|
||||||
Object object = game.getState().getValue(key);
|
Object object = game.getState().getValue(key);
|
||||||
if (object instanceof Integer) {
|
if (object instanceof Integer) {
|
||||||
int lifePaid = (int) object;
|
int lifePaid = (int) object;
|
||||||
|
|
Loading…
Reference in a new issue