- 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

View File

@@ -102,7 +102,7 @@ public class GameActionUtil {
public static void executeDrawStepEffects() {
AllZone.Stack.freezeStack();
final Player player = AllZone.Phase.getPlayerTurn();
draw_Teferi_Puzzle_Box(player);
draw_Sylvan_Library(player);
AllZone.Stack.unfreezeStack();
@@ -4640,44 +4640,6 @@ public class GameActionUtil {
}//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() {
final Player player = AllZone.Phase.getPlayerTurn();

View File

@@ -680,6 +680,11 @@ public class AbilityFactory {
if(isDb)
SA = AbilityFactory_DelayedTrigger.getDrawback(this);
}
if(API.equals("Cleanup")) {
if(isDb)
SA = AbilityFactory_Cleanup.getDrawback(this);
}
if (SA == null)
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 origin = params.get("Origin");
CardList cards = AllZoneUtil.getCardsInZone(origin);
CardList cards = null;
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);
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));
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
int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0;
@@ -1490,6 +1501,9 @@ public class AbilityFactory_ChangeZone {
}
else
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

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);
}
}