forked from External/mage
Fix Dragon's Fire targeting issue (#13756)
This commit is contained in:
parent
924585cb86
commit
f674034cdf
1 changed files with 32 additions and 30 deletions
|
|
@ -18,8 +18,8 @@ import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
|
||||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,11 +54,10 @@ class DragonsFireCost extends CostImpl {
|
||||||
|
|
||||||
public enum DragonZone {
|
public enum DragonZone {
|
||||||
HAND,
|
HAND,
|
||||||
BATTLEFIELD,
|
BATTLEFIELD
|
||||||
NONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DragonZone dragonZone = DragonZone.NONE;
|
private DragonZone dragonZone = null;
|
||||||
private UUID selectedCardId = null;
|
private UUID selectedCardId = null;
|
||||||
|
|
||||||
private static final FilterCard handFilter = new FilterCard("Dragon card from your hand");
|
private static final FilterCard handFilter = new FilterCard("Dragon card from your hand");
|
||||||
|
|
@ -90,14 +89,13 @@ class DragonsFireCost extends CostImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||||
this.getTargets().clear();
|
dragonZone = null;
|
||||||
dragonZone = DragonZone.NONE;
|
|
||||||
selectedCardId = null;
|
selectedCardId = null;
|
||||||
Player controller = game.getPlayer(controllerId);
|
Player controller = game.getPlayer(controllerId);
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
boolean dragonInHand = false;
|
boolean dragonInHand = false;
|
||||||
boolean dragonOnBattlefield = false;
|
boolean dragonOnBattlefield = false;
|
||||||
DragonZone chosenZone = DragonZone.NONE;
|
DragonZone chosenZone = null;
|
||||||
for (UUID cardId : controller.getHand()) {
|
for (UUID cardId : controller.getHand()) {
|
||||||
Card card = game.getCard(cardId);
|
Card card = game.getCard(cardId);
|
||||||
if (card != null && card.hasSubtype(SubType.DRAGON, game)) {
|
if (card != null && card.hasSubtype(SubType.DRAGON, game)) {
|
||||||
|
|
@ -132,23 +130,25 @@ class DragonsFireCost extends CostImpl {
|
||||||
}
|
}
|
||||||
switch (chosenZone) {
|
switch (chosenZone) {
|
||||||
case HAND:
|
case HAND:
|
||||||
this.getTargets().add(new TargetCardInHand(handFilter));
|
TargetCardInHand handTarget = new TargetCardInHand(handFilter);
|
||||||
if (this.getTargets().choose(Outcome.Benefit, controllerId, source.getSourceId(), source, game)) {
|
handTarget.withNotTarget(true);
|
||||||
Card card = game.getCard(this.getTargets().getFirstTarget());
|
if (controller.choose(Outcome.Benefit, handTarget, source, game)) {
|
||||||
|
Card card = game.getCard(handTarget.getFirstTarget());
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
dragonZone = DragonZone.HAND;
|
dragonZone = DragonZone.HAND;
|
||||||
selectedCardId = this.getTargets().getFirstTarget();
|
selectedCardId = handTarget.getFirstTarget();
|
||||||
controller.revealCards(source, new CardsImpl(card), game);
|
controller.revealCards(source, new CardsImpl(card), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BATTLEFIELD:
|
case BATTLEFIELD:
|
||||||
this.getTargets().add(new TargetControlledPermanent(battlefieldFilter));
|
TargetPermanent battlefieldTarget = new TargetPermanent(battlefieldFilter);
|
||||||
if (this.getTargets().choose(Outcome.Benefit, controllerId, source.getSourceId(), source, game)) {
|
battlefieldTarget.withNotTarget(true);
|
||||||
Permanent permanent = game.getPermanent(this.getTargets().getFirstTarget());
|
if (controller.choose(Outcome.Benefit, battlefieldTarget, source, game)) {
|
||||||
|
Permanent permanent = game.getPermanent(battlefieldTarget.getFirstTarget());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
dragonZone = DragonZone.BATTLEFIELD;
|
dragonZone = DragonZone.BATTLEFIELD;
|
||||||
selectedCardId = this.getTargets().getFirstTarget();
|
selectedCardId = battlefieldTarget.getFirstTarget();
|
||||||
game.informPlayers(controller.getLogName() + " chooses " + permanent.getLogName());
|
game.informPlayers(controller.getLogName() + " chooses " + permanent.getLogName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +190,7 @@ class DragonsFireEffect extends OneShotEffect {
|
||||||
if (targetedPermanent == null) {
|
if (targetedPermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DragonsFireCost.DragonZone dragonZone = DragonsFireCost.DragonZone.NONE;
|
DragonsFireCost.DragonZone dragonZone = null;
|
||||||
UUID selectedCardId = null;
|
UUID selectedCardId = null;
|
||||||
int damage = 3;
|
int damage = 3;
|
||||||
for (Cost cost : source.getCosts()) {
|
for (Cost cost : source.getCosts()) {
|
||||||
|
|
@ -201,21 +201,23 @@ class DragonsFireEffect extends OneShotEffect {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (dragonZone) {
|
if (dragonZone != null) {
|
||||||
case HAND:
|
switch (dragonZone) {
|
||||||
Card card = game.getCard(selectedCardId);
|
case HAND:
|
||||||
if (card != null) {
|
Card card = game.getCard(selectedCardId);
|
||||||
damage = card.getPower().getValue();
|
if (card != null) {
|
||||||
}
|
damage = card.getPower().getValue();
|
||||||
break;
|
}
|
||||||
case BATTLEFIELD:
|
break;
|
||||||
Permanent dragon = game.getPermanentOrLKIBattlefield(selectedCardId);
|
case BATTLEFIELD:
|
||||||
if (dragon != null) {
|
Permanent dragon = game.getPermanentOrLKIBattlefield(selectedCardId);
|
||||||
damage = dragon.getPower().getValue();
|
if (dragon != null) {
|
||||||
}
|
damage = dragon.getPower().getValue();
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
targetedPermanent.damage(damage, source.getSourceId(), source, game);
|
targetedPermanent.damage(damage, source.getSourceId(), source, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue