mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Cleanup: source deals damage to {this}; mill cards (#10603)
* New common class for "Whenever a source deals damage to {this}, " which resolves #9340
* Merge `PutLibraryIntoGraveTargetEffect` with functionally identical `MillCardsTargetEffect`
* Text fix on `RevealDragonFromHandCost` noticed in #10593
* Text fix following up on #10594
This commit is contained in:
parent
73104f6705
commit
6c9079012c
101 changed files with 297 additions and 590 deletions
|
|
@ -0,0 +1,55 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class SourceDealsDamageToThisTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public SourceDealsDamageToThisTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public SourceDealsDamageToThisTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
setTriggerPhrase("Whenever a source deals damage to {this}, ");
|
||||
}
|
||||
|
||||
public SourceDealsDamageToThisTriggeredAbility(final SourceDealsDamageToThisTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceDealsDamageToThisTriggeredAbility copy() {
|
||||
return new SourceDealsDamageToThisTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!event.getTargetId().equals(this.sourceId)) {
|
||||
return false;
|
||||
}
|
||||
int damageAmount = event.getAmount();
|
||||
if (damageAmount < 1) {
|
||||
return false;
|
||||
}
|
||||
this.getEffects().setValue("damage", damageAmount);
|
||||
Player sourceController = game.getPlayer(game.getControllerId(event.getSourceId()));
|
||||
if (sourceController != null) {
|
||||
getEffects().setTargetPointer(new FixedTarget(sourceController.getId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ public class RevealDragonFromHandCost extends RevealTargetFromHandCost {
|
|||
|
||||
public RevealDragonFromHandCost() {
|
||||
super(new TargetCardInHand(0, 1, filter));
|
||||
this.text = "you may reveal a Dragon card from your hand";
|
||||
}
|
||||
|
||||
private RevealDragonFromHandCost(final RevealDragonFromHandCost cost) {
|
||||
|
|
|
|||
|
|
@ -59,11 +59,17 @@ public class MillCardsTargetEffect extends OneShotEffect {
|
|||
sb.append("that player");
|
||||
}
|
||||
sb.append(" mills ");
|
||||
if (numberCards.toString().equals("1")) {
|
||||
sb.append("a card");
|
||||
String message = numberCards.getMessage();
|
||||
if (message.isEmpty()) {
|
||||
if (numberCards.toString().equals("1")) {
|
||||
sb.append("a card");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(numberCards.toString()));
|
||||
sb.append(" cards");
|
||||
}
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(numberCards.toString()));
|
||||
sb.append(" cards");
|
||||
sb.append("X cards, where X is the number of ");
|
||||
sb.append(message);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PutLibraryIntoGraveTargetEffect extends OneShotEffect {
|
||||
|
||||
private DynamicValue amount;
|
||||
|
||||
public PutLibraryIntoGraveTargetEffect(int amount) {
|
||||
this(StaticValue.get(amount));
|
||||
}
|
||||
|
||||
public PutLibraryIntoGraveTargetEffect(DynamicValue amount) {
|
||||
super(Outcome.Detriment);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public PutLibraryIntoGraveTargetEffect(final PutLibraryIntoGraveTargetEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount.copy();
|
||||
}
|
||||
|
||||
public void setAmount(DynamicValue value) {
|
||||
this.amount = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PutLibraryIntoGraveTargetEffect copy() {
|
||||
return new PutLibraryIntoGraveTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.millCards(amount.calculate(game, source, this), source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String message = amount.getMessage();
|
||||
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
|
||||
} else {
|
||||
sb.append("that target");
|
||||
}
|
||||
|
||||
sb.append(" mills ");
|
||||
if (message.isEmpty()) {
|
||||
if (amount.toString().equals("1")) {
|
||||
sb.append("a card");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(amount.toString())).append(" cards");
|
||||
}
|
||||
} else {
|
||||
sb.append("X cards, where X is the number of ");
|
||||
}
|
||||
|
||||
if (!message.isEmpty()) {
|
||||
sb.append(message);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ public class SacrificeEffect extends OneShotEffect {
|
|||
if (preText != null) {
|
||||
sb.append(preText);
|
||||
}
|
||||
if (preText != null && (preText.endsWith("player") || preText.endsWith("opponent"))) {
|
||||
if (preText != null && (preText.endsWith("player") || preText.endsWith("opponent") || preText.endsWith("controller"))) {
|
||||
sb.append(" sacrifices ");
|
||||
} else {
|
||||
if (preText == null || preText.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
|
|||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.MillCardsTargetEffect;
|
||||
import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
|
||||
import mage.abilities.effects.common.RollPlanarDieEffect;
|
||||
import mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect;
|
||||
import mage.constants.Planes;
|
||||
|
|
@ -31,7 +30,7 @@ public class LetheLakePlane extends Plane {
|
|||
this.setPlaneType(Planes.PLANE_LETHE_LAKE);
|
||||
|
||||
// At the beginning of your upkeep, put the top ten cards of your libary into your graveyard
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.COMMAND, new PutLibraryIntoGraveTargetEffect(10).setText("that player mills 10 cards"), TargetController.ANY, false, true);
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.COMMAND, new MillCardsTargetEffect(10).setText("that player mills 10 cards"), TargetController.ANY, false, true);
|
||||
this.getAbilities().add(ability);
|
||||
|
||||
// Active player can roll the planar die: Whenever you roll {CHAOS}, target player puts the top ten cards of their library into their graveyard
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue