mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Support UnlessCost for random Discard
This commit is contained in:
@@ -1064,7 +1064,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory){
|
private boolean prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory) {
|
||||||
if (sa.hasParam("TargetingPlayer")) {
|
if (sa.hasParam("TargetingPlayer")) {
|
||||||
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
|
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
|
||||||
sa.setTargetingPlayer(targetingPlayer);
|
sa.setTargetingPlayer(targetingPlayer);
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ Name:Balduvian Horde
|
|||||||
ManaCost:2 R R
|
ManaCost:2 R R
|
||||||
Types:Creature Human Barbarian
|
Types:Creature Human Barbarian
|
||||||
PT:5/5
|
PT:5/5
|
||||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDiscard | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSac | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
||||||
SVar:TrigDiscard:DB$ Discard | NumCards$ 1 | Mode$ Random | Optional$ True | RememberDiscarded$ True | SubAbility$ DBSacrifice
|
SVar:TrigSac:DB$ Sacrifice | SacValid$ Self | UnlessCost$ Discard<1/Random> | UnlessPayer$ You
|
||||||
SVar:DBSacrifice:DB$ Sacrifice | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | SubAbility$ DBCleanup
|
|
||||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
|
||||||
SVar:X:Remembered$Amount
|
|
||||||
SVar:NeedsToPlayVar:Y GE2
|
SVar:NeedsToPlayVar:Y GE2
|
||||||
SVar:Y:Count$InYourHand
|
SVar:Y:Count$InYourHand
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/balduvian_horde.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/balduvian_horde.jpg
|
||||||
|
|||||||
@@ -2,11 +2,8 @@ Name:Minotaur Explorer
|
|||||||
ManaCost:1 R
|
ManaCost:1 R
|
||||||
Types:Creature Minotaur Scout
|
Types:Creature Minotaur Scout
|
||||||
PT:3/3
|
PT:3/3
|
||||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDiscard | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSac | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
||||||
SVar:TrigDiscard:DB$ Discard | NumCards$ 1 | Mode$ Random | Optional$ True | RememberDiscarded$ True | SubAbility$ DBSacrifice
|
SVar:TrigSac:DB$ Sacrifice | SacValid$ Self | UnlessCost$ Discard<1/Random> | UnlessPayer$ You
|
||||||
SVar:DBSacrifice:DB$ Sacrifice | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | SubAbility$ DBCleanup
|
|
||||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
|
||||||
SVar:X:Remembered$Amount
|
|
||||||
SVar:NeedsToPlayVar:Y GE2
|
SVar:NeedsToPlayVar:Y GE2
|
||||||
SVar:Y:Count$InYourHand
|
SVar:Y:Count$InYourHand
|
||||||
SVar:Picture:http://resources.wizards.com/magic/cards/od/en-us/card31786.jpg
|
SVar:Picture:http://resources.wizards.com/magic/cards/od/en-us/card31786.jpg
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ Name:Pillaging Horde
|
|||||||
ManaCost:2 R R
|
ManaCost:2 R R
|
||||||
Types:Creature Human Barbarian
|
Types:Creature Human Barbarian
|
||||||
PT:5/5
|
PT:5/5
|
||||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDiscard | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSac | TriggerDescription$ When CARDNAME enters the battlefield, sacrifice it unless you discard a card at random.
|
||||||
SVar:TrigDiscard:DB$ Discard | NumCards$ 1 | Mode$ Random | Optional$ True | RememberDiscarded$ True | SubAbility$ DBSacrifice
|
SVar:TrigSac:DB$ Sacrifice | SacValid$ Self | UnlessCost$ Discard<1/Random> | UnlessPayer$ You
|
||||||
SVar:DBSacrifice:DB$ Sacrifice | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0 | SubAbility$ DBCleanup
|
|
||||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
|
||||||
SVar:X:Remembered$Amount
|
SVar:X:Remembered$Amount
|
||||||
SVar:NeedsToPlayVar:Y GE2
|
SVar:NeedsToPlayVar:Y GE2
|
||||||
SVar:Y:Count$InYourHand
|
SVar:Y:Count$InYourHand
|
||||||
|
|||||||
@@ -269,8 +269,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
final CardCollection enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
|
final CardCollection enoughType = CardLists.filter(list, CardPredicates.isOwner(p));
|
||||||
if (enoughType.size() < c) {
|
if (enoughType.size() < c) {
|
||||||
list.removeAll((CardCollectionView)enoughType);
|
list.removeAll((CardCollectionView)enoughType);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
payableZone.add(p);
|
payableZone.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,9 +436,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
||||||
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblExertCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability) ? PaymentDecision.card(source) : null;
|
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblExertCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability) ? PaymentDecision.card(source) : null;
|
||||||
}
|
}
|
||||||
else {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer c = cost.convertAmount();
|
Integer c = cost.convertAmount();
|
||||||
@@ -782,8 +779,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
inp.setMessage(Localizer.getInstance().getMessage("lblSelectNCardOfSameColorToReveal", String.valueOf(num)));
|
inp.setMessage(Localizer.getInstance().getMessage("lblSelectNCardOfSameColorToReveal", String.valueOf(num)));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Integer num = cost.convertAmount();
|
Integer num = cost.convertAmount();
|
||||||
|
|
||||||
CardCollectionView hand = player.getCardsIn(cost.getRevealFrom());
|
CardCollectionView hand = player.getCardsIn(cost.getRevealFrom());
|
||||||
@@ -1029,9 +1025,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
|
||||||
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability) ? PaymentDecision.card(source) : null;
|
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(source.getName())), ability) ? PaymentDecision.card(source) : null;
|
||||||
}
|
}
|
||||||
else {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("OriginalHost")) {
|
if (type.equals("OriginalHost")) {
|
||||||
@@ -1039,9 +1033,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
if (host.getController() == ability.getActivatingPlayer() && host.isInPlay()) {
|
if (host.getController() == ability.getActivatingPlayer() && host.isInPlay()) {
|
||||||
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(host.getName())), ability) ? PaymentDecision.card(host) : null;
|
return player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblSacrificeCardConfirm", CardTranslation.getTranslatedName(host.getName())), ability) ? PaymentDecision.card(host) : null;
|
||||||
}
|
}
|
||||||
else {
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount.equals("All")) {
|
if (amount.equals("All")) {
|
||||||
@@ -1209,8 +1201,6 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaymentDecision visit(final CostUnattach cost) {
|
public PaymentDecision visit(final CostUnattach cost) {
|
||||||
final Card source = ability.getHostCard();
|
|
||||||
|
|
||||||
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
|
||||||
if (cardToUnattach != null && player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName())), ability)) {
|
if (cardToUnattach != null && player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblUnattachCardConfirm", CardTranslation.getTranslatedName(cardToUnattach.getName())), ability)) {
|
||||||
return PaymentDecision.card(cardToUnattach);
|
return PaymentDecision.card(cardToUnattach);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import forge.gamemodes.match.input.InputPayManaOfCostPayment;
|
|||||||
import forge.gamemodes.match.input.InputSelectCardsFromList;
|
import forge.gamemodes.match.input.InputSelectCardsFromList;
|
||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.util.SGuiChoose;
|
import forge.gui.util.SGuiChoose;
|
||||||
|
import forge.util.Aggregates;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
@@ -565,15 +566,21 @@ public class HumanPlay {
|
|||||||
if (!hasPaid) { return false; }
|
if (!hasPaid) { return false; }
|
||||||
}
|
}
|
||||||
else if (part instanceof CostDiscard) {
|
else if (part instanceof CostDiscard) {
|
||||||
|
int amount = getAmountFromPartX(part, source, sourceAbility);
|
||||||
if ("Hand".equals(part.getType())) {
|
if ("Hand".equals(part.getType())) {
|
||||||
if (!p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantDiscardYourHand"), sourceAbility)) {
|
if (!p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantDiscardYourHand"), sourceAbility)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
((CostDiscard)part).payAsDecided(p, PaymentDecision.card(p.getCardsIn(ZoneType.Hand)), sourceAbility);
|
((CostDiscard)part).payAsDecided(p, PaymentDecision.card(p.getCardsIn(ZoneType.Hand)), sourceAbility);
|
||||||
|
} else if ("Random".equals(part.getType())) {
|
||||||
|
if (!part.canPay(sourceAbility, p) || !p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblWouldYouLikeRandomDiscardTargetCard", amount), sourceAbility)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
((CostDiscard)part).payAsDecided(p, (PaymentDecision.card(Aggregates.random(p.getCardsIn(ZoneType.Hand), amount, new CardCollection()))), sourceAbility);
|
||||||
} else {
|
} else {
|
||||||
CardCollectionView list = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), part.getType(), p, source, sourceAbility);
|
CardCollectionView list = CardLists.getValidCards(p.getCardsIn(ZoneType.Hand), part.getType(), p, source, sourceAbility);
|
||||||
int amount = getAmountFromPartX(part, source, sourceAbility);
|
|
||||||
boolean hasPaid = payCostPart(controller, p, sourceAbility, (CostPartWithList)part, amount, list, Localizer.getInstance().getMessage("lbldiscard") + orString);
|
boolean hasPaid = payCostPart(controller, p, sourceAbility, (CostPartWithList)part, amount, list, Localizer.getInstance().getMessage("lbldiscard") + orString);
|
||||||
if (!hasPaid) { return false; }
|
if (!hasPaid) { return false; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user