Start removing logic that depends on a single opponent, as this (naturally) doesn't work in multiplayer games.

'OppLifeTotal' is now removed, and started removing 'OppPoisonCounters'.
This commit is contained in:
elcnesh
2014-06-25 10:07:23 +00:00
parent 4eca4decac
commit 48086b30b7
9 changed files with 52 additions and 16 deletions

View File

@@ -961,7 +961,17 @@ public class CardFactoryUtil {
if (sq[0].contains("YourLifeTotal")) return doXMath(cc.getLife(), m, c);
if (sq[0].contains("OppLifeTotal")) return doXMath(ccOpp.getLife(), m, c);
if (sq[0].contains("OppGreatestLifeTotal")) return doXMath(cc.getOpponentsGreatestLifeTotal(), m, c);
if (sq[0].contains("OppsAtLifeTotal")) {
final int lifeTotal = xCount(c, sq[1]);
int number = 0;
for (final Player opp : cc.getOpponents()) {
if (opp.getLife() == lifeTotal) {
number++;
}
}
return doXMath(number, m, c);
}
// Count$TargetedLifeTotal (targeted player's life total)
if (sq[0].contains("TargetedLifeTotal")) {

View File

@@ -301,6 +301,22 @@ public class Player extends GameEntity implements Comparable<Player> {
return result;
}
/**
* Find the greatest life total amongst this player's opponents.
*
* @return the life total of the opponent with the most life.
*/
public final int getOpponentsGreatestLifeTotal() {
final List<Player> opps = this.getOpponents();
int greatestLifeTotal = Integer.MIN_VALUE;
for (final Player p : opps) {
if (p.getLife() > greatestLifeTotal) {
greatestLifeTotal = p.getLife();
}
}
return greatestLifeTotal;
}
/**
* returns allied players.
* Should keep player relations somewhere in the match structure
@@ -2407,6 +2423,10 @@ public class Player extends GameEntity implements Comparable<Player> {
if (this.getLife() != life) {
return false;
}
} else if (property.equals("IsPoisoned")) {
if (this.getPoisonCounters() <= 0) {
return false;
}
} else if (property.startsWith("withMore")) {
final String cardType = property.split("sThan")[0].substring(8);
final Player controller = "Active".equals(property.split("sThan")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController;
@@ -2426,7 +2446,7 @@ public class Player extends GameEntity implements Comparable<Player> {
return false;
}
} else if (property.startsWith("hasMore")) {
final Player controller = "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController;
final Player controller = property.contains("Than") && "Active".equals(property.split("Than")[1]) ? game.getPhaseHandler().getPlayerTurn() : sourceController;
if (property.substring(7).startsWith("Life") && this.getLife() <= controller.getLife()) {
return false;
} else if (property.substring(7).startsWith("CardsInHand")

View File

@@ -79,6 +79,12 @@ public class StaticAbilityCantAttackBlock {
&& defender.equals(hostCard.getGame().getNextPlayerAfter(card.getController(), hostCard.getChosenDirection()))) {
return false;
}
if (params.containsKey("UnlessDefender")) {
final String type = params.get("UnlessDefender");
if (defender.hasProperty(type, hostCard.getController(), hostCard)) {
return false;
}
}
return true;
}