mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
[WWK] rework implementation of Dead Reckoning
This commit is contained in:
parent
4165c94a74
commit
19f38a70da
1 changed files with 29 additions and 29 deletions
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -9,16 +7,19 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.EachTargetPointer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class DeadReckoning extends CardImpl {
|
||||
|
||||
|
|
@ -27,7 +28,8 @@ public final class DeadReckoning extends CardImpl {
|
|||
|
||||
// You may put target creature card from your graveyard on top of your library. If you do, Dead Reckoning deals damage equal to that card's power to target creature.
|
||||
this.getSpellAbility().addEffect(new DeadReckoningEffect());
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
}
|
||||
|
||||
private DeadReckoning(final DeadReckoning card) {
|
||||
|
|
@ -44,7 +46,9 @@ class DeadReckoningEffect extends OneShotEffect {
|
|||
|
||||
public DeadReckoningEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "You may put target creature card from your graveyard on top of your library. If you do, {this} deals damage equal to that card's power to target creature";
|
||||
this.staticText = "you may put target creature card from your graveyard on top of your library. " +
|
||||
"If you do, {this} deals damage equal to that card's power to target creature";
|
||||
this.setTargetPointer(new EachTargetPointer());
|
||||
}
|
||||
|
||||
public DeadReckoningEffect(final DeadReckoningEffect effect) {
|
||||
|
|
@ -58,28 +62,24 @@ class DeadReckoningEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
TargetCardInYourGraveyard target1 = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
|
||||
TargetCreaturePermanent target2 = new TargetCreaturePermanent();
|
||||
|
||||
if (controller != null) {
|
||||
if (target1.canChoose(source.getControllerId(), source, game)
|
||||
&& controller.choose(Outcome.Benefit, target1, source, game)
|
||||
&& target2.canChoose(source.getControllerId(), source, game)
|
||||
&& controller.choose(Outcome.Damage, target2, source, game)) {
|
||||
Card creatureInGraveyard = game.getCard(target1.getFirstTarget());
|
||||
if (creatureInGraveyard != null) {
|
||||
if (controller.putCardsOnTopOfLibrary(creatureInGraveyard, game, source, true)) {
|
||||
int power = creatureInGraveyard.getPower().getValue();
|
||||
Permanent creature = game.getPermanent(target2.getFirstTarget());
|
||||
if (creature != null) {
|
||||
creature.damage(power, source.getSourceId(), source, game, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
List<UUID> targets = this.getTargetPointer().getTargets(game, source);
|
||||
Card card = game.getCard(targets.get(0));
|
||||
if (player == null || card == null || !player.chooseUse(
|
||||
outcome, "Put " + card.getName() + " on top of your library?", source, game
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
int power = card.getPower().getValue();
|
||||
player.putCardsOnTopOfLibrary(card, game, source, false);
|
||||
if (targets.size() < 2 || power < 1) {
|
||||
return true;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(targets.get(1));
|
||||
if (permanent == null) {
|
||||
return true;
|
||||
}
|
||||
permanent.damage(power, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue