fix instances of setLife and subtractLife that should have been using addDamage (GameActionUtil.java)

This commit is contained in:
jendave
2011-08-06 09:00:26 +00:00
parent 9c853300ba
commit 4f7f8718f4

View File

@@ -2857,7 +2857,7 @@ public class GameActionUtil {
@Override @Override
public void resolve() { public void resolve() {
AllZone.GameAction.getPlayerLife(player_d).subtractLife(1,F_card); AllZone.GameAction.addDamage(player_d, F_card, 1);
} }
}; };
ability.setStackDescription(list.get(i) + " - Deals 1 damage to him or her"); ability.setStackDescription(list.get(i) + " - Deals 1 damage to him or her");
@@ -3270,8 +3270,7 @@ public class GameActionUtil {
public void execute() { public void execute() {
if(c.getName().equals("Cosmic Horror")) { if(c.getName().equals("Cosmic Horror")) {
String player = c.getController(); String player = c.getController();
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, c, 7);
life.subtractLife(7,c);
} }
AllZone.GameAction.destroy(c); AllZone.GameAction.destroy(c);
} }
@@ -3343,8 +3342,7 @@ public class GameActionUtil {
public void execute() { public void execute() {
//AllZone.GameAction.sacrifice(c); //AllZone.GameAction.sacrifice(c);
String player = c.getController(); String player = c.getController();
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, c, c.getUpkeepDamage());
life.subtractLife(c.getUpkeepDamage(),c);
} }
}; };
@@ -4356,8 +4354,7 @@ public class GameActionUtil {
@Override @Override
public void resolve() { public void resolve() {
String player = crd.getController(); String player = crd.getController();
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, crd, 2);
life.subtractLife(2,crd);
} }
}; };
ability.setStackDescription("Dingus Egg - Deals 2 damage to " + destroyed.getController() + "."); ability.setStackDescription("Dingus Egg - Deals 2 damage to " + destroyed.getController() + ".");
@@ -4544,7 +4541,7 @@ public class GameActionUtil {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) if(AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(valakutCard, getTargetCard())) getTargetCard().addDamage(3, && CardFactoryUtil.canTarget(valakutCard, getTargetCard())) getTargetCard().addDamage(3,
valakutCard); valakutCard);
} else AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(3,valakutCard); } else AllZone.GameAction.addDamage(getTargetPlayer(), valakutCard, 3);
}//resolve() }//resolve()
}; };
@@ -4904,7 +4901,7 @@ public class GameActionUtil {
if(target != null) if(target != null)
target.addDamage(2, src); target.addDamage(2, src);
else else
AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(2,src); AllZone.GameAction.addDamage(getTargetPlayer(), src, 2);
AllZone.GameAction.drawCard(src.getController()); AllZone.GameAction.drawCard(src.getController());
} }
@@ -7668,28 +7665,21 @@ public class GameActionUtil {
private static void upkeep_Ancient_Runes() { private static void upkeep_Ancient_Runes() {
final String player = AllZone.Phase.getActivePlayer(); final String player = AllZone.Phase.getActivePlayer();
CardList ancient_runes = new CardList(); CardList ancient_runes = AllZoneUtil.getCardsInPlay("Ancient Runes");
ancient_runes.addAll(AllZone.Human_Play.getCards());
ancient_runes.addAll(AllZone.Computer_Play.getCards());
ancient_runes = ancient_runes.getName("Ancient Runes");
PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player);
CardList artifacts = new CardList(activePlayZone.getCards());
artifacts = artifacts.getType("Artifact");
// determine how much damage to deal the current player // determine how much damage to deal the current player
final int damage = artifacts.size(); final int damage = AllZoneUtil.getPlayerTypeInPlay(player, "Artifact").size();
// if there are 1 or more Ancient Runes on the // if there are 1 or more Ancient Runes on the
// battlefield have each of them deal damage. // battlefield have each of them deal damage.
if(0 < ancient_runes.size()) { if(0 < ancient_runes.size()) {
for(int i = 0; i < ancient_runes.size(); i++) { for(Card rune:ancient_runes) {
Ability ability = new Ability(ancient_runes.get(0), "0") { final Card src = rune;
Ability ability = new Ability(src, "0") {
@Override @Override
public void resolve() { public void resolve() {
if(damage>0){ if(damage>0){
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, src, damage);
life.setLife(life.getLife() - damage);
} }
} }
};// Ability };// Ability
@@ -7704,10 +7694,7 @@ public class GameActionUtil {
private static void upkeep_Karma() { private static void upkeep_Karma() {
final String player = AllZone.Phase.getActivePlayer(); final String player = AllZone.Phase.getActivePlayer();
CardList karma = new CardList(); CardList karmas = AllZoneUtil.getCardsInPlay("Karma");
karma.addAll(AllZone.Human_Play.getCards());
karma.addAll(AllZone.Computer_Play.getCards());
karma = karma.getName("Karma");
PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player); PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player);
CardList swamps = new CardList(activePlayZone.getCards()); CardList swamps = new CardList(activePlayZone.getCards());
@@ -7718,14 +7705,14 @@ public class GameActionUtil {
// if there are 1 or more Karmas on the // if there are 1 or more Karmas on the
// battlefield have each of them deal damage. // battlefield have each of them deal damage.
if(0 < karma.size()) { if(0 < karmas.size()) {
for(int i = 0; i < karma.size(); i++) { for(Card karma:karmas) {
Ability ability = new Ability(karma.get(0), "0") { final Card src = karma;
Ability ability = new Ability(src, "0") {
@Override @Override
public void resolve() { public void resolve() {
if(damage>0){ if(damage>0){
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, src, 1);
life.setLife(life.getLife() - damage);
} }
} }
};// Ability };// Ability
@@ -7737,45 +7724,6 @@ public class GameActionUtil {
}// if }// if
}// upkeep_Karma() }// upkeep_Karma()
/*
private static void upkeep_Karma() {
final String player = AllZone.Phase.getActivePlayer();
String opponent = AllZone.GameAction.getOpponent(player);
PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent);
CardList karma = new CardList(opponentPlayZone.getCards());
karma = karma.getName("Karma");
PlayerZone activePlayZone = AllZone.getZone(Constant.Zone.Play, player);
CardList swamps = new CardList(activePlayZone.getCards());
swamps = swamps.getType("Swamp");
// determine how much damage to deal the current player
final int damage = swamps.size();
// if there are 1 or more Karmas owned by the opponent of the
// current player have each of them deal damage.
if(0 < karma.size()) {
for(int i = 0; i < karma.size(); i++) {
Ability ability = new Ability(karma.get(0), "0") {
@Override
public void resolve() {
if(damage>0){
PlayerLife life = AllZone.GameAction.getPlayerLife(player);
life.setLife(life.getLife() - damage);
}
}
};// Ability
if(damage>0){
ability.setStackDescription("Karma deals " + damage + " damage to " + player);
AllZone.Stack.add(ability);
}
}
}// if
}// upkeep_Karma()
*/
private static void upkeep_Convalescence() { private static void upkeep_Convalescence() {
final String player = AllZone.Phase.getActivePlayer(); final String player = AllZone.Phase.getActivePlayer();
PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player); PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);
@@ -7873,21 +7821,21 @@ public class GameActionUtil {
PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent); PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent);
CardList theRack = new CardList(opponentPlayZone.getCards()); CardList racks = new CardList(opponentPlayZone.getCards());
theRack = theRack.getName("The Rack"); racks = racks.getName("The Rack");
// determine how much damage to deal the current player // determine how much damage to deal the current player
final int damage = 3 - playerHandSize; final int damage = 3 - playerHandSize;
// if there are 1 or more The Racks owned by the opponent of the // if there are 1 or more The Racks owned by the opponent of the
// current player have each of them deal damage. // current player have each of them deal damage.
if(0 < theRack.size()) { if(0 < racks.size()) {
for(int i = 0; i < theRack.size(); i++) { for(Card rack:racks) {
Ability ability = new Ability(theRack.get(0), "0") { final Card src = rack;
Ability ability = new Ability(src, "0") {
@Override @Override
public void resolve() { public void resolve() {
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, src, damage);
life.setLife(life.getLife() - damage);
} }
};// Ability };// Ability
@@ -7943,30 +7891,25 @@ public class GameActionUtil {
// so, check if opponent of the current player has Black Vise // so, check if opponent of the current player has Black Vise
String opponent = AllZone.GameAction.getOpponent(player); String opponent = AllZone.GameAction.getOpponent(player);
PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Play, opponent); CardList vises = AllZoneUtil.getPlayerCardsInPlay(opponent, "Black Vise");
CardList blackVice = new CardList(opponentPlayZone.getCards());
blackVice = blackVice.getName("Black Vise");
// determine how much damage to deal the current player // determine how much damage to deal the current player
final int damage = playerHandSize - 4; final int damage = playerHandSize - 4;
// if there are 1 or more black vises owned by the opponent of the // if there are 1 or more black vises owned by the opponent of the
// current player have each of them deal damage. // current player have each of them deal damage
if(0 < blackVice.size()) { for(Card vise:vises) {
for(int i = 0; i < blackVice.size(); i++) { final Card src = vise;
Ability ability = new Ability(blackVice.get(0), "0") { Ability ability = new Ability(src, "0") {
@Override @Override
public void resolve() { public void resolve() {
PlayerLife life = AllZone.GameAction.getPlayerLife(player); AllZone.GameAction.addDamage(player, src, damage);
life.setLife(life.getLife() - damage); }
} };// Ability
};// Ability
ability.setStackDescription("Black Vise deals " + damage + " to " + player); ability.setStackDescription("Black Vise deals " + damage + " to " + player);
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
} }
}// if
}// upkeep_BlackVice }// upkeep_BlackVice
private static void upkeep_Copper_Tablet() { private static void upkeep_Copper_Tablet() {
@@ -7983,7 +7926,6 @@ public class GameActionUtil {
ability = new Ability(source, "0") { ability = new Ability(source, "0") {
@Override @Override
public void resolve() { public void resolve() {
//AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card);
AllZone.GameAction.addDamage(player, source, 1); AllZone.GameAction.addDamage(player, source, 1);
} }
};// Ability };// Ability
@@ -8256,7 +8198,7 @@ public class GameActionUtil {
ability = new Ability(list.get(i), "0") { ability = new Ability(list.get(i), "0") {
@Override @Override
public void resolve() { public void resolve() {
AllZone.GameAction.getPlayerLife(player).subtractLife(2,F_card); AllZone.GameAction.addDamage(player, F_card, 2);
} }
}; };
@@ -8293,19 +8235,14 @@ public class GameActionUtil {
@Override @Override
public void resolve() { public void resolve() {
//if (c.getController().equals(player)) //if (c.getController().equals(player))
AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card); AllZone.GameAction.addDamage(player, F_card, 1);
} }
}; };
ability.setStackDescription("Cursed Land deals one damage to enchanted land's controller."); ability.setStackDescription("Cursed Land deals one damage to enchanted land's controller.");
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
} }
} }
} }
}//list > 0 }//list > 0
}//cursed land }//cursed land
@@ -8338,7 +8275,7 @@ public class GameActionUtil {
AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card); AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card);
} }
}; };
ability.setStackDescription("Pillory of the Sleepless deals one damage to enchanted creature's controller."); ability.setStackDescription("Pillory of the Sleepless - enchanted creature's controller loses 1 life.");
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
} }
@@ -8410,8 +8347,7 @@ public class GameActionUtil {
"Creature", "Faerie", "Rogue"}, 1, 1, new String[] {"Flying"}); "Creature", "Faerie", "Rogue"}, 1, 1, new String[] {"Flying"});
}// resolve() }// resolve()
};// Ability };// Ability
ability.setStackDescription("Bitterblossom - deals 1 damage to " + player ability.setStackDescription("Bitterblossom - " +player+" loses 1 life and puts a 1/1 token into play.");
+ " and put a 1/1 token into play.");
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
}// for }// for
@@ -8606,10 +8542,10 @@ public class GameActionUtil {
Ability ability = new Ability(blaze.get(i), "0") { Ability ability = new Ability(blaze.get(i), "0") {
@Override @Override
public void resolve() { public void resolve() {
AllZone.GameAction.getPlayerLife(player).subtractLife(1,Source); AllZone.GameAction.addDamage(player, Source, 1);
} }
}; };
ability.setStackDescription(blaze.get(i) + " - has a blaze counter and " + player + " gets dealt 1 damage."); ability.setStackDescription(blaze.get(i) + " - has a blaze counter and deals 1 damage to" + player + ".");
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
} }
@@ -9367,8 +9303,8 @@ public class GameActionUtil {
String[] choices = {"Yes", "No, target a creature instead"}; String[] choices = {"Yes", "No, target a creature instead"};
Object q = AllZone.Display.getChoiceOptional("Select computer as target?", choices); Object q = AllZone.Display.getChoiceOptional("Select computer as target?", choices);
if(q != null && q.equals("Yes")) AllZone.GameAction.getPlayerLife(Constant.Player.Computer).subtractLife( if(q != null && q.equals("Yes")) AllZone.GameAction.addDamage(Constant.Player.Computer,
hondlist.size(),card); card, hondlist.size());
else { else {
CardList cards = new CardList(oppPlay.getCards()); CardList cards = new CardList(oppPlay.getCards());
CardList oppCreatures = new CardList(); CardList oppCreatures = new CardList();
@@ -9401,8 +9337,7 @@ public class GameActionUtil {
} }
if(targetc != null) { if(targetc != null) {
if(AllZone.GameAction.isCardInPlay(targetc)) targetc.addDamage(hondlist.size(), card); if(AllZone.GameAction.isCardInPlay(targetc)) targetc.addDamage(hondlist.size(), card);
} else AllZone.GameAction.getPlayerLife(Constant.Player.Human).subtractLife( } else AllZone.GameAction.addDamage(Constant.Player.Human, card, hondlist.size());
hondlist.size(),card);
} }
}//resolve() }//resolve()
};//SpellAbility };//SpellAbility
@@ -9410,8 +9345,6 @@ public class GameActionUtil {
ability.setStackDescription(list.get(i) + " - Deals " + hondlist.size() ability.setStackDescription(list.get(i) + " - Deals " + hondlist.size()
+ " damage to target creature or player"); + " damage to target creature or player");
AllZone.Stack.add(ability); AllZone.Stack.add(ability);
} }
}// upkeep_Honden_of_Infinite_Rage }// upkeep_Honden_of_Infinite_Rage
@@ -9477,13 +9410,7 @@ public class GameActionUtil {
private static void upkeep_Moroii() { private static void upkeep_Moroii() {
final String player = AllZone.Phase.getActivePlayer(); final String player = AllZone.Phase.getActivePlayer();
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player); CardList list = AllZoneUtil.getPlayerCardsInPlay(player, "Moroii");
CardList list = new CardList();
list.addAll(play.getCards());
list = list.getName("Moroii");
for(int i = 0; i < list.size(); i++) { for(int i = 0; i < list.size(); i++) {
final Card F_card = list.get(i); final Card F_card = list.get(i);
AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card); AllZone.GameAction.getPlayerLife(player).subtractLife(1,F_card);
@@ -10628,10 +10555,8 @@ public class GameActionUtil {
{ {
if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(c, getTargetCard()) ) if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(c, getTargetCard()) )
AllZone.GameAction.addDamage(getTargetCard(), c, 1); AllZone.GameAction.addDamage(getTargetCard(), c, 1);
//getTargetCard().addDamage(1);
} }
else else
//AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(1);
AllZone.GameAction.addDamage(getTargetPlayer(), c, 1); AllZone.GameAction.addDamage(getTargetPlayer(), c, 1);
}//resolve() }//resolve()
};//SpellAbility };//SpellAbility