mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
fix #4207 (Indomitable Creativity)
rework to follow game rules for effect order
This commit is contained in:
parent
842fa90e7e
commit
0668a9aebc
1 changed files with 43 additions and 35 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.cards.i;
|
package mage.cards.i;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -15,9 +14,7 @@ import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.targetadjustment.XTargetsCountAdjuster;
|
import mage.target.targetadjustment.XTargetsCountAdjuster;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
|
@ -67,37 +64,48 @@ class IndomitableCreativityEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller == null) {
|
||||||
List<Permanent> destroyedPermanents = new ArrayList<>();
|
return false;
|
||||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
|
||||||
Permanent target = game.getPermanent(targetId);
|
|
||||||
if (target != null) {
|
|
||||||
if (target.destroy(source, game, false)) {
|
|
||||||
destroyedPermanents.add(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Permanent permanent : destroyedPermanents) {
|
|
||||||
Player controllerOfDestroyedCreature = game.getPlayer(permanent.getControllerId());
|
|
||||||
if (controllerOfDestroyedCreature != null) {
|
|
||||||
Library library = controllerOfDestroyedCreature.getLibrary();
|
|
||||||
if (library.hasCards()) {
|
|
||||||
Cards cardsToReaveal = new CardsImpl();
|
|
||||||
for (Card card : library.getCards(game)) {
|
|
||||||
cardsToReaveal.add(card);
|
|
||||||
if (card.isCreature(game) || card.isArtifact(game)) {
|
|
||||||
controllerOfDestroyedCreature.moveCards(card, Zone.EXILED, source, game);
|
|
||||||
controllerOfDestroyedCreature.moveCards(card, Zone.BATTLEFIELD, source, game);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controllerOfDestroyedCreature.revealCards(source, " for destroyed " + permanent.getIdName(), cardsToReaveal, game);
|
|
||||||
controllerOfDestroyedCreature.shuffleLibrary(source, game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
List<Permanent> destroyedPermanents = new ArrayList<>();
|
||||||
|
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||||
|
Permanent target = game.getPermanent(targetId);
|
||||||
|
if (target != null && target.destroy(source, game, false)) {
|
||||||
|
destroyedPermanents.add(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (destroyedPermanents.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
game.processAction();
|
||||||
|
Map<UUID, Set<Card>> playerToBattlefield = new HashMap<>();
|
||||||
|
for (Permanent permanent : destroyedPermanents) {
|
||||||
|
Player controllerOfDestroyedCreature = game.getPlayer(permanent.getControllerId());
|
||||||
|
if (controllerOfDestroyedCreature != null) {
|
||||||
|
Library library = controllerOfDestroyedCreature.getLibrary();
|
||||||
|
if (library.hasCards()) {
|
||||||
|
playerToBattlefield.computeIfAbsent(controllerOfDestroyedCreature.getId(), x -> new HashSet<>());
|
||||||
|
Cards cardsToReveal = new CardsImpl();
|
||||||
|
for (Card card : library.getCards(game)) {
|
||||||
|
cardsToReveal.add(card);
|
||||||
|
if (card.isCreature(game) || card.isArtifact(game)) {
|
||||||
|
controllerOfDestroyedCreature.moveCards(card, Zone.EXILED, source, game);
|
||||||
|
playerToBattlefield.computeIfAbsent(controllerOfDestroyedCreature.getId(), x -> new HashSet<>()).add(card);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controllerOfDestroyedCreature.revealCards(source, " for destroyed " + permanent.getIdName(), cardsToReveal, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game.processAction();
|
||||||
|
for (Map.Entry<UUID, Set<Card>> entry: playerToBattlefield.entrySet()) {
|
||||||
|
Player player = game.getPlayer(entry.getKey());
|
||||||
|
if (player != null) {
|
||||||
|
player.moveCards(entry.getValue(), Zone.BATTLEFIELD, source, game);
|
||||||
|
player.shuffleLibrary(source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue