Refactor - move MoreCardsInHandThanOpponentsCondition to shared file

This commit is contained in:
JOAC69 2016-09-24 18:16:47 -05:00
parent 71c8adbe5f
commit 1005fd65f9
8 changed files with 39 additions and 26 deletions

View file

@ -0,0 +1,32 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
public class MoreCardsInHandThanOpponentsCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int cardsInHand = player.getHand().size();
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null && opponent.getHand().size() >= cardsInHand) {
return false;
}
}
}
return true;
}
@Override
public String toString() {
return "you have more cards in hand than each opponent";
}
}