mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Support using Shift+click to tap multiple lands while paying for a spell
This commit is contained in:
@@ -2,7 +2,9 @@ package forge.match.input;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
protected final SpellAbility saPaidFor;
|
protected final SpellAbility saPaidFor;
|
||||||
private final boolean wasFloatingMana;
|
private final boolean wasFloatingMana;
|
||||||
private final Object zoneToRestore;
|
private final Object zoneToRestore;
|
||||||
|
private final Queue<Card> delaySelectCards = new LinkedList<Card>();
|
||||||
|
|
||||||
private boolean bPaid = false;
|
private boolean bPaid = false;
|
||||||
protected Boolean canPayManaCost = null;
|
protected Boolean canPayManaCost = null;
|
||||||
@@ -67,11 +70,34 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onCardSelected(final Card card, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) {
|
protected boolean onCardSelected(final Card card, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) {
|
||||||
if (card.getManaAbilities().isEmpty()) {
|
if (otherCardsToSelect != null) {
|
||||||
|
for (Card c : otherCardsToSelect) {
|
||||||
|
for (SpellAbility sa : c.getManaAbilities()) {
|
||||||
|
if (sa.canPlay()) {
|
||||||
|
delaySelectCards.add(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!card.getManaAbilities().isEmpty() && activateManaAbility(card, manaCost)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return activateDelayedCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean activateDelayedCard() {
|
||||||
|
if (delaySelectCards.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// only tap card if the mana is needed
|
if (manaCost.isPaid()) {
|
||||||
return activateManaAbility(card, manaCost);
|
delaySelectCards.clear(); //clear delayed cards if mana cost already paid
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (activateManaAbility(delaySelectCards.poll(), manaCost)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return activateDelayedCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -357,6 +383,9 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
|||||||
|
|
||||||
protected final void updateMessage() {
|
protected final void updateMessage() {
|
||||||
locked = false;
|
locked = false;
|
||||||
|
if (activateDelayedCard()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (supportAutoPay()) {
|
if (supportAutoPay()) {
|
||||||
if (canPayManaCost == null) {
|
if (canPayManaCost == null) {
|
||||||
//use AI utility to determine if mana cost can be paid if that hasn't been determined yet
|
//use AI utility to determine if mana cost can be paid if that hasn't been determined yet
|
||||||
|
|||||||
Reference in New Issue
Block a user