add Dance of Many (from The Dark); required a hack in MagicStack.java because af.getHostCard() in AF wasn't the same object that was on the battlefield. Why? I don't know. But this works.

This commit is contained in:
jendave
2011-08-07 01:35:15 +00:00
parent dc9fb24c69
commit 4ae8d96ebe
6 changed files with 72 additions and 8 deletions

View File

@@ -157,6 +157,7 @@ public class Card extends MyObservable {
private String topCardName = "";
private String reflectableMana = "";
private Card cloneOrigin = null;
private ArrayList<Card> clones = new ArrayList<Card>();
private Card currentlyCloningCard = null;
private Command cloneLeavesPlayCommand = null;
private ArrayList<Card> gainControlTargets = new ArrayList<Card>();
@@ -426,6 +427,27 @@ public class Card extends MyObservable {
return sirenAttackOrDestroy;
}
public ArrayList<Card> getClones() {
return clones;
}
public void setClones(ArrayList<Card> c) {
clones.clear();
clones.addAll(c);
}
public void addClone(Card c) {
clones.add(c);
}
public void addClones(ArrayList<Card> c) {
clones.addAll(c);
}
public void clearClones() {
clones.clear();
}
public Card getCloneOrigin() {
return cloneOrigin;
}
@@ -2808,6 +2830,10 @@ public class Card extends MyObservable {
if (!equippedBy.contains(source) && !enchantedBy.contains(source)) return false; }
else if (Property.startsWith("Attached")) {
if (!equipping.contains(source) && !enchanting.contains(source)) return false; }
else if(Property.startsWith("Cloned")) {
if(cloneOrigin == null || !cloneOrigin.equals(source)) return false;
}
else if (Property.startsWith("DamagedBy")) {
if(!receivedDamageFromThisTurn.containsKey(source)) return false; }

View File

@@ -748,6 +748,19 @@ public class MagicStack extends MyObservable {
CombatUtil.showCombat();
GuiDisplayUtil.updateGUI();
//TODO - this is a huge hack. Why is this necessary?
//hostCard in AF is not the same object that's on the battlefield
//verified by System.identityHashCode(card);
Card tmp = sa.getSourceCard();
if(tmp.getClones().size() > 0) {
for(Card c : AllZoneUtil.getCardsInPlay()) {
if(c.equals(tmp)) {
c.setClones(tmp.getClones());
}
}
}
}
public boolean hasFizzled(SpellAbility sa, Card source){

View File

@@ -1026,6 +1026,12 @@ public class AbilityFactory {
}
}
else if (defined.equals("Clones")){
for(Card clone : hostCard.getClones()){
cards.add(AllZoneUtil.getCardState(clone));
}
}
else if (defined.equals("Imprinted")){
for(Card imprint : hostCard.getImprinted()){
cards.add(AllZoneUtil.getCardState(imprint));

View File

@@ -227,12 +227,12 @@ public class AbilityFactory_Copy {
private static void copyPermanentResolve(final AbilityFactory af, final SpellAbility sa) {
final HashMap<String,String> params = af.getMapParams();
Card card = af.getHostCard();
Card hostCard = af.getHostCard();
ArrayList<String> keywords = new ArrayList<String>();
if(params.containsKey("Keywords")) {
keywords.addAll(Arrays.asList(params.get("Keywords").split(" & ")));
}
int numCopies = params.containsKey("NumCopies") ? AbilityFactory.calculateAmount(card, params.get("NumCopies"), sa) : 1;
int numCopies = params.containsKey("NumCopies") ? AbilityFactory.calculateAmount(hostCard, params.get("NumCopies"), sa) : 1;
ArrayList<Card> tgtCards;
@@ -240,13 +240,15 @@ public class AbilityFactory_Copy {
if (tgt != null)
tgtCards = tgt.getTargetCards();
else
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
hostCard.clearClones();
for(Card c : tgtCards) {
if (tgt == null || CardFactoryUtil.canTarget(card, c)) {
if (tgt == null || CardFactoryUtil.canTarget(hostCard, c)) {
//start copied Kiki code
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(hostCard.getController());
multiplier *= numCopies;
Card[] crds = new Card[multiplier];
@@ -310,12 +312,13 @@ public class AbilityFactory_Copy {
copy.setCurSetCode("");
copy.setImageFilename("morph.jpg");
}
AllZone.GameAction.moveToPlay(copy);
copy = AllZone.GameAction.moveToPlay(copy);
copy.setCloneOrigin(hostCard);
sa.getSourceCard().addClone(copy);
crds[i] = copy;
}
//have to do this since getTargetCard() might change
//if Kiki-Jiki somehow gets untapped again
final Card[] target = new Card[multiplier];