more refactors

This commit is contained in:
theelk801 2024-10-03 12:59:14 -04:00
parent f4c55dfc45
commit e0f031801d
20 changed files with 348 additions and 555 deletions

View file

@ -1,21 +1,17 @@
package mage.cards.t;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author cbt33, Ad Nauseum (North), Izzet Staticaster (LevelX2), Bane Alley
* Broker (LevelX2)
*/
@ -56,30 +52,28 @@ class TaintedPactEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Card sourceCard = game.getCard(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller == null
|| sourceCard == null) {
if (controller == null) {
return false;
}
Set<String> names = new HashSet<>();
while (controller.canRespond()
&& controller.getLibrary().hasCards()) {
Cards cards = new CardsImpl();
while (controller.canRespond() && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
// the card move is sequential, not all at once.
controller.moveCards(card, Zone.EXILED, source, game);
game.processAction(); // Laelia, the Blade Reforged
// Checks if there was already exiled a card with the same name
if (names.contains(card.getName())) {
break;
}
names.add(card.getName());
if (controller.chooseUse(outcome, "Put " + card.getName() + " into your hand?", source, game)) {
//Adds the current card to hand if it is chosen.
controller.moveCards(card, Zone.HAND, source, game);
break;
}
if (card == null) {
continue;
}
// the card move is sequential, not all at once.
controller.moveCards(card, Zone.EXILED, source, game);
game.processAction(); // Laelia, the Blade Reforged
// Checks if there was already exiled a card with the same name
if (cards.getCards(game).stream().anyMatch(c -> c.sharesName(card, game))) {
break;
}
cards.add(card);
if (controller.chooseUse(outcome, "Put " + card.getName() + " into your hand?", source, game)) {
//Adds the current card to hand if it is chosen.
controller.moveCards(card, Zone.HAND, source, game);
break;
}
}
return true;