use of mage.target.TargetPlayer in project mage by magefree.
the class PersecuteEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
ChoiceColor choice = new ChoiceColor();
if (controller == null || sourceObject == null || targetPlayer == null || !controller.choose(outcome, choice, game)) {
return false;
}
FilterCard filterCard = new FilterCard();
filterCard.add(new ColorPredicate(choice.getColor()));
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
targetPlayer.discard(new CardsImpl(targetPlayer.getHand().getCards(filterCard, game)), false, source, game);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class PersonalIncarnationLoseHalfLifeEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) {
TargetPlayer target = new TargetPlayer();
target.add(game.getOwnerId(source.getSourceId()), game);
redirectTarget = target;
return true;
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class PeerIntoTheAbyssEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer == null) {
return false;
}
targetPlayer.drawCards((int) Math.ceil(targetPlayer.getLibrary().size() / 2.0), source, game);
targetPlayer.loseLife((int) Math.ceil(targetPlayer.getLife() / 2.0), game, source, false);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class SeasonsBeatingsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
Map<Integer, UUID> creatures = new HashMap<>();
int numCreature = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
if (permanent != null) {
creatures.put(numCreature, permanent.getId());
numCreature++;
}
}
if (numCreature < 2) {
return true;
}
for (Integer i : creatures.keySet()) {
Permanent creature = game.getPermanent(creatures.get(i));
int other = RandomUtil.nextInt(numCreature);
while (other == i) {
other = RandomUtil.nextInt(numCreature);
}
Permanent creature2 = game.getPermanent(creatures.get(other));
if (creature != null && creature2 != null) {
creature2.damage(creature.getPower().getValue(), creature.getId(), source, game, false, true);
}
}
return true;
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class TezzeretAgentOfBolasEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
int count = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT).calculate(game, source, this) * 2;
if (count > 0) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.loseLife(count, game, source, false);
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(count, game, source);
}
}
return true;
}
Aggregations