Remove some references to Player.getOpponent (fixing cards for multiplayer games).

This commit is contained in:
elcnesh
2014-07-28 14:35:57 +00:00
parent 643e58e954
commit 05cb449cb9
6 changed files with 23 additions and 51 deletions

View File

@@ -168,14 +168,6 @@ public abstract class CardTraitBase extends GameObject {
if ("True".equalsIgnoreCase(params.get("Bloodthirst")) && !hostController.hasBloodthirst()) return false;
if ("True".equalsIgnoreCase(params.get("FatefulHour")) && hostController.getLife() > 5) return false;
if ("You".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getPoisonCounters() == 0) return false;
if ("Opponent".equalsIgnoreCase(params.get("PlayersPoisoned")) && hostController.getOpponent().getPoisonCounters() == 0) return false;
if ("Each".equalsIgnoreCase(params.get("PlayersPoisoned"))) {
for( Player p : game.getPlayers())
if( p.getPoisonCounters() == 0 )
return false;
}
if (params.containsKey("LifeTotal")) {
final String player = params.get("LifeTotal");
String lifeCompare = "GE1";
@@ -184,8 +176,11 @@ public abstract class CardTraitBase extends GameObject {
if (player.equals("You")) {
life = hostController.getLife();
}
if (player.equals("Opponent")) {
life = hostController.getOpponent().getLife();
if (player.equals("OpponentSmallest")) {
life = hostController.getOpponentsSmallestLifeTotal();
}
if (player.equals("OpponentGreatest")) {
life = hostController.getOpponentsGreatestLifeTotal();
}
if (player.equals("ActivePlayer")) {
life = game.getPhaseHandler().getPlayerTurn().getLife();

View File

@@ -461,44 +461,6 @@ public class Game {
return card;
}
/**
* <p>
* compareTypeAmountInPlay.
* </p>
*
* @param player
* a {@link forge.game.player.Player} object.
* @param type
* a {@link java.lang.String} object.
* @return a int.
*/
public static int compareTypeAmountInPlay(final Player player, final String type) {
// returns the difference between player's
final Player opponent = player.getOpponent();
final List<Card> playerList = CardLists.getType(player.getCardsIn(ZoneType.Battlefield), type);
final List<Card> opponentList = CardLists.getType(opponent.getCardsIn(ZoneType.Battlefield), type);
return (playerList.size() - opponentList.size());
}
/**
* <p>
* compareTypeAmountInGraveyard.
* </p>
*
* @param player
* a {@link forge.game.player.Player} object.
* @param type
* a {@link java.lang.String} object.
* @return a int.
*/
public static int compareTypeAmountInGraveyard(final Player player, final String type) {
// returns the difference between player's
final Player opponent = player.getOpponent();
final List<Card> playerList = CardLists.getType(player.getCardsIn(ZoneType.Graveyard), type);
final List<Card> opponentList = CardLists.getType(opponent.getCardsIn(ZoneType.Graveyard), type);
return (playerList.size() - opponentList.size());
}
public List<Card> getCardsInGame() {
final List<Card> all = new ArrayList<Card>();
for (final Player player : getPlayers()) {

View File

@@ -308,6 +308,15 @@ public class Player extends GameEntity implements Comparable<Player> {
return result;
}
/**
* Find the smallest life total amongst this player's opponents.
*
* @return the life total of the opponent with the least life.
*/
public final int getOpponentsSmallestLifeTotal() {
return Aggregates.min(this.getOpponents(), Accessors.FN_GET_LIFE_TOTAL);
}
/**
* Find the greatest life total amongst this player's opponents.
*

View File

@@ -93,6 +93,12 @@ public class TriggerAttacks extends Trigger {
}
}
if (this.mapParams.containsKey("DefendingPlayerPoisoned")) {
if (((Player) runParams2.get("Attacked")).getPoisonCounters() == 0) {
return false;
}
}
return true;
}

View File

@@ -1,7 +1,7 @@
Name:Lurking Jackals
ManaCost:B
Types:Enchantment
T:Mode$ Always | LifeTotal$ Opponent | LifeAmount$ LE10 | TriggerZones$ Battlefield | Execute$ TrigLurkingJackalsAnimate | IsPresent$ Card.Self+Enchantment | ResolvingCheck$ IsPresent | TriggerDescription$ When an opponent has 10 or less life, if CARDNAME is an enchantment, CARDNAME becomes a 3/2 Hound creature.
T:Mode$ Always | LifeTotal$ OpponentSmallest | LifeAmount$ LE10 | TriggerZones$ Battlefield | Execute$ TrigLurkingJackalsAnimate | IsPresent$ Card.Self+Enchantment | ResolvingCheck$ IsPresent | TriggerDescription$ When an opponent has 10 or less life, if CARDNAME is an enchantment, CARDNAME becomes a 3/2 Hound creature.
SVar:TrigLurkingJackalsAnimate:AB$ Animate | Cost$ 0 | Types$ Creature,Hound | Power$ 3 | Toughness$ 2 | OverwriteTypes$ True | Permanent$ True
SVar:Picture:http://www.wizards.com/global/images/magic/general/lurking_jackals.jpg
Oracle:When an opponent has 10 or less life, if Lurking Jackals is an enchantment, it becomes a 3/2 Hound creature.
Oracle:When an opponent has 10 or less life, if Lurking Jackals is an enchantment, it becomes a 3/2 Hound creature.

View File

@@ -3,7 +3,7 @@ ManaCost:1 B B
Types:Creature Rat
PT:2/2
K:Infect
T:Mode$ Attacks | ValidCard$ Creature.Self | TriggerZones$ Battlefield | PlayersPoisoned$ Opponent | Execute$ TrigPump | TriggerDescription$ When CARDNAME attacks, if defending player is poisoned, it gets +1/+1 until end of turn.
T:Mode$ Attacks | ValidCard$ Creature.Self | TriggerZones$ Battlefield | DefendingPlayerPoisoned$ True | Execute$ TrigPump | TriggerDescription$ When CARDNAME attacks, if defending player is poisoned, it gets +1/+1 until end of turn.
SVar:TrigPump:AB$Pump | Cost$ 0 | NumAtt$ 1 | NumDef$ 1 | Defined$ Self
SVar:Picture:http://www.wizards.com/global/images/magic/general/septic_rats.jpg
Oracle:Infect (This creature deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.)\nWhenever Septic Rats attacks, if defending player is poisoned, it gets +1/+1 until end of turn.