mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Refactor - move MoreCardsInHandThanOpponentsCondition to shared file
This commit is contained in:
parent
71c8adbe5f
commit
1005fd65f9
8 changed files with 39 additions and 26 deletions
|
|
@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue