* Malfegor - Fixed the enters the battlefield triggered ability that did not work correctly.

This commit is contained in:
LevelX2 2014-03-23 17:56:55 +01:00
parent c72b87a446
commit c352c70e27

View file

@ -93,22 +93,19 @@ class MalfegorEffect extends OneShotEffect<MalfegorEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (you == null) { if (controller != null) {
return false; int sacrificeNumber = controller.getHand().size();
} if (sacrificeNumber > 0) {
int handSizeBefore = you.getHand().size(); controller.discard(sacrificeNumber, source, game);
you.discardToMax(game); for (UUID opponentId : game.getOpponents(controller.getId())) {
int sacrificeNumber = handSizeBefore - you.getHand().size();
for (UUID opponentId : game.getOpponents(you.getId())) {
Player opponent = game.getPlayer(opponentId); Player opponent = game.getPlayer(opponentId);
if (opponent != null) { if (opponent != null) {
for (int i = 0; i < sacrificeNumber; i++) { for (int i = 0; i < sacrificeNumber; i++) {
Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent()); Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent());
target.setRequired(true);
if (target.canChoose(opponentId, game)) { if (target.canChoose(opponentId, game)) {
while (!target.isChosen() && target.canChoose(opponentId, game)) { if (opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game); permanent.sacrifice(source.getSourceId(), game);
@ -117,8 +114,13 @@ class MalfegorEffect extends OneShotEffect<MalfegorEffect> {
} }
} }
} }
}
}
return true; return true;
} }
return false;
}
@Override @Override
public MalfegorEffect copy() { public MalfegorEffect copy() {