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;
}