mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Added logic that a player can order cards if more than one card goes simultanously to graveyard.
This commit is contained in:
parent
e82eecd75d
commit
050043c6b6
6 changed files with 96 additions and 33 deletions
|
@ -54,17 +54,18 @@ public class JaceBeleren extends CardImpl {
|
|||
this.color.setBlue(true);
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), false));
|
||||
|
||||
|
||||
// +2: Each player draws a card.
|
||||
this.addAbility(new LoyaltyAbility(new DrawCardAllEffect(1), 2));
|
||||
|
||||
// -1: Target player draws a card.
|
||||
LoyaltyAbility ability1 = new LoyaltyAbility(new DrawCardTargetEffect(1), -1);
|
||||
ability1.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability1);
|
||||
|
||||
// -10: Target player puts the top twenty cards of his or her library into his or her graveyard.
|
||||
LoyaltyAbility ability2 = new LoyaltyAbility(new PutLibraryIntoGraveTargetEffect(20), -10);
|
||||
ability2.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability2);
|
||||
|
||||
}
|
||||
|
||||
public JaceBeleren(final JaceBeleren card) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
@ -50,7 +49,7 @@ public class Traumatize extends CardImpl {
|
|||
public Traumatize(UUID ownerId) {
|
||||
super(ownerId, 119, "Traumatize", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
|
||||
this.expansionSetCode = "10E";
|
||||
this.color.setBlue(true);
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
this.getSpellAbility().addEffect(new TraumatizeEffect());
|
||||
}
|
||||
|
@ -79,17 +78,12 @@ class TraumatizeEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
Card card;
|
||||
int amount = player.getLibrary().size() / 2;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (player != null) {
|
||||
int amount = player.getLibrary().size() / 2;
|
||||
player.moveCardsToGraveyardWithInfo(player.getLibrary().getTopCards(game, amount), source, game, Zone.LIBRARY);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,4 +91,4 @@ class TraumatizeEffect extends OneShotEffect {
|
|||
return new TraumatizeEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import mage.abilities.Mode;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
@ -77,15 +76,7 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
// putting cards to grave shouldn't end the game, so getting minimun available
|
||||
int cardsCount = Math.min(amount.calculate(game, source, this), player.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.moveCardsToGraveyardWithInfo(player.getLibrary().getTopCards(game, cardsCount), source, game, Zone.LIBRARY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -98,7 +89,7 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect {
|
|||
|
||||
sb.append("Target ").append(mode.getTargets().get(0).getTargetName());
|
||||
sb.append(" puts the top ");
|
||||
if (message.isEmpty()) {
|
||||
if (message.isEmpty()) {
|
||||
if (amount.toString().equals("1")) {
|
||||
sb.append("card ");
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,8 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -98,12 +100,9 @@ class DredgeEffect extends ReplacementEffectImpl {
|
|||
&& player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getName()).
|
||||
append("? (").append(amount).append(" cards go from top of library to graveyard)").toString(), game)) {
|
||||
game.informPlayers(new StringBuilder(player.getName()).append(" dreges ").append(sourceCard.getName()).toString());
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
}
|
||||
Cards cardsToGrave = new CardsImpl();
|
||||
cardsToGrave.addAll(player.getLibrary().getTopCards(game, amount));
|
||||
player.moveCardsToGraveyardWithInfo(cardsToGrave, source, game, Zone.LIBRARY);
|
||||
player.moveCardToHandWithInfo(sourceCard, source.getSourceId(), game, Zone.GRAVEYARD);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -461,6 +461,22 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
*/
|
||||
boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
|
||||
|
||||
|
||||
/**
|
||||
* Moves 1 to n cards to the graveyard. The owner of the cards may determine the order,
|
||||
* if more than one card is moved to graveyard.
|
||||
* Uses card.moveToZone and posts a inform message about moving the card to graveyard
|
||||
* into the game log
|
||||
*
|
||||
* @param cards
|
||||
* @param source
|
||||
* @param game
|
||||
* @param fromZone if null, this info isn't postet
|
||||
* @return
|
||||
*/
|
||||
boolean moveCardsToGraveyardWithInfo(Cards cards, Ability source, Game game, Zone fromZone);
|
||||
boolean moveCardsToGraveyardWithInfo(List<Card> cards, Ability source, Game game, Zone fromZone);
|
||||
|
||||
/**
|
||||
* Uses card.moveToZone and posts a inform message about moving the card to graveyard
|
||||
* into the game log
|
||||
|
|
|
@ -2764,7 +2764,69 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToGraveyardWithInfo(Cards allCards, Ability source, Game game, Zone fromZone) {
|
||||
ArrayList<Card> cards = new ArrayList<>();
|
||||
cards.addAll(allCards.getCards(game));
|
||||
return moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardsToGraveyardWithInfo(List<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
while (!allCards.isEmpty()) {
|
||||
// identify cards from one owner
|
||||
Cards cards = new CardsImpl();
|
||||
UUID ownerId = null;
|
||||
for (Card card: allCards) {
|
||||
if (cards.isEmpty()) {
|
||||
ownerId = card.getOwnerId();
|
||||
}
|
||||
if (card.getOwnerId().equals(ownerId)) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
allCards.removeAll(cards);
|
||||
// move cards ot graveyard in order the owner decides
|
||||
if (cards.size() != 0) {
|
||||
TargetCard target = new TargetCard(fromZone, new FilterCard("card to put on the top of your graveyard (last one chosen will be topmost)"));
|
||||
target.setRequired(true);
|
||||
Player choosingPlayer = this;
|
||||
if (ownerId != this.getId()) {
|
||||
choosingPlayer = game.getPlayer(ownerId);
|
||||
}
|
||||
if (choosingPlayer == null) {
|
||||
continue;
|
||||
}
|
||||
boolean chooseOrder = true;
|
||||
if (cards.size() > 2) {
|
||||
chooseOrder = choosingPlayer.chooseUse(Outcome.Neutral, "Do you like to choose the order the cards go to graveyard?", game);
|
||||
}
|
||||
if (chooseOrder) {
|
||||
while (choosingPlayer.isInGame() && cards.size() > 1) {
|
||||
choosingPlayer.chooseTarget(Outcome.Neutral, cards, target, source, game);
|
||||
UUID targetObjectId = target.getFirstTarget();
|
||||
Card card = cards.get(targetObjectId, game);
|
||||
cards.remove(targetObjectId);
|
||||
if (card != null) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, fromZone);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cards.size() == 1) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(cards.getCards(game).iterator().next(), source.getSourceId(), game, fromZone);
|
||||
}
|
||||
} else {
|
||||
for (Card card : cards.getCards(game)) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, fromZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
||||
boolean result = false;
|
||||
|
|
Loading…
Reference in a new issue