introduced XorLessLifeCondition

This commit is contained in:
ingmargoudt 2017-04-05 15:58:54 +02:00
parent e44b2fd673
commit 1f89b4eedf
8 changed files with 32 additions and 44 deletions

View file

@ -27,25 +27,28 @@
*/
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.players.Player;
import mage.players.PlayerList;
import java.util.UUID;
/**
*
* @author maurer.it_at_gmail.com
*/
public class TenOrLessLifeCondition implements Condition {
public class XorLessLifeCondition implements Condition {
public enum CheckType { AN_OPPONENT, CONTROLLER, TARGET_OPPONENT, EACH_PLAYER }
private final CheckType type;
private final int amount;
public TenOrLessLifeCondition ( CheckType type ) {
public XorLessLifeCondition ( CheckType type , int amount) {
this.type = type;
this.amount = amount;
}
@Override
@ -55,11 +58,11 @@ public class TenOrLessLifeCondition implements Condition {
switch ( this.type ) {
case AN_OPPONENT:
for ( UUID opponentUUID : game.getOpponents(source.getControllerId()) ) {
conditionApplies |= game.getPlayer(opponentUUID).getLife() <= 10;
conditionApplies |= game.getPlayer(opponentUUID).getLife() <= amount;
}
break;
case CONTROLLER:
conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= 10;
conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= amount;
break;
case TARGET_OPPONENT:
//TODO: Implement this.
@ -71,11 +74,11 @@ public class TenOrLessLifeCondition implements Condition {
Player p = game.getPlayer(pid);
if (p != null) {
if (maxLife < p.getLife()) {
maxLife = p.getLife();
maxLife = p.getLife();
}
}
}
conditionApplies |= maxLife <= 10;
conditionApplies |= maxLife <= amount;
break;
}