mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Convert Sylvan Library to Script
This commit is contained in:
@@ -2,6 +2,12 @@ Name:Sylvan Library
|
||||
ManaCost:1 G
|
||||
Types:Enchantment
|
||||
Text:no text
|
||||
T:Mode$ Phase | Phase$ Draw | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigDraw | OptionalDecider$ You |TriggerDescription$ At the beginning of your draw step, you may draw two additional cards. If you do, choose two cards in your hand drawn this turn. For each of those cards, pay 4 life or put the card on top of your library.
|
||||
SVar:TrigDraw:AB$ Draw | Cost$ 0 | Defined$ TriggeredPlayer | NumCards$ 2 | SubAbility$ ChooseDrawn
|
||||
SVar:ChooseDrawn:DB$ ChooseCard | ChoiceZone$ Hand | Choices$ Card.YouOwn+DrawnThisTurn | Amount$ 2 | RememberChosen$ True | AILogic$ Worst | SubAbility$ DBPayOrReturn
|
||||
SVar:DBPayOrReturn:DB$ RepeatEach | UseImprinted$ True | RepeatCards$ Card.IsRemembered | Zone$ Hand | RepeatSubAbility$ DBReplace | SubAbility$ DBCleanup
|
||||
SVar:DBReplace:DB$ ChangeZone | Origin$ Hand | Destination$ Library | ChangeType$ Card.IsImprinted | UnlessCost$ PayLife<4> | UnlessPayer$ TriggeredPlayer | SubAbility$ DBCleanup
|
||||
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/sylvan_library.jpg
|
||||
|
||||
@@ -6700,6 +6700,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (!this.hasLevelUp()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("DrawnThisTurn")) {
|
||||
if (!this.getDrawnThisTurn()) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.startsWith("enteredBattlefieldThisTurn")) {
|
||||
if (!(this.getTurnInZone() == Singletons.getModel().getGame().getPhaseHandler().getTurn())) {
|
||||
return false;
|
||||
|
||||
@@ -85,18 +85,29 @@ public class ChooseCardEffect extends SpellEffect {
|
||||
break;
|
||||
}
|
||||
} else { // Computer
|
||||
if (sa.hasParam("AILogic") && sa.getParam("AILogic").equals("BestBlocker")) {
|
||||
String logic = sa.getParam("AILogic");
|
||||
Card choice = null;
|
||||
if (logic == null) {
|
||||
// Base Logic is choose "best"
|
||||
choice = CardFactoryUtil.getBestAI(choices);
|
||||
} else if ("WorstCard".equals(logic)) {
|
||||
choice = CardFactoryUtil.getWorstAI(choices);
|
||||
} else if (logic.equals("BestBlocker")) {
|
||||
if (!CardLists.filter(choices, Presets.UNTAPPED).isEmpty()) {
|
||||
choices = CardLists.filter(choices, Presets.UNTAPPED);
|
||||
}
|
||||
chosen.add(CardFactoryUtil.getBestCreatureAI(choices));
|
||||
} else if (sa.hasParam("AILogic") && sa.getParam("AILogic").equals("Clone")) {
|
||||
choice = CardFactoryUtil.getBestCreatureAI(choices);
|
||||
} else if (logic.equals("Clone")) {
|
||||
if (!CardLists.getValidCards(choices, "Permanent.YouDontCtrl,Permanent.NonLegendary", host.getController(), host).isEmpty()) {
|
||||
choices = CardLists.getValidCards(choices, "Permanent.YouDontCtrl,Permanent.NonLegendary", host.getController(), host);
|
||||
}
|
||||
chosen.add(CardFactoryUtil.getBestAI(choices));
|
||||
choice = CardFactoryUtil.getBestAI(choices);
|
||||
}
|
||||
if (choice != null) {
|
||||
chosen.add(choice);
|
||||
choices.remove(choice);
|
||||
} else {
|
||||
chosen.add(CardFactoryUtil.getBestAI(choices));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,79 +222,5 @@ class CardFactoryEnchantments {
|
||||
card.addComesIntoPlayCommand(intoPlay);
|
||||
card.addDestroyCommand(toGrave);
|
||||
} // *************** END ************ END **************************
|
||||
|
||||
// *************** START *********** START **************************
|
||||
else if (cardName.equals("Sylvan Library")) {
|
||||
|
||||
final Ability ability = new Ability(card, "") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
final Player player = card.getController();
|
||||
if (player.isHuman()) {
|
||||
final String cardQuestion = "Pay 4 life and keep in hand?";
|
||||
player.drawCards(2);
|
||||
int numPutBack = 0;
|
||||
for (Card c : player.getCardsIn(ZoneType.Hand)) {
|
||||
if (c.getDrawnThisTurn()) {
|
||||
numPutBack++;
|
||||
}
|
||||
}
|
||||
numPutBack = Math.min(2, numPutBack);
|
||||
for (int i = 0; i < numPutBack; i++) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(card).append(" - Select a card drawn this turn: ").append(numPutBack - i)
|
||||
.append(" of " + numPutBack);
|
||||
final String prompt = sb.toString();
|
||||
Singletons.getModel().getMatch().getInput().setInput(new Input() {
|
||||
private static final long serialVersionUID = -3389565833121544797L;
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
if (player.getZone(ZoneType.Hand).size() == 0) {
|
||||
this.stop();
|
||||
}
|
||||
CMatchUI.SINGLETON_INSTANCE.showMessage(prompt);
|
||||
ButtonUtil.disableAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCard(final Card card) {
|
||||
Zone zone = Singletons.getModel().getGame().getZoneOf(card);
|
||||
if (zone.is(ZoneType.Hand) && card.getDrawnThisTurn()) {
|
||||
if (player.canPayLife(4) && GameActionUtil.showYesNoDialog(card, cardQuestion)) {
|
||||
player.payLife(4, card);
|
||||
// card stays in hand
|
||||
} else {
|
||||
Singletons.getModel().getGame().getAction().moveToLibrary(card);
|
||||
}
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
}); // end Input
|
||||
}
|
||||
} else {
|
||||
// Computer, but he's too stupid to play this
|
||||
}
|
||||
} // resolve
|
||||
}; // Ability
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("At the beginning of your draw step, you may draw two additional cards. ");
|
||||
sb.append("If you do, choose two cards in your hand drawn this turn. For each of those cards, ");
|
||||
sb.append("pay 4 life or put the card on top of your library.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
final StringBuilder sbTrg = new StringBuilder();
|
||||
sbTrg.append("Mode$ Phase | Phase$ Draw | ValidPlayer$ You | OptionalDecider$ You | ");
|
||||
sbTrg.append("TriggerZones$ Battlefield | TriggerDescription$ At the beginning of ");
|
||||
sbTrg.append("your draw step, you may draw two additional cards. If you do, choose two ");
|
||||
sbTrg.append("cards in your hand drawn this turn. For each of those cards, ");
|
||||
sbTrg.append("pay 4 life or put the card on top of your library.");
|
||||
final Trigger drawStepTrigger = TriggerHandler.parseTrigger(sbTrg.toString(), card, true);
|
||||
|
||||
drawStepTrigger.setOverridingAbility(ability);
|
||||
card.addTrigger(drawStepTrigger);
|
||||
} // *************** END ************ END **************************
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user