mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Converted Take Possesion to Enchant Permanent
- Consolidated Change controllers code - moveTo Cleanup
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
Name:Take Possession
|
||||
ManaCost:5 U U
|
||||
Types:Sorcery
|
||||
Text:Gain control of target permanent. (NOTE: This spell is currently treated as a Sorcery rather than as an Enchantment.)
|
||||
Types:Enchantment Aura
|
||||
Text:You control enchanted permanent.
|
||||
K:Split second
|
||||
K:Enchant permanent
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://resources.wizards.com/magic/cards/fut/en-us/card136199.jpg
|
||||
SetInfo:FUT|Rare|http://magiccards.info/scans/en/fut/44.jpg
|
||||
|
||||
@@ -222,17 +222,7 @@ public class AbilityFactory_GainControl {
|
||||
tgtC.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
//tgtC.setSickness(true);
|
||||
tgtC.setController(hostCard.getController());
|
||||
|
||||
PlayerZone from = AllZone.getZone(tgtC);
|
||||
from.remove(tgtC);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, tgtC.getController());
|
||||
to.add(tgtC);
|
||||
AllZone.GameAction.changeController(new CardList(tgtC), tgtC.getController(), sa.getActivatingPlayer());
|
||||
|
||||
if(bUntap) tgtC.untap();
|
||||
|
||||
@@ -241,12 +231,8 @@ public class AbilityFactory_GainControl {
|
||||
tgtC.addExtrinsicKeyword(kw);
|
||||
}
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
}
|
||||
|
||||
|
||||
//end copied
|
||||
|
||||
if (lose != null){
|
||||
@@ -333,22 +319,10 @@ public class AbilityFactory_GainControl {
|
||||
if(null == c) return;
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(c)) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
AllZone.GameAction.changeController(new CardList(c), c.getController(), c.getController().getOpponent());
|
||||
|
||||
c.setSickness(true);
|
||||
c.setController(c.getController().getOpponent());
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
from.remove(c);
|
||||
|
||||
//make sure the creature is removed from combat:
|
||||
CardList list = new CardList(AllZone.Combat.getAttackers());
|
||||
if(list.contains(c)) AllZone.Combat.removeFromCombat(c);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, c.getOwner());
|
||||
to.add(c);
|
||||
|
||||
if(bTapOnLose) c.tap();
|
||||
|
||||
if(null != kws) {
|
||||
@@ -356,9 +330,6 @@ public class AbilityFactory_GainControl {
|
||||
c.removeExtrinsicKeyword(kw);
|
||||
}
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
}//if
|
||||
hostCard.clearGainControlTargets();
|
||||
hostCard.clearGainControlReleaseCommands();
|
||||
|
||||
@@ -5410,49 +5410,6 @@ public class CardFactory implements NewConstants {
|
||||
enchantment.setBeforePayMana(CardFactoryUtil.input_targetCreature(enchantment));
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Take Possession")) {
|
||||
final SpellAbility spell = new Spell(card) {
|
||||
private static final long serialVersionUID = -7359291736123492910L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return 0 < CardFactoryUtil.AI_getHumanCreature(card, true).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chooseTargetAI() {
|
||||
Card best = CardFactoryUtil.AI_getBestCreature(CardFactoryUtil.AI_getHumanCreature(card, true));
|
||||
setTargetCard(best);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getTargetCard();
|
||||
c.setController(card.getController());
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
|
||||
from.remove(c);
|
||||
to.add(c);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
|
||||
}//resolve()
|
||||
};
|
||||
|
||||
card.clearSpellAbility();
|
||||
spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "All"));
|
||||
card.addSpellAbility(spell);
|
||||
|
||||
card.setSVar("PlayMain1", "TRUE");
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("That Which Was Taken")) {
|
||||
|
||||
@@ -974,9 +974,6 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, player);
|
||||
|
||||
//card.setName("Morph");
|
||||
sourceCard.setIsFaceDown(true);
|
||||
sourceCard.setManaCost("");
|
||||
@@ -1969,14 +1966,12 @@ public class CardFactoryUtil {
|
||||
}//canPlayAI()
|
||||
|
||||
public void resolve() {
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, sourceCard.getController());
|
||||
play.add(sourceCard);
|
||||
|
||||
Card aura = AllZone.GameAction.moveToPlay(sourceCard);
|
||||
|
||||
Card c = getTargetCard();
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(sourceCard, c)) {
|
||||
sourceCard.enchantCard(c);
|
||||
//System.out.println("Enchanted: " +getTargetCard());
|
||||
aura.enchantCard(c);
|
||||
}
|
||||
}//resolve()
|
||||
};//enchant ability
|
||||
|
||||
@@ -1587,8 +1587,7 @@ class CardFactory_Auras {
|
||||
|
||||
// Bring creature onto the battlefield under your control (should trigger etb Abilities)
|
||||
animated.setController(card.getController());
|
||||
grave.remove(animated);
|
||||
play.add(animated);
|
||||
AllZone.GameAction.moveToPlay(animated);
|
||||
card.enchantCard(animated); // Attach before Targeting so detach Command will trigger
|
||||
|
||||
if(CardFactoryUtil.hasProtectionFrom(card, animated)) {
|
||||
@@ -1647,6 +1646,77 @@ class CardFactory_Auras {
|
||||
card.addUnEnchantCommand(detachCmd);
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Take Possession")) {
|
||||
final Player[] prevController = new Player[1];
|
||||
prevController[0] = null;
|
||||
|
||||
Ability_Cost cost = new Ability_Cost("5 U U", cardName, false);
|
||||
Target tgt = new Target("Select target Permanent", "Permanent".split(","));
|
||||
|
||||
final SpellAbility spell = new Spell(card, cost, tgt) {
|
||||
private static final long serialVersionUID = -7359291736123492910L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
Card best = CardFactoryUtil.AI_getBestCreature(CardFactoryUtil.AI_getHumanCreature(card, true));
|
||||
setTargetCard(best);
|
||||
return best != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getTargetCard();
|
||||
if(!AllZone.GameAction.isCardInPlay(c))
|
||||
return;
|
||||
|
||||
prevController[0] = c.getController();
|
||||
AllZone.GameAction.moveToPlay(card);
|
||||
c.attachCard(card);
|
||||
AllZone.GameAction.changeController(new CardList(c), c.getController(), card.getController());
|
||||
}//resolve()
|
||||
};
|
||||
|
||||
Command onUnEnchant = new Command() {
|
||||
private static final long serialVersionUID = 3426441132121179288L;
|
||||
|
||||
public void execute() {
|
||||
if(card.isEnchanting()) {
|
||||
Card crd = card.getEnchanting().get(0);
|
||||
if(AllZone.GameAction.isCardInPlay(crd)) {
|
||||
if(crd.getKeyword().contains("Haste")) {
|
||||
crd.setSickness(false);
|
||||
} else {
|
||||
crd.setSickness(true);
|
||||
}
|
||||
|
||||
AllZone.GameAction.changeController(new CardList(crd), crd.getController(), prevController[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}//execute()
|
||||
};//Command
|
||||
|
||||
Command onLeavesPlay = new Command() {
|
||||
private static final long serialVersionUID = -639204333673364477L;
|
||||
|
||||
public void execute() {
|
||||
if(card.isEnchanting()) {
|
||||
Card crd = card.getEnchanting().get(0);
|
||||
card.unEnchantCard(crd);
|
||||
}
|
||||
}
|
||||
};//Command
|
||||
|
||||
card.clearFirstSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
|
||||
card.addUnEnchantCommand(onUnEnchant);
|
||||
card.addLeavesPlayCommand(onLeavesPlay);
|
||||
|
||||
card.setSVar("PlayMain1", "TRUE");
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
//**************************************************************
|
||||
// This card can't be converted to keyword, problem with Fear *
|
||||
@@ -2283,6 +2353,9 @@ class CardFactory_Auras {
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
|
||||
final Player[] prevController = new Player[1];
|
||||
prevController[0] = null;
|
||||
|
||||
Command onEnchant = new Command() {
|
||||
private static final long serialVersionUID = -6323085271405286813L;
|
||||
|
||||
@@ -2296,19 +2369,8 @@ class CardFactory_Auras {
|
||||
crd.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(crd);
|
||||
from.remove(crd);
|
||||
|
||||
crd.setController(card.getController());
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to.add(crd);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
prevController[0] = crd.getController();
|
||||
AllZone.GameAction.changeController(new CardList(crd), crd.getController(), card.getController());
|
||||
}
|
||||
}//execute()
|
||||
};//Command
|
||||
@@ -2326,22 +2388,7 @@ class CardFactory_Auras {
|
||||
crd.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(crd);
|
||||
from.remove(crd);
|
||||
|
||||
AllZone.Combat.removeFromCombat(crd);
|
||||
|
||||
Player opp = crd.getController().getOpponent();
|
||||
crd.setController(opp);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, opp);
|
||||
to.add(crd);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(crd), crd.getController(), prevController[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2447,6 +2494,9 @@ class CardFactory_Auras {
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
|
||||
final Player[] prevController = new Player[1];
|
||||
prevController[0] = null;
|
||||
|
||||
Command onEnchant = new Command() {
|
||||
private static final long serialVersionUID = -2519887209491512000L;
|
||||
|
||||
@@ -2459,20 +2509,9 @@ class CardFactory_Auras {
|
||||
} else {
|
||||
crd.setSickness(true);
|
||||
}
|
||||
prevController[0] = crd.getController();
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(crd);
|
||||
from.remove(crd);
|
||||
|
||||
crd.setController(card.getController());
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to.add(crd);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(crd), prevController[0], card.getController());
|
||||
}
|
||||
}//execute()
|
||||
};//Command
|
||||
@@ -2490,22 +2529,7 @@ class CardFactory_Auras {
|
||||
crd.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(crd);
|
||||
from.remove(crd);
|
||||
|
||||
AllZone.Combat.removeFromCombat(crd);
|
||||
|
||||
Player opp = crd.getController().getOpponent();
|
||||
crd.setController(opp);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, opp);
|
||||
to.add(crd);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(crd), crd.getController(), prevController[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1574,25 +1574,13 @@ public class CardFactory_Creatures {
|
||||
@Override
|
||||
public void resolve() {
|
||||
PlayerZone libraryZone = AllZone.getZone(Constant.Zone.Library, card.getController());
|
||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
|
||||
|
||||
|
||||
//get top 4 cards of the library
|
||||
CardList top = new CardList();
|
||||
Card[] library = libraryZone.getCards();
|
||||
for(int i = 0; i < 4 && i < library.length; i++)
|
||||
top.add(library[i]);
|
||||
|
||||
//put top 4 cards on bottom of library
|
||||
for(int i = 0; i < top.size(); i++) {
|
||||
libraryZone.remove(top.get(i));
|
||||
libraryZone.add(top.get(i));
|
||||
}
|
||||
|
||||
CardList typeLimitedTop = top.getType(typeToGet[0]);
|
||||
|
||||
for(int i = 0; i < typeLimitedTop.size(); i++)
|
||||
AllZone.GameAction.moveTo(hand, typeLimitedTop.get(i));
|
||||
|
||||
if (card.getController().equals(AllZone.ComputerPlayer))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -1604,6 +1592,18 @@ public class CardFactory_Creatures {
|
||||
sb.append("</b></html>");
|
||||
JOptionPane.showMessageDialog(null, sb.toString(), "Computer reveals:", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
CardList typeLimitedTop = top.getType(typeToGet[0]);
|
||||
|
||||
for(Card c : typeLimitedTop){
|
||||
AllZone.GameAction.moveToHand(c);
|
||||
top.remove(c);
|
||||
}
|
||||
|
||||
for(Card c : top){
|
||||
AllZone.GameAction.moveToBottomOfLibrary(c);
|
||||
}
|
||||
|
||||
}//resolve()
|
||||
};//SpellAbility
|
||||
|
||||
@@ -1678,21 +1678,8 @@ public class CardFactory_Creatures {
|
||||
final SpellAbility ability = new Ability(card, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(card);
|
||||
from.remove(card);
|
||||
|
||||
card.setController(card.getOwner().getOpponent());
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield,
|
||||
card.getOwner().getOpponent());
|
||||
to.add(card);
|
||||
Log.debug("Sleeper Agent", "cards controller = " + card.getController());
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
// Todo: this need to be targeted
|
||||
AllZone.GameAction.changeController(new CardList(card), card.getController(), card.getController().getOpponent());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2803,33 +2790,11 @@ public class CardFactory_Creatures {
|
||||
@Override
|
||||
public void resolve() {
|
||||
Player opp = card.getController().getOpponent();
|
||||
PlayerZone oppPlay = AllZone.getZone(Constant.Zone.Battlefield, opp);
|
||||
PlayerZone myPlay = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
|
||||
CardList list = new CardList(myPlay.getCards());
|
||||
//list.remove(card);//doesn't move Sky Swallower
|
||||
|
||||
list = list.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return !c.equals(card) && !c.getName().equals("Mana Pool");
|
||||
}
|
||||
});
|
||||
|
||||
while(!list.isEmpty()) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
//so "enters the battlefield" abilities don't trigger
|
||||
///list.get(0).addComesIntoPlayCommand(Command.Blank);
|
||||
|
||||
oppPlay.add(list.get(0));
|
||||
myPlay.remove(list.get(0));
|
||||
|
||||
list.get(0).setController(opp);
|
||||
list.remove(0);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
}
|
||||
CardList list = AllZoneUtil.getCardsInPlay();
|
||||
list = list.getValidCards("Card.Other+YouCtrl".split(","),card.getController(), card);
|
||||
|
||||
AllZone.GameAction.changeController(list, card.getController(), opp);
|
||||
}//resolve()
|
||||
};//SpellAbility
|
||||
|
||||
@@ -3389,24 +3354,10 @@ public class CardFactory_Creatures {
|
||||
final SpellAbility ability = new Ability(card, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
if(AllZone.GameAction.isCardInPlay(getTargetCard())
|
||||
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
PlayerZone oldPlay = AllZone.getZone(getTargetCard());
|
||||
|
||||
//so "enters the battlefield" abilities don't trigger
|
||||
//getTargetCard().addComesIntoPlayCommand(Command.Blank);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
play.add(getTargetCard());
|
||||
oldPlay.remove(getTargetCard());
|
||||
|
||||
getTargetCard().setController(card.getController());
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
Card tgt = getTargetCard();
|
||||
if(AllZone.GameAction.isCardInPlay(tgt)
|
||||
&& CardFactoryUtil.canTarget(card, tgt)) {
|
||||
AllZone.GameAction.changeController(new CardList(tgt), tgt.getController(), card.getController());
|
||||
}
|
||||
}//resolve()
|
||||
};
|
||||
@@ -3958,31 +3909,14 @@ public class CardFactory_Creatures {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
|
||||
Card crd0 = target[0];
|
||||
Card crd1 = target[1];
|
||||
|
||||
if(crd0 != null && crd1 != null) {
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from0 = AllZone.getZone(crd0);
|
||||
from0.remove(crd0);
|
||||
PlayerZone from1 = AllZone.getZone(crd1);
|
||||
from1.remove(crd1);
|
||||
|
||||
crd0.setController(card.getController().getOpponent());
|
||||
crd1.setController(card.getController());
|
||||
|
||||
PlayerZone to0 = AllZone.getZone(Constant.Zone.Battlefield,
|
||||
card.getController().getOpponent());
|
||||
to0.add(crd0);
|
||||
PlayerZone to1 = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to1.add(crd1);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
Player p0 = crd0.getController();
|
||||
Player p1 = crd1.getController();
|
||||
AllZone.GameAction.changeController(new CardList(crd0), p0, p1);
|
||||
AllZone.GameAction.changeController(new CardList(crd1), p1, p0);
|
||||
}
|
||||
|
||||
}//resolve()
|
||||
@@ -4229,7 +4163,7 @@ public class CardFactory_Creatures {
|
||||
@Override
|
||||
public void resolve() {
|
||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, card.getController());
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
|
||||
CardList Library = new CardList(lib.getCards());
|
||||
int Count = 5;
|
||||
if(Library.size() < 5) Count = Library.size();
|
||||
@@ -5019,7 +4953,9 @@ public class CardFactory_Creatures {
|
||||
}
|
||||
};//CommandReturn
|
||||
|
||||
|
||||
final Player[] prevController = new Player[1];
|
||||
prevController[0] = null;
|
||||
|
||||
final SpellAbility comesAbility = new Ability(card, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
@@ -5027,6 +4963,7 @@ public class CardFactory_Creatures {
|
||||
|
||||
Card c = getTargetCard();
|
||||
movedCreature[0] = c;
|
||||
prevController[0] = c.getController();
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(card) && AllZone.GameAction.isCardInPlay(c) &&
|
||||
CardFactoryUtil.canTarget(card, c)) {
|
||||
@@ -5037,20 +4974,7 @@ public class CardFactory_Creatures {
|
||||
c.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
c.setSickness(true);
|
||||
c.setController(card.getController());
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
from.remove(c);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to.add(c);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(c), c.getController(), card.getController());
|
||||
}
|
||||
}//resolve()
|
||||
};//SpellAbility
|
||||
@@ -5108,24 +5032,7 @@ public class CardFactory_Creatures {
|
||||
Card c = movedCreature[0];
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(c)) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
c.setSickness(true);
|
||||
c.setController(c.getController().getOpponent());
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
from.remove(c);
|
||||
|
||||
//make sure the creature is removed from combat:
|
||||
CardList list = new CardList(AllZone.Combat.getAttackers());
|
||||
if(list.contains(c)) AllZone.Combat.removeFromCombat(c);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, c.getOwner());
|
||||
to.add(c);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(c), c.getController(), prevController[0]);
|
||||
}//if
|
||||
}//execute()
|
||||
});//Command
|
||||
@@ -7782,17 +7689,7 @@ public class CardFactory_Creatures {
|
||||
land.setSickness(true);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(land);
|
||||
from.remove(land);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to.add(land);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(land), land.getController(), card.getController());
|
||||
}//if
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,11 +757,9 @@ class CardFactory_Planeswalkers {
|
||||
Object o = GuiUtils.getChoiceOptional("Select any card", list.toArray());
|
||||
|
||||
card.getController().shuffle();
|
||||
if(o != null) {
|
||||
//put creature on top of library
|
||||
library.remove(o);
|
||||
library.add((Card) o, 0);
|
||||
}
|
||||
if(o != null) //put creature on top of library
|
||||
AllZone.GameAction.moveToLibrary((Card) o);
|
||||
|
||||
}//if
|
||||
}//resolve()
|
||||
|
||||
@@ -1938,15 +1936,13 @@ class CardFactory_Planeswalkers {
|
||||
if(o != null) {
|
||||
Card c1 = (Card) o;
|
||||
putOnTop.remove(c1);
|
||||
hand.remove(c1);
|
||||
lib.add(c1, 0);
|
||||
AllZone.GameAction.moveToLibrary(c1);
|
||||
}
|
||||
o = GuiUtils.getChoiceOptional("Second card to put on top: ", putOnTop.toArray());
|
||||
if(o != null) {
|
||||
Card c2 = (Card) o;
|
||||
putOnTop.remove(c2);
|
||||
hand.remove(c2);
|
||||
lib.add(c2, 0);
|
||||
AllZone.GameAction.moveToLibrary(c2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -265,25 +265,10 @@ public class CardFactory_Sorceries {
|
||||
Card crd1 = target[1];
|
||||
|
||||
if(crd0 != null && crd1 != null) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from0 = AllZone.getZone(crd0);
|
||||
from0.remove(crd0);
|
||||
PlayerZone from1 = AllZone.getZone(crd1);
|
||||
from1.remove(crd1);
|
||||
|
||||
crd0.setController(card.getController().getOpponent());
|
||||
crd1.setController(card.getController());
|
||||
|
||||
PlayerZone to0 = AllZone.getZone(Constant.Zone.Battlefield,
|
||||
card.getController().getOpponent());
|
||||
to0.add(crd0);
|
||||
PlayerZone to1 = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
to1.add(crd1);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
Player p0 = crd0.getController();
|
||||
Player p1 = crd1.getController();
|
||||
AllZone.GameAction.changeController(new CardList(crd0), p0, p1);
|
||||
AllZone.GameAction.changeController(new CardList(crd1), p1, p0);
|
||||
}
|
||||
|
||||
}//resolve()
|
||||
@@ -503,20 +488,12 @@ public class CardFactory_Sorceries {
|
||||
int i = 0;
|
||||
for(Card target:targets) {
|
||||
//if card isn't in play, do nothing
|
||||
if(!AllZone.GameAction.isCardInPlay(target)) break;
|
||||
if(!AllZone.GameAction.isCardInPlay(target)) continue;
|
||||
|
||||
target.setController(controllerEOT.get(i));
|
||||
AllZone.GameAction.changeController(new CardList(target), card.getController(), controllerEOT.get(i));
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
newZone[0].remove(target);
|
||||
orig.get(i).add(target);
|
||||
target.untap();
|
||||
target.removeExtrinsicKeyword("Haste");
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
i++;
|
||||
}
|
||||
}//execute()
|
||||
@@ -536,17 +513,7 @@ public class CardFactory_Sorceries {
|
||||
controllerEOT.add(i, target.getController());
|
||||
targets.add(i, target);
|
||||
|
||||
//set the controller
|
||||
target.setController(card.getController());
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
newZone[0].add(target);
|
||||
orig.get(i).remove(target);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(target), target.getController(), card.getController());
|
||||
|
||||
target.untap();
|
||||
target.addExtrinsicKeyword("Haste");
|
||||
@@ -3892,21 +3859,10 @@ public class CardFactory_Sorceries {
|
||||
Card c = getTargetCard();
|
||||
|
||||
if(c != null && AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) {
|
||||
// Donate should target both the player and the creature
|
||||
if(!c.isAura()) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
from.remove(c);
|
||||
|
||||
c.setController(card.getController().getOpponent());
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield,
|
||||
card.getController().getOpponent());
|
||||
to.add(c);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(c), c.getController(), c.getController().getOpponent());
|
||||
|
||||
} else //Aura
|
||||
{
|
||||
c.setController(card.getController().getOpponent());
|
||||
@@ -6105,51 +6061,6 @@ public class CardFactory_Sorceries {
|
||||
spell.setBeforePayMana(runtime);
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Take Possession")) {
|
||||
final SpellAbility spell = new Spell(card) {
|
||||
private static final long serialVersionUID = -7359291736123492910L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return 0 < CardFactoryUtil.AI_getHumanCreature(card, true).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chooseTargetAI() {
|
||||
Card best = CardFactoryUtil.AI_getBestCreature(CardFactoryUtil.AI_getHumanCreature(card, true));
|
||||
setTargetCard(best);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getTargetCard();
|
||||
c.setController(card.getController());
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
PlayerZone from = AllZone.getZone(c);
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||
|
||||
from.remove(c);
|
||||
to.add(c);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
|
||||
}//resolve()
|
||||
};
|
||||
|
||||
card.clearSpellAbility();
|
||||
spell.setBeforePayMana(CardFactoryUtil.input_targetType(spell, "All"));
|
||||
card.addSpellAbility(spell);
|
||||
|
||||
card.setSVar("PlayMain1", "TRUE");
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Leeches")) {
|
||||
/*
|
||||
|
||||
@@ -163,4 +163,12 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
|
||||
}
|
||||
public void setUpdate(boolean b) {update = b;}
|
||||
public boolean getUpdate() {return update;}
|
||||
|
||||
public String toString(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (player != null)
|
||||
sb.append(player.toString()).append(" ");
|
||||
sb.append(zoneName);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,19 +126,8 @@ public class EndOfTurn implements java.io.Serializable
|
||||
@Override
|
||||
public void resolve() {
|
||||
if(AllZone.GameAction.isCardInPlay(vale)) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
|
||||
vale.setController(vale.getController().getOpponent());
|
||||
|
||||
PlayerZone from = AllZone.getZone(vale);
|
||||
from.remove(vale);
|
||||
|
||||
PlayerZone to = AllZone.getZone(Constant.Zone.Battlefield, vale.getController());
|
||||
to.add(vale);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
AllZone.GameAction.changeController(new CardList(vale), vale.getController(), vale.getController().getOpponent());
|
||||
|
||||
vale.removeExtrinsicKeyword("An opponent gains control of CARDNAME at the beginning of the next end step.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,30 @@ public class GameAction {
|
||||
return moving;
|
||||
}
|
||||
|
||||
public void changeController(CardList list, Player oldController, Player newController){
|
||||
if (oldController.equals(newController))
|
||||
return;
|
||||
|
||||
// Consolidating this code for now. In the future I want moveTo to handle this garbage
|
||||
PlayerZone oldBattlefield = AllZone.getZone(Constant.Zone.Battlefield, oldController);
|
||||
PlayerZone newBattlefield = AllZone.getZone(Constant.Zone.Battlefield, newController);
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(false);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(false);
|
||||
//so "enters the battlefield" abilities don't trigger
|
||||
|
||||
for(Card c : list){
|
||||
oldBattlefield.remove(c);
|
||||
c.setController(newController);
|
||||
newBattlefield.add(c);
|
||||
if (c.isCreature())
|
||||
AllZone.Combat.removeFromCombat(c);
|
||||
}
|
||||
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Battlefield).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Battlefield).setTriggers(true);
|
||||
}
|
||||
|
||||
public Card moveToStack(Card c){
|
||||
PlayerZone stack = AllZone.getZone(Constant.Zone.Stack, null);
|
||||
return moveTo(stack, c);
|
||||
@@ -2133,15 +2157,11 @@ public class GameAction {
|
||||
* @param c the card to be exiled
|
||||
*/
|
||||
public void exile(Card c) {
|
||||
//removeFromGame(c);
|
||||
if(AllZone.GameAction.isCardExiled(c)) return;
|
||||
|
||||
PlayerZone zone = AllZone.getZone(c); //could be hand, grave, play, ...
|
||||
PlayerZone removed = AllZone.getZone(Constant.Zone.Exile, c.getOwner());
|
||||
|
||||
if (zone != null) // for suspend
|
||||
zone.remove(c);
|
||||
if(!c.isToken()) removed.add(c);
|
||||
AllZone.GameAction.moveTo(removed, c);
|
||||
}
|
||||
|
||||
//is this card a permanent that is in play?
|
||||
|
||||
@@ -546,7 +546,7 @@ public class GameActionUtil {
|
||||
playCard_Merrow_Levitator(c);
|
||||
playCard_Primordial_Sage(c);
|
||||
playCard_Quirion_Dryad(c);
|
||||
playCard_Enchantress_Draw(c);
|
||||
//playCard_Enchantress_Draw(c);
|
||||
playCard_Mold_Adder(c);
|
||||
playCard_Fable_of_Wolf_and_Owl(c);
|
||||
playCard_Kor_Firewalker(c);
|
||||
|
||||
@@ -31,4 +31,6 @@ interface IPlayerZone
|
||||
|
||||
public Player getPlayer();//the Player that owns this zone
|
||||
public String getZoneName();//returns the Zone's name like Graveyard
|
||||
|
||||
public String toString();
|
||||
}
|
||||
Reference in New Issue
Block a user