- Added activatingPlayer to SpellAbility.

- Rakka Mar and Captain of the Watch now use the activatingPlayer which is locked in when the ability hits the stack.
This commit is contained in:
jendave
2011-08-06 05:23:43 +00:00
parent 8a31fa95a4
commit b7f3f258c0
6 changed files with 30 additions and 14 deletions

View File

@@ -3797,14 +3797,7 @@ public class CardFactoryUtil {
} }
return s; return s;
} }
public static boolean hasNecropotence(String player) {
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
CardList list = new CardList(play.getCards());
list = list.getName("Necropotence");
return list.size() > 0;
}
public static CardList getCards(String cardName) public static CardList getCards(String cardName)
{ {
CardList list = new CardList(); CardList list = new CardList();
@@ -3905,7 +3898,8 @@ public class CardFactoryUtil {
} }
public static CardList makeToken(String name, String imageName, Card source, String manaCost, String[] types, int baseAttack, int baseDefense, String[] intrinsicKeywords) { public static CardList makeToken(String name, String imageName, Card source, String manaCost, String[] types, int baseAttack, int baseDefense, String[] intrinsicKeywords) {
CardList list = new CardList(); // todo(sol) this function shouldn't be called, better to call makeToken with String controller as third paramter
CardList list = new CardList();
Card c = new Card(); Card c = new Card();
c.setName(name); c.setName(name);
c.setImageName(imageName); c.setImageName(imageName);
@@ -3935,12 +3929,11 @@ public class CardFactoryUtil {
Card temp = CardFactory.copyStats(c); Card temp = CardFactory.copyStats(c);
temp.setToken(true); temp.setToken(true);
temp.setController(source.getController()); temp.setController(source.getController());
temp.setOwner(source.getOwner()); temp.setOwner(source.getController());
play.add(temp); play.add(temp);
list.add(temp); list.add(temp);
} }
return list; return list;
} }
public static CardList makeToken(String name, String imageName, String controller, String manaCost, String[] types, int baseAttack, int baseDefense, String[] intrinsicKeywords) { public static CardList makeToken(String name, String imageName, String controller, String manaCost, String[] types, int baseAttack, int baseDefense, String[] intrinsicKeywords) {

View File

@@ -189,7 +189,7 @@ public class CardFactory_Creatures {
}//resolve() }//resolve()
public void makeToken() { public void makeToken() {
CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card, "W", new String[] { CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", getActivatingPlayer(), "W", new String[] {
"Creature", "Soldier"}, 1, 1, new String[] {""}); "Creature", "Soldier"}, 1, 1, new String[] {""});
} }
@@ -14076,7 +14076,7 @@ public class CardFactory_Creatures {
} }
void makeToken() { void makeToken() {
CardFactoryUtil.makeToken("Elemental", "R 3 1 Elemental", card, "R", new String[] { CardFactoryUtil.makeToken("Elemental", "R 3 1 Elemental", getActivatingPlayer(), "R", new String[] {
"Creature", "Elemental"}, 3, 1, new String[] {"Haste"}); "Creature", "Elemental"}, 3, 1, new String[] {"Haste"});
}//makeToken() }//makeToken()
};//SpellAbility };//SpellAbility

View File

@@ -36,6 +36,7 @@ public class ComputerUtil
payManaCost(all[i]); payManaCost(all[i]);
all[i].chooseTargetAI(); all[i].chooseTargetAI();
all[i].getBeforePayManaAI().execute(); all[i].getBeforePayManaAI().execute();
all[i].setActivatingPlayer(Constant.Player.Computer);
AllZone.Stack.add(all[i]); AllZone.Stack.add(all[i]);
return false; return false;
@@ -52,6 +53,7 @@ public class ComputerUtil
if (AllZone.GameAction.isCardInZone(sa.getSourceCard(),AllZone.Computer_Hand)) if (AllZone.GameAction.isCardInZone(sa.getSourceCard(),AllZone.Computer_Hand))
AllZone.Computer_Hand.remove(sa.getSourceCard()); AllZone.Computer_Hand.remove(sa.getSourceCard());
sa.setActivatingPlayer(Constant.Player.Computer);
if (sa.getSourceCard().getKeyword().contains("Draw a card.")) if (sa.getSourceCard().getKeyword().contains("Draw a card."))
AllZone.GameAction.drawCard(sa.getSourceCard().getController()); AllZone.GameAction.drawCard(sa.getSourceCard().getController());
@@ -63,6 +65,8 @@ public class ComputerUtil
final static public void playStackFree(SpellAbility sa) final static public void playStackFree(SpellAbility sa)
{ {
sa.setActivatingPlayer(Constant.Player.Computer);
if (AllZone.GameAction.isCardInZone(sa.getSourceCard(),AllZone.Computer_Hand)) if (AllZone.GameAction.isCardInZone(sa.getSourceCard(),AllZone.Computer_Hand))
AllZone.Computer_Hand.remove(sa.getSourceCard()); AllZone.Computer_Hand.remove(sa.getSourceCard());
@@ -85,6 +89,8 @@ public class ComputerUtil
//sa.getSourceCard().comesIntoPlay(); - messes things up, maybe for the future fix this //sa.getSourceCard().comesIntoPlay(); - messes things up, maybe for the future fix this
} }
sa.setActivatingPlayer(Constant.Player.Computer);
if(sa instanceof Ability_Tap) if(sa instanceof Ability_Tap)
sa.getSourceCard().tap(); sa.getSourceCard().tap();

View File

@@ -3238,7 +3238,7 @@ public class GameAction {
public void playSpellAbility(SpellAbility sa) { public void playSpellAbility(SpellAbility sa) {
ManaCost manaCost = new ManaCost(sa.getManaCost()); ManaCost manaCost = new ManaCost(sa.getManaCost());
sa.setActivatingPlayer(Constant.Player.Human);
if(sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if(sa.getSourceCard().isCopiedSpell() && sa.isSpell()) {
manaCost = new ManaCost("0"); manaCost = new ManaCost("0");
} else { } else {

View File

@@ -80,6 +80,12 @@ public class MagicStack extends MyObservable
public void add(SpellAbility sp) public void add(SpellAbility sp)
{ {
// if activating player slips through the cracks, assign activating Player to the controller here
if (sp.getActivatingPlayer().equals("")){
sp.setActivatingPlayer(sp.getSourceCard().getController());
//System.out.println(sp.getSourceCard().getName() + " - activatingPlayer not set before adding to stack.");
}
if(sp instanceof Ability_Mana || sp instanceof Ability_Triggered)//TODO make working triggered abilities! if(sp instanceof Ability_Mana || sp instanceof Ability_Triggered)//TODO make working triggered abilities!
sp.resolve(); sp.resolve();
else { else {

View File

@@ -18,6 +18,7 @@ public abstract class SpellAbility {
private String additionalManaCost = ""; private String additionalManaCost = "";
private String multiKickerManaCost= ""; private String multiKickerManaCost= "";
private String xManaCost = ""; private String xManaCost = "";
private String activatingPlayer = "";
private String type = "Intrinsic"; //set to Intrinsic by default private String type = "Intrinsic"; //set to Intrinsic by default
@@ -129,6 +130,16 @@ public abstract class SpellAbility {
xManaCost = cost; xManaCost = cost;
} }
public String getActivatingPlayer()
{
return activatingPlayer;
}
public void setActivatingPlayer(String player)
{
activatingPlayer = player;
}
public boolean isSpell() { public boolean isSpell() {
return spell; return spell;
} }