mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Malfegor - Fixed the enters the battlefield triggered ability that did not work correctly.
This commit is contained in:
parent
c72b87a446
commit
c352c70e27
1 changed files with 22 additions and 20 deletions
|
@ -93,31 +93,33 @@ class MalfegorEffect extends OneShotEffect<MalfegorEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you == null) {
|
||||
return false;
|
||||
}
|
||||
int handSizeBefore = you.getHand().size();
|
||||
you.discardToMax(game);
|
||||
int sacrificeNumber = handSizeBefore - you.getHand().size();
|
||||
for (UUID opponentId : game.getOpponents(you.getId())) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
if (opponent != null) {
|
||||
for (int i = 0; i < sacrificeNumber; i++) {
|
||||
Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent());
|
||||
if (target.canChoose(opponentId, game)) {
|
||||
while (!target.isChosen() && target.canChoose(opponentId, game)) {
|
||||
opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
}
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int sacrificeNumber = controller.getHand().size();
|
||||
if (sacrificeNumber > 0) {
|
||||
controller.discard(sacrificeNumber, source, game);
|
||||
for (UUID opponentId : game.getOpponents(controller.getId())) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
if (opponent != null) {
|
||||
for (int i = 0; i < sacrificeNumber; i++) {
|
||||
Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent());
|
||||
target.setRequired(true);
|
||||
if (target.canChoose(opponentId, game)) {
|
||||
if (opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue