mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 05:09:16 -08:00
commit
3991ec4ba0
24 changed files with 445 additions and 73 deletions
|
|
@ -109,6 +109,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
|
|||
if (permanent != null) {
|
||||
return permanent.getControllerId();
|
||||
}
|
||||
return null;
|
||||
// for effects like Deflecting Palm (could be wrong if card was played multiple times by different players)
|
||||
return game.getContinuousEffects().getControllerOfSourceId(sourceId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,10 +164,8 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
|
|||
if (gainsHaste) {
|
||||
token.addAbility(HasteAbility.getInstance());
|
||||
}
|
||||
if (additionalSubType != null) {
|
||||
if (token.getSubtype().contains(additionalSubType)) {
|
||||
token.getSubtype().add(additionalSubType);
|
||||
}
|
||||
if (additionalSubType != null && !token.getSubtype().contains(additionalSubType)) {
|
||||
token.getSubtype().add(additionalSubType);
|
||||
}
|
||||
token.putOntoBattlefield(number, game, source.getSourceId(), playerId == null ? source.getControllerId() : playerId, tapped, attacking, attackedPlayer);
|
||||
for (UUID tokenId : token.getLastAddedTokenIds()) { // by cards like Doubling Season multiple tokens can be added to the battlefield
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -44,7 +43,6 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class PutTopCardOfLibraryIntoGraveEachPlayerEffect extends OneShotEffect {
|
||||
|
||||
private final DynamicValue numberCards;
|
||||
|
|
@ -53,7 +51,7 @@ public class PutTopCardOfLibraryIntoGraveEachPlayerEffect extends OneShotEffect
|
|||
public PutTopCardOfLibraryIntoGraveEachPlayerEffect(int numberCards, TargetController targetController) {
|
||||
this(new StaticValue(numberCards), targetController);
|
||||
}
|
||||
|
||||
|
||||
public PutTopCardOfLibraryIntoGraveEachPlayerEffect(DynamicValue numberCards, TargetController targetController) {
|
||||
super(Outcome.Discard);
|
||||
this.numberCards = numberCards;
|
||||
|
|
@ -76,42 +74,42 @@ public class PutTopCardOfLibraryIntoGraveEachPlayerEffect extends OneShotEffect
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
switch(targetController) {
|
||||
switch (targetController) {
|
||||
case OPPONENT:
|
||||
for(UUID playerId: game.getOpponents(source.getControllerId()) ) {
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
putCardsToGravecard(playerId, source, game);
|
||||
}
|
||||
break;
|
||||
case ANY:
|
||||
for(UUID playerId: player.getInRange() ) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
putCardsToGravecard(playerId, source, game);
|
||||
}
|
||||
break;
|
||||
case NOT_YOU:
|
||||
for(UUID playerId: player.getInRange() ) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
if (!playerId.equals(source.getSourceId())) {
|
||||
putCardsToGravecard(playerId, source, game);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("TargetController type not supported.");
|
||||
}
|
||||
throw new UnsupportedOperationException("TargetController type not supported.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void putCardsToGravecard(UUID playerId, Ability source, Game game) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
player.moveCards(player.getLibrary().getTopCards(game, numberCards.calculate(game, source, this)), Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
switch(targetController) {
|
||||
switch (targetController) {
|
||||
case OPPONENT:
|
||||
sb.append("Each opponent ");
|
||||
break;
|
||||
|
|
@ -120,14 +118,14 @@ public class PutTopCardOfLibraryIntoGraveEachPlayerEffect extends OneShotEffect
|
|||
break;
|
||||
case NOT_YOU:
|
||||
sb.append("Each other player ");
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("TargetController type not supported.");
|
||||
throw new UnsupportedOperationException("TargetController type not supported.");
|
||||
}
|
||||
sb.append("puts the top ");
|
||||
sb.append(CardUtil.numberToText(numberCards.toString(),"a"));
|
||||
sb.append(CardUtil.numberToText(numberCards.toString(), "a"));
|
||||
sb.append(" card");
|
||||
sb.append(numberCards.toString().equals("1")?"":"s");
|
||||
sb.append(numberCards.toString().equals("1") ? "" : "s");
|
||||
sb.append(" of his or her library into his or her graveyard");
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class ZombieToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("10E", "M10", "M11", "M12", "M13", "M14", "M15", "MBS", "ALA", "ISD", "C14", "CNS", "MMA", "BNG", "KTK", "DTK", "ORI"));
|
||||
tokenImageSets.addAll(Arrays.asList("10E", "M10", "M11", "M12", "M13", "M14", "M15", "MBS", "ALA", "ISD", "C14", "C15", "CNS", "MMA", "BNG", "KTK", "DTK", "ORI"));
|
||||
}
|
||||
|
||||
public ZombieToken() {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ import mage.abilities.Modes;
|
|||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
|
|
@ -756,19 +758,23 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void cleanUpOnMatchEnd();
|
||||
|
||||
/**
|
||||
* If the next cast spell has the set sourceId, the spell will be cast
|
||||
* without mana.
|
||||
* If the next spell cast has the set sourceId, the spell will be cast
|
||||
* without mana (null) or the mana set to manaCosts instead of its normal
|
||||
* mana costs.
|
||||
*
|
||||
* @param sourceId the source that can be cast without mana
|
||||
* @param manaCosts alternate ManaCost, null if it can be cast without mana
|
||||
* cost
|
||||
* @param costs alternate other costs you need to pay
|
||||
*/
|
||||
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts);
|
||||
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts<ManaCost> manaCosts, mage.abilities.costs.Costs costs);
|
||||
|
||||
UUID getCastSourceIdWithAlternateMana();
|
||||
|
||||
ManaCosts getCastSourceIdManaCosts();
|
||||
|
||||
Costs<Cost> getCastSourceIdCosts();
|
||||
|
||||
// permission handling to show hand cards
|
||||
void addPermissionToShowHandCards(UUID watcherUserId);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import mage.abilities.costs.AlternativeCost;
|
|||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
|
|
@ -222,7 +223,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
// indicates that the spell with the set sourceId can be cast with an alternate mana costs (can also be no mana costs)
|
||||
protected UUID castSourceIdWithAlternateMana;
|
||||
protected ManaCosts castSourceIdManaCosts;
|
||||
protected ManaCosts<ManaCost> castSourceIdManaCosts;
|
||||
protected Costs<Cost> castSourceIdCosts;
|
||||
|
||||
// indicates that the player is in mana payment phase
|
||||
protected boolean payManaMode = false;
|
||||
|
|
@ -326,6 +328,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
this.castSourceIdWithAlternateMana = player.castSourceIdWithAlternateMana;
|
||||
this.castSourceIdManaCosts = player.castSourceIdManaCosts;
|
||||
this.castSourceIdCosts = player.castSourceIdCosts;
|
||||
this.payManaMode = player.payManaMode;
|
||||
}
|
||||
|
||||
|
|
@ -388,6 +391,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.reachedNextTurnAfterLeaving = player.hasReachedNextTurnAfterLeaving();
|
||||
this.castSourceIdWithAlternateMana = player.getCastSourceIdWithAlternateMana();
|
||||
this.castSourceIdManaCosts = player.getCastSourceIdManaCosts();
|
||||
this.castSourceIdCosts = player.getCastSourceIdCosts();
|
||||
|
||||
// Don't restore!
|
||||
// this.storedBookmark
|
||||
|
|
@ -453,6 +457,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
this.castSourceIdWithAlternateMana = null;
|
||||
this.castSourceIdManaCosts = null;
|
||||
this.castSourceIdCosts = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -476,6 +481,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.alternativeSourceCosts.clear();
|
||||
this.castSourceIdWithAlternateMana = null;
|
||||
this.castSourceIdManaCosts = null;
|
||||
this.castSourceIdCosts = null;
|
||||
this.getManaPool().clearEmptyManaPoolRules();
|
||||
}
|
||||
|
||||
|
|
@ -684,6 +690,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param amount
|
||||
* @param source
|
||||
* @param game
|
||||
*/
|
||||
@Override
|
||||
public void discard(int amount, Ability source, Game game) {
|
||||
discard(amount, false, source, game);
|
||||
|
|
@ -917,9 +929,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts) {
|
||||
public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts, mage.abilities.costs.Costs costs) {
|
||||
castSourceIdWithAlternateMana = sourceId;
|
||||
castSourceIdManaCosts = manaCosts;
|
||||
castSourceIdCosts = costs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -927,6 +940,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return castSourceIdWithAlternateMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Costs<Cost> getCastSourceIdCosts() {
|
||||
return castSourceIdCosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts getCastSourceIdManaCosts() {
|
||||
return castSourceIdManaCosts;
|
||||
|
|
@ -950,20 +968,25 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
Zone fromZone = game.getState().getZone(card.getMainCard().getId());
|
||||
card.cast(game, fromZone, ability, playerId);
|
||||
Spell spell = game.getStack().getSpell(ability.getId());
|
||||
// some effects set sourceId to cast without paying mana costs
|
||||
// some effects set sourceId to cast without paying mana costs or other costs
|
||||
if (ability.getSourceId().equals(getCastSourceIdWithAlternateMana())) {
|
||||
ManaCosts alternateCosts = getCastSourceIdManaCosts();
|
||||
Ability spellAbility = spell.getSpellAbility();
|
||||
ManaCosts alternateCosts = getCastSourceIdManaCosts();
|
||||
Costs<Cost> costs = getCastSourceIdCosts();
|
||||
if (alternateCosts == null) {
|
||||
noMana = true;
|
||||
} else {
|
||||
spellAbility.getManaCosts().clear();
|
||||
spellAbility.getManaCosts().add(alternateCosts.copy());
|
||||
spellAbility.getManaCostsToPay().clear();
|
||||
spellAbility.getManaCosts().add(alternateCosts.copy());
|
||||
spellAbility.getManaCostsToPay().add(alternateCosts.copy());
|
||||
}
|
||||
spellAbility.getCosts().clear();
|
||||
if (costs != null) {
|
||||
spellAbility.getCosts().addAll(costs);
|
||||
}
|
||||
}
|
||||
setCastSourceIdWithAlternateMana(null, null);
|
||||
setCastSourceIdWithAlternateMana(null, null, null);
|
||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId);
|
||||
game.fireEvent(event);
|
||||
if (spell.activate(game, noMana)) {
|
||||
|
|
@ -984,12 +1007,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) {
|
||||
public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana
|
||||
) {
|
||||
return ability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playLand(Card card, Game game) {
|
||||
public boolean playLand(Card card, Game game
|
||||
) {
|
||||
// Check for alternate casting possibilities: e.g. land with Morph
|
||||
ActivatedAbility playLandAbility = null;
|
||||
boolean found = false;
|
||||
|
|
@ -3050,7 +3075,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
case GRAVEYARD:
|
||||
fromZone = game.getState().getZone(cards.iterator().next().getId());
|
||||
successfulMovedCards = moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
||||
break;
|
||||
return successfulMovedCards.size() > 0;
|
||||
case BATTLEFIELD: // new logic that does not yet add the permanents to battlefield while replacement effects are handled
|
||||
List<Permanent> permanents = new ArrayList<>();
|
||||
List<Permanent> permanentsEntered = new ArrayList<>();
|
||||
|
|
@ -3260,6 +3285,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
game.fireEvent(new ZoneChangeGroupEvent(movedCards, source == null ? null : source.getSourceId(), this.getId(), fromZone, Zone.GRAVEYARD));
|
||||
return movedCards;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue