- Converted Teferi's Puzzle Box to Script

This commit is contained in:
jendave
2011-08-07 01:05:33 +00:00
parent c9fd38bb2b
commit 9d9ac2bb46
6 changed files with 81 additions and 48 deletions

1
.gitattributes vendored
View File

@@ -8910,6 +8910,7 @@ src/forge/card/abilityFactory/AbilityFactory_Animate.java -text svneol=native#te
src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_Choose.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Choose.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_Clash.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Clash.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_Cleanup.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_Combat.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Combat.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_Copy.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Copy.java -text svneol=native#text/plain
src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java -text svneol=native#text/plain

View File

@@ -1,7 +1,12 @@
Name:Teferi's Puzzle Box Name:Teferi's Puzzle Box
ManaCost:4 ManaCost:4
Types:Artifact Types:Artifact
Text:At the beginning of each player's draw step, that player puts the cards in his or her hand on the bottom of his or her library in any order, then draws that many cards. Text:no text
T:Mode$ Phase | Phase$ Draw | ValidPlayer$ Player | TriggerZones$ Battlefield | Execute$ TrigChangeAll | TriggerDescription$ At the beginning of each player's draw step, that player puts the cards in his or her hand on the bottom of his or her library in any order, then draws that many cards.
SVar:TrigChangeAll:DB$ ChangeZoneAll | Defined$ TriggeredPlayer | Origin$ Hand | Destination$ Library | LibraryPosition$ -1 | RememberChanged$ True | ForgetOtherRemembered$ True | SubAbility$ SVar=DBDraw
SVar:DBDraw:DB$Draw | NumCards$ X | Defined$ TriggeredPlayer | SubAbility$ SVar=DBCleanup
SVar:DBCleanup:DB$Cleanup | ClearRemembered$ True
SVar:X:Remembered$Amount
SVar:RemRandomDeck:True SVar:RemRandomDeck:True
SVar:Rarity:Rare SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/teferis_puzzle_box.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/teferis_puzzle_box.jpg

View File

@@ -102,7 +102,7 @@ public class GameActionUtil {
public static void executeDrawStepEffects() { public static void executeDrawStepEffects() {
AllZone.Stack.freezeStack(); AllZone.Stack.freezeStack();
final Player player = AllZone.Phase.getPlayerTurn(); final Player player = AllZone.Phase.getPlayerTurn();
draw_Teferi_Puzzle_Box(player);
draw_Sylvan_Library(player); draw_Sylvan_Library(player);
AllZone.Stack.unfreezeStack(); AllZone.Stack.unfreezeStack();
@@ -4641,44 +4641,6 @@ public class GameActionUtil {
}//end for }//end for
} }
private static void draw_Teferi_Puzzle_Box(Player player) {
CardList list = AllZoneUtil.getCardsInPlay("Teferi's Puzzle Box");
PlayerZone Playerhand = AllZone.getZone(Constant.Zone.Hand, player);
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
CardList hand = new CardList();
Card[] handlist = null;
if(list.size() > 0) {
AllZone.Display.showMessage("Shuffle cards back into your library: ");
ButtonUtil.enableOnlyCancel();
hand.addAll(Playerhand.getCards());
int Count = hand.size();
for(int i = 0; i < list.size(); i++) {
if(AllZone.HumanPlayer.equals(player)) {
for(int e = 0; e < Count; e++) {
if(hand.size() == 0) hand.addAll(Playerhand.getCards());
handlist = hand.toArray();
Object check = GuiUtils.getChoice("Select card to put on bottom of library", handlist);
if(check != null) {
Card target = ((Card) check);
hand.remove(target);
AllZone.GameAction.moveTo(lib, target);
}
}
}else {
for(int x = 0; x < hand.size(); x++) hand.remove(hand.get(x));
hand.addAll(Playerhand.getCards());
for(int e = 0; e < hand.size(); e++) {
AllZone.GameAction.moveTo(lib, hand.get(e));
}
}
player.drawCards(Count);
}
}
}// Teferi_Puzzle_Box
private static void upkeep_Carnophage() { private static void upkeep_Carnophage() {
final Player player = AllZone.Phase.getPlayerTurn(); final Player player = AllZone.Phase.getPlayerTurn();

View File

@@ -681,6 +681,11 @@ public class AbilityFactory {
SA = AbilityFactory_DelayedTrigger.getDrawback(this); SA = AbilityFactory_DelayedTrigger.getDrawback(this);
} }
if(API.equals("Cleanup")) {
if(isDb)
SA = AbilityFactory_Cleanup.getDrawback(this);
}
if (SA == null) if (SA == null)
throw new RuntimeException("AbilityFactory : SpellAbility was not created for "+hostCard.getName()+". Looking for API: "+API); throw new RuntimeException("AbilityFactory : SpellAbility was not created for "+hostCard.getName()+". Looking for API: "+API);

View File

@@ -1468,16 +1468,27 @@ public class AbilityFactory_ChangeZone {
String destination = params.get("Destination"); String destination = params.get("Destination");
String origin = params.get("Origin"); String origin = params.get("Origin");
CardList cards = AllZoneUtil.getCardsInZone(origin); CardList cards = null;
ArrayList<Player> tgtPlayers = null;
Target tgt = af.getAbTgt();
if (tgt != null)
tgtPlayers = tgt.getTargetPlayers();
else if (params.containsKey("Defined")) // Make sure Defined exists to use it
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);
if (tgtPlayers == null || tgtPlayers.isEmpty())
cards = AllZoneUtil.getCardsInZone(origin);
else
cards = AllZoneUtil.getCardsInZone(origin,tgtPlayers.get(0));
Player tgtPlayer = null;
if(af.getAbTgt() != null)
if(af.getAbTgt().getTargetPlayers() != null) {
tgtPlayer = af.getAbTgt().getTargetPlayers().get(0);
cards = AllZoneUtil.getCardsInZone(origin,tgtPlayer);
}
cards = filterListByType(cards, params, sa); cards = filterListByType(cards, params, sa);
if (params.containsKey("ForgetOtherRemembered"))
sa.getSourceCard().clearRemembered();
String remember = params.get("RememberChanged");
// I don't know if library position is necessary. It's here if it is, just in case // I don't know if library position is necessary. It's here if it is, just in case
int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0; int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0;
@@ -1490,6 +1501,9 @@ public class AbilityFactory_ChangeZone {
} }
else else
AllZone.GameAction.moveTo(destination, c, libraryPos); AllZone.GameAction.moveTo(destination, c, libraryPos);
if (remember != null)
sa.getSourceCard().addRemembered(c);
} }
// if Shuffle parameter exists, and any amount of cards were owned by that player, then shuffle that library // if Shuffle parameter exists, and any amount of cards were owned by that player, then shuffle that library

View File

@@ -0,0 +1,46 @@
package forge.card.abilityFactory;
import forge.card.spellability.Ability_Sub;
import forge.card.spellability.SpellAbility;
import java.util.HashMap;
// Cleanup is not the same as other AFs, it is only used as a Drawback, and only used to Cleanup particular card states
// That need to be reset. I'm creating this to clear Remembered Cards at the end of an Effect so they don't get shown on a card
// After the effect finishes resolving.
public class AbilityFactory_Cleanup {
public static Ability_Sub getDrawback(final AbilityFactory AF)
{
final Ability_Sub drawback = new Ability_Sub(AF.getHostCard(),AF.getAbTgt()) {
private static final long serialVersionUID = 6192972525033429820L;
@Override
public boolean chkAI_Drawback() {
return true;
}
@Override
public boolean doTrigger(boolean mandatory) {
return true;
}
@Override
public void resolve() {
doResolve(AF,this);
}
};
return drawback;
}
private static void doResolve(AbilityFactory AF,SpellAbility sa)
{
HashMap<String,String> params = AF.getMapParams();
if (params.containsKey("ClearRemembered"))
sa.getSourceCard().clearRemembered();
AbilityFactory.resolveSubAbility(sa);
}
}