mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
- Fixed #6056. Please test when you can. Now you will see other abilities/spellAbilities from cards presented during the cast from exile. Overload, Emerge, Surge, etc.
This commit is contained in:
parent
76da8dd539
commit
2de7c136ea
11 changed files with 135 additions and 66 deletions
|
|
@ -63,6 +63,9 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
*/
|
||||
public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) {
|
||||
MageObject object = game.getObject(sourceId);
|
||||
if ((Boolean) game.getState().getValue("CastFromExileEnabled" + object.getId()) != null) {
|
||||
return (Boolean) game.getState().getValue("CastFromExileEnabled" + object.getId()); // card like Chandra, Torch of Defiance +1 loyal ability)
|
||||
}
|
||||
return null != game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) // check this first to allow Offering in main phase
|
||||
|| timing == TimingRule.INSTANT
|
||||
|| object.hasAbility(FlashAbility.getInstance().getId(), game)
|
||||
|
|
@ -72,7 +75,8 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
if (this.spellCanBeActivatedRegularlyNow(playerId, game)) {
|
||||
if (spellAbilityType == SpellAbilityType.SPLIT || spellAbilityType == SpellAbilityType.SPLIT_AFTERMATH) {
|
||||
if (spellAbilityType == SpellAbilityType.SPLIT
|
||||
|| spellAbilityType == SpellAbilityType.SPLIT_AFTERMATH) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
// fix for Gitaxian Probe and casting opponent's spells
|
||||
|
|
@ -93,7 +97,8 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
// Alternate spell abilities (Flashback, Overload) can't be cast with no mana to pay option
|
||||
if (getSpellAbilityType() == SpellAbilityType.BASE_ALTERNATE) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && getSourceId().equals(player.getCastSourceIdWithAlternateMana())) {
|
||||
if (player != null
|
||||
&& getSourceId().equals(player.getCastSourceIdWithAlternateMana())) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ public class EmergeAbility extends SpellAbility {
|
|||
if (super.canActivate(playerId, game).canActivate()) {
|
||||
Player controller = game.getPlayer(this.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), this.getControllerId(), this.getSourceId(), game)) {
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(
|
||||
new FilterControlledCreaturePermanent(), this.getControllerId(), this.getSourceId(), game)) {
|
||||
ManaCost costToPay = CardUtil.reduceCost(emergeCost.copy(), creature.getConvertedManaCost());
|
||||
if (costToPay.canPay(this, this.getSourceId(), this.getControllerId(), game)) {
|
||||
return ActivationStatus.getTrue();
|
||||
|
|
|
|||
|
|
@ -57,10 +57,13 @@ public class FlashbackAbility extends SpellAbility {
|
|||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
ActivationStatus activationStatus = super.canActivate(playerId, game);
|
||||
if (activationStatus.canActivate()) {
|
||||
if (super.canActivate(playerId, game).canActivate()) {
|
||||
Card card = game.getCard(getSourceId());
|
||||
if (card != null) {
|
||||
// Card must be in the graveyard zone
|
||||
if (game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
// Cards with no Mana Costs cant't be flashbacked (e.g. Ancestral Vision)
|
||||
if (card.getManaCost().isEmpty()) {
|
||||
return ActivationStatus.getFalse();
|
||||
|
|
@ -76,7 +79,7 @@ public class FlashbackAbility extends SpellAbility {
|
|||
return card.getSpellAbility().canActivate(playerId, game);
|
||||
}
|
||||
}
|
||||
return activationStatus;
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ public class SpectacleAbility extends SpellAbility {
|
|||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
if (OpponentsLostLifeCount.instance.calculate(game, playerId) > 0) {
|
||||
return super.canActivate(playerId, game);
|
||||
if (OpponentsLostLifeCount.instance.calculate(game, playerId) > 0
|
||||
&& super.canActivate(playerId, game).canActivate()) {
|
||||
return ActivationStatus.getTrue();
|
||||
}
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,9 @@ public class SurgeAbility extends SpellAbility {
|
|||
if (player != null) {
|
||||
for (UUID playerToCheckId : game.getState().getPlayersInRange(playerId, game)) {
|
||||
if (!player.hasOpponent(playerToCheckId, game)) {
|
||||
if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(playerToCheckId) > 0) {
|
||||
return super.canActivate(playerId, game);
|
||||
if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(playerToCheckId) > 0
|
||||
&& super.canActivate(playerId, game).canActivate()) {
|
||||
return ActivationStatus.getTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void setLife(int life, Game game, UUID sourceId);
|
||||
|
||||
/**
|
||||
* @param amount amount of life loss
|
||||
* @param amount amount of life loss
|
||||
* @param game
|
||||
* @param atCombat was the source combat damage
|
||||
* @return
|
||||
|
|
@ -311,7 +311,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void useDeck(Deck deck, Game game);
|
||||
|
||||
/**
|
||||
* Called before each applyEffects, to rest all what can be applyed by
|
||||
* Called before each applyEffects, to rest all what can be applied by
|
||||
* continuous effects
|
||||
*/
|
||||
void reset();
|
||||
|
|
@ -326,6 +326,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana);
|
||||
|
||||
SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana);
|
||||
|
||||
boolean putInHand(Card card, Game game);
|
||||
|
||||
boolean removeFromHand(Card card, Game game);
|
||||
|
|
@ -349,14 +351,15 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param source
|
||||
* @param game
|
||||
* @param targetPlayerId player whose library will be searched
|
||||
* @param triggerEvents whether searching will trigger any game events
|
||||
* @param triggerEvents whether searching will trigger any game events
|
||||
* @return true if search was successful
|
||||
*/
|
||||
boolean searchLibrary(TargetCardInLibrary target, Ability source, Game game, UUID targetPlayerId, boolean triggerEvents);
|
||||
|
||||
/**
|
||||
* Reveals all players' libraries. Useful for abilities like Jace, Architect of Thought's -8
|
||||
* that have effects that require information from all libraries.
|
||||
* Reveals all players' libraries. Useful for abilities like Jace, Architect
|
||||
* of Thought's -8 that have effects that require information from all
|
||||
* libraries.
|
||||
*
|
||||
* @param source
|
||||
* @param game
|
||||
|
|
@ -369,23 +372,23 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
/**
|
||||
* Plays a card if possible
|
||||
*
|
||||
* @param card the card that can be cast
|
||||
* @param card the card that can be cast
|
||||
* @param game
|
||||
* @param noMana if it's a spell i can be cast without paying mana
|
||||
* @param noMana if it's a spell i can be cast without paying mana
|
||||
* @param ignoreTiming if it's cast during the resolution of another spell
|
||||
* no sorcery or play land timing restriction are checked. For a land it has
|
||||
* to be the turn of the player playing that card.
|
||||
* @param reference mage object that allows to play the card
|
||||
* no sorcery or play land timing restriction are checked. For a land it has
|
||||
* to be the turn of the player playing that card.
|
||||
* @param reference mage object that allows to play the card
|
||||
* @return
|
||||
*/
|
||||
boolean playCard(Card card, Game game, boolean noMana, boolean ignoreTiming, MageObjectReference reference);
|
||||
|
||||
/**
|
||||
* @param card the land card to play
|
||||
* @param card the land card to play
|
||||
* @param game
|
||||
* @param ignoreTiming false - it won't be checked if the stack is empty and
|
||||
* you are able to play a Sorcery. It's still checked, if you are able to
|
||||
* play a land concerning the number of lands you already played.
|
||||
* you are able to play a Sorcery. It's still checked, if you are able to
|
||||
* play a land concerning the number of lands you already played.
|
||||
* @return
|
||||
*/
|
||||
boolean playLand(Card card, Game game, boolean ignoreTiming);
|
||||
|
|
@ -531,11 +534,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
/**
|
||||
* Moves the cards from cards to the bottom of the players library.
|
||||
*
|
||||
* @param cards - list of cards that have to be moved
|
||||
* @param game - game
|
||||
* @param cards - list of cards that have to be moved
|
||||
* @param game - game
|
||||
* @param anyOrder - true if player can determine the order of the cards
|
||||
* else random order
|
||||
* @param source - source ability
|
||||
* else random order
|
||||
* @param source - source ability
|
||||
* @return
|
||||
*/
|
||||
boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
|
||||
|
|
@ -556,10 +559,10 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
/**
|
||||
* Moves the cards from cards to the top of players library.
|
||||
*
|
||||
* @param cards - list of cards that have to be moved
|
||||
* @param game - game
|
||||
* @param cards - list of cards that have to be moved
|
||||
* @param game - game
|
||||
* @param anyOrder - true if player can determine the order of the cards
|
||||
* @param source - source ability
|
||||
* @param source - source ability
|
||||
* @return
|
||||
*/
|
||||
boolean putCardsOnTopOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
|
||||
|
|
@ -590,8 +593,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
/**
|
||||
* Choose the order in which blockers get damage assigned to
|
||||
*
|
||||
* @param blockers list of blockers where to choose the next one from
|
||||
* @param combatGroup the concerning combat group
|
||||
* @param blockers list of blockers where to choose the next one from
|
||||
* @param combatGroup the concerning combat group
|
||||
* @param blockerOrder the already set order of blockers
|
||||
* @param game
|
||||
* @return blocker next to add to the blocker order
|
||||
|
|
@ -660,7 +663,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
*
|
||||
* @param card
|
||||
* @param game
|
||||
* @param abilitiesToActivate extra info about abilities that can be activated on NO option
|
||||
* @param abilitiesToActivate extra info about abilities that can be
|
||||
* activated on NO option
|
||||
* @return player looked at the card
|
||||
*/
|
||||
boolean lookAtFaceDownCard(Card card, Game game, int abilitiesToActivate);
|
||||
|
|
@ -700,8 +704,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void addCommanderId(UUID commanderId);
|
||||
|
||||
/**
|
||||
* Get the commanderIds of the player
|
||||
* Deprecated, use game.getCommandersIds(xxx) instead
|
||||
* Get the commanderIds of the player Deprecated, use
|
||||
* game.getCommandersIds(xxx) instead
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -733,11 +737,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param toZone
|
||||
* @param source
|
||||
* @param game
|
||||
* @param tapped the cards are tapped on the battlefield
|
||||
* @param faceDown the cards are face down in the to zone
|
||||
* @param byOwner the card is moved (or put onto battlefield) by the owner
|
||||
* of the card and if target zone is battlefield controls the permanent
|
||||
* (instead of the controller of the source)
|
||||
* @param tapped the cards are tapped on the battlefield
|
||||
* @param faceDown the cards are face down in the to zone
|
||||
* @param byOwner the card is moved (or put onto battlefield) by the owner
|
||||
* of the card and if target zone is battlefield controls the permanent
|
||||
* (instead of the controller of the source)
|
||||
* @param appliedEffects
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -773,7 +777,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* list of applied effects is not saved
|
||||
*
|
||||
* @param card
|
||||
* @param exileId exile zone id (optional)
|
||||
* @param exileId exile zone id (optional)
|
||||
* @param exileName name of exile zone (optional)
|
||||
* @param sourceId
|
||||
* @param game
|
||||
|
|
@ -815,7 +819,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param sourceId
|
||||
* @param game
|
||||
* @param fromZone if null, this info isn't postet
|
||||
* @param toTop to the top of the library else to the bottom
|
||||
* @param toTop to the top of the library else to the bottom
|
||||
* @param withName show the card name in the log
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -840,10 +844,10 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* 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 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
|
||||
* cost
|
||||
* @param costs alternate other costs you need to pay
|
||||
*/
|
||||
void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts<ManaCost> manaCosts, Costs<Cost> costs);
|
||||
|
||||
|
|
@ -900,4 +904,5 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void removePhyrexianFromColors(FilterMana colors);
|
||||
|
||||
FilterMana getPhyrexianColors();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1462,6 +1462,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
for (Ability ability : object.getAbilities()) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
switch (((SpellAbility) ability).getSpellAbilityType()) {
|
||||
case BASE_ALTERNATE:
|
||||
ActivationStatus as = ((SpellAbility) ability).canActivate(playerId, game);
|
||||
if (as.canActivate()) {
|
||||
useable.put(ability.getId(), (SpellAbility) ability); // example: Chandra, Torch of Defiance +1 loyal ability
|
||||
}
|
||||
return useable;
|
||||
case SPLIT_FUSED:
|
||||
if (zone == Zone.HAND) {
|
||||
if (ability.canChooseTarget(game)) {
|
||||
|
|
@ -1502,7 +1508,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// Get the usable activated abilities for a *single card object*, that is, either a card or half of a split card.
|
||||
// Also called on the whole split card but only passing the fuse ability and other whole-split-card shared abilities
|
||||
// as candidates.
|
||||
private void getUseableActivatedAbilitiesHalfImpl(MageObject object, Zone zone, Game game, Abilities<Ability> candidateAbilites,
|
||||
private void getUseableActivatedAbilitiesHalfImpl(MageObject object, Zone zone, Game game, Abilities<Ability> candidateAbilites,
|
||||
LinkedHashMap<UUID, ActivatedAbility> output) {
|
||||
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
|
||||
ManaOptions availableMana = null;
|
||||
|
|
@ -4345,4 +4351,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
public FilterMana getPhyrexianColors() {
|
||||
return this.phyrexianColors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana) {
|
||||
return card.getSpellAbility();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue