mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Support Captain America
This commit is contained in:
@@ -838,12 +838,12 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(CostUnattach cost) {
|
||||
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach == null) {
|
||||
final CardCollection cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach.isEmpty()) {
|
||||
// We really shouldn't be able to get here if there's nothing to unattach
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(cardToUnattach);
|
||||
return PaymentDecision.card(cardToUnattach.getFirst());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
*/
|
||||
package forge.game.cost;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
@@ -70,27 +69,27 @@ public class CostUnattach extends CostPartWithList {
|
||||
*/
|
||||
@Override
|
||||
public final boolean canPay(final SpellAbility ability, final Player payer, final boolean effect) {
|
||||
return findCardToUnattach(ability.getHostCard(), payer, ability) != null;
|
||||
return !findCardToUnattach(ability.getHostCard(), payer, ability).isEmpty();
|
||||
}
|
||||
|
||||
public Card findCardToUnattach(final Card source, Player activator, SpellAbility ability) {
|
||||
public CardCollection findCardToUnattach(final Card source, Player activator, SpellAbility ability) {
|
||||
CardCollection attachees = new CardCollection();
|
||||
if (payCostFromSource()) {
|
||||
if (source.isEquipping()) {
|
||||
return source;
|
||||
attachees.add(source);
|
||||
}
|
||||
} else if (getType().equals("OriginalHost")) {
|
||||
Card originalEquipment = ability.getOriginalHost();
|
||||
if (originalEquipment.isEquipping()) {
|
||||
return originalEquipment;
|
||||
attachees.add(originalEquipment);
|
||||
}
|
||||
} else {
|
||||
List<Card> attachees = CardLists.getValidCards(source.getEquippedBy(), this.getType(), activator, source, ability);
|
||||
if (attachees.size() > 0) {
|
||||
// Just pick the first one, although maybe give a dialog
|
||||
return attachees.get(0);
|
||||
attachees.addAll(source.getEquippedBy());
|
||||
if (!getType().contains("X") || ability.getXManaCostPaid() != null) {
|
||||
attachees = CardLists.getValidCards(attachees, this.getType(), activator, source, ability);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return attachees;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -2,8 +2,8 @@ Name:Captain America, First Avenger
|
||||
ManaCost:R W U
|
||||
Types:Legendary Creature Human Soldier Hero
|
||||
PT:4/4
|
||||
A:AB$ DealDamage | Cost$ 3 Unattach<Equipment.Attached/Equipment attached to NICKNAME> | PrecostDesc$ Throw . . . — | ValidTgts$ Any | TgtPrompt$ Select any target to distribute damage to | NumDmg$ X | TargetMin$ 1 | TargetMax$ 3 | DividedAsYouChoose$ X | SpellDescription$ He deals damage equal to that Equipment's mana value divided as you choose among one, two, or three targets.
|
||||
SVar:X:Unattached$CardManaCost
|
||||
A:AB$ DealDamage | Cost$ 3 Unattach<Equipment.Attached+cmcEQX/an Equipment attached to NICKNAME> | Announce$ X | PrecostDesc$ Throw . . . — | ValidTgts$ Any | TgtPrompt$ Select any target to distribute damage to | NumDmg$ X | TargetMin$ 1 | TargetMax$ 3 | DividedAsYouChoose$ X | SpellDescription$ He deals damage equal to that Equipment's mana value divided as you choose among one, two, or three targets.
|
||||
SVar:X:Count$xPaid
|
||||
T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ DBAttach | TriggerDescription$ . . . Catch — At the beginning of combat on your turn, attach up one target Equipment you control to NICKNAME.
|
||||
SVar:DBAttach:DB$ Attach | ValidTgts$ Equipment.YouCtrl | TargetMin$ 0 | TargetMax$ 1 | TgtPrompt$ Select up to one target Equipment you control | Object$ Targeted | Defined$ Self
|
||||
Oracle:Throw . . . — {3}, Unattach an Equipment from Captain America: He deals damage equal to that Equipment's mana value divided as you choose among one, two, or three targets.\n. . . Catch — At the beginning of combat on your turn, attach up one target Equipment you control to Captain America.
|
||||
|
||||
@@ -1330,9 +1330,20 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
@Override
|
||||
public PaymentDecision visit(final CostUnattach cost) {
|
||||
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach != null && confirmAction(cost, Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName())))) {
|
||||
return PaymentDecision.card(cardToUnattach);
|
||||
final CardCollection cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||
if (cardToUnattach.size() == 1 && confirmAction(cost, Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getFirst().getName())))) {
|
||||
return PaymentDecision.card(cardToUnattach.getFirst());
|
||||
}
|
||||
if (cardToUnattach.size() > 1) {
|
||||
int c = cost.getAbilityAmount(ability);
|
||||
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, cardToUnattach, ability);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage(Localizer.getInstance().getMessage("lblUnattachCardConfirm", cost.getDescriptiveType()));
|
||||
inp.showAndWait();
|
||||
if (inp.hasCancelled() || inp.getSelected().size() != c) {
|
||||
return null;
|
||||
}
|
||||
return PaymentDecision.card(inp.getSelected());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1341,6 +1352,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
public boolean paysRightAfterDecision() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean confirmAction(CostPart costPart, String message) {
|
||||
CardView cardView = ability.getCardView();
|
||||
if (GuiBase.getInterface().isLibgdxPort()) {
|
||||
|
||||
Reference in New Issue
Block a user