mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
Some more changes concerning ThoughtAsEffects.
This commit is contained in:
parent
d1a8678086
commit
2ca945fabf
45 changed files with 3306 additions and 206 deletions
|
@ -68,9 +68,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
|
|||
protected int maxThink;
|
||||
protected int nodeCount = 0;
|
||||
protected long thinkTime = 0;
|
||||
protected transient LinkedList<Ability> actions = new LinkedList<Ability>();
|
||||
protected transient List<UUID> targets = new ArrayList<UUID>();
|
||||
protected transient List<String> choices = new ArrayList<String>();
|
||||
protected transient LinkedList<Ability> actions = new LinkedList<>();
|
||||
protected transient List<UUID> targets = new ArrayList<>();
|
||||
protected transient List<String> choices = new ArrayList<>();
|
||||
protected transient Combat combat;
|
||||
protected int currentScore;
|
||||
protected transient SimulationNode root;
|
||||
|
@ -86,8 +86,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
|
|||
super(player);
|
||||
this.maxDepth = player.maxDepth;
|
||||
this.currentScore = player.currentScore;
|
||||
if (player.combat != null)
|
||||
if (player.combat != null) {
|
||||
this.combat = player.combat.copy();
|
||||
}
|
||||
this.actions.addAll(player.actions);
|
||||
this.targets.addAll(player.targets);
|
||||
this.choices.addAll(player.choices);
|
||||
|
|
|
@ -890,7 +890,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (ability instanceof PlayLandAbility) {
|
||||
return true;
|
||||
}
|
||||
if (ability.getManaCostsToPay().convertedManaCost() > 0) {
|
||||
if (!ability.getSourceId().equals(getCastSourceIdWithoutMana()) && ability.getManaCostsToPay().convertedManaCost() > 0) {
|
||||
return true;
|
||||
}
|
||||
if (ability instanceof ManaAbility) {
|
||||
|
|
3128
Mage.Server/mageServerDaily.log.2014-08-03
Normal file
3128
Mage.Server/mageServerDaily.log.2014-08-03
Normal file
File diff suppressed because it is too large
Load diff
|
@ -276,10 +276,10 @@ public class GameSession extends GameWatcher {
|
|||
|
||||
public void kill() {
|
||||
if (game != null) {
|
||||
logger.debug("GameSession.kill before player quit for game");
|
||||
logger.debug("before game.quit playerId:" + playerId);
|
||||
game.quit(playerId);
|
||||
} else {
|
||||
logger.error("GameSession.kill game object missing playerId: " + (playerId == null ? "[null]":playerId));
|
||||
logger.error("game object missing playerId: " + (playerId == null ? "[null]":playerId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
try {
|
||||
update();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Games room update exception!", ex);
|
||||
logger.fatal("Games room update exception! " + ex.toString(), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,16 +56,16 @@ public class ServerMessagesUtil {
|
|||
private static final String SERVER_MSG_TXT_FILE = "server.msg.txt";
|
||||
private static ScheduledExecutorService updateExecutor;
|
||||
|
||||
private List<String> messages = new ArrayList<String>();
|
||||
private ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final List<String> messages = new ArrayList<>();
|
||||
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
private static String pathToExternalMessages = null;
|
||||
|
||||
private static boolean ignore = false;
|
||||
|
||||
private static long startDate;
|
||||
private static AtomicInteger gamesStarted = new AtomicInteger(0);
|
||||
private static AtomicInteger tournamentsStarted = new AtomicInteger(0);
|
||||
private static final AtomicInteger gamesStarted = new AtomicInteger(0);
|
||||
private static final AtomicInteger tournamentsStarted = new AtomicInteger(0);
|
||||
|
||||
static {
|
||||
pathToExternalMessages = System.getProperty("messagesPath");
|
||||
|
@ -97,7 +97,7 @@ public class ServerMessagesUtil {
|
|||
private void reloadMessages() {
|
||||
log.debug("Reading server messages...");
|
||||
List<String> motdMessages = readFromFile();
|
||||
List<String> newMessages = new ArrayList<String>();
|
||||
List<String> newMessages = new ArrayList<>();
|
||||
if (motdMessages != null) {
|
||||
newMessages.addAll(motdMessages);
|
||||
}
|
||||
|
@ -154,14 +154,14 @@ public class ServerMessagesUtil {
|
|||
return null;
|
||||
}
|
||||
Scanner scanner = new Scanner(is);
|
||||
List<String> messages = new ArrayList<String>();
|
||||
List<String> newMessages = new ArrayList<>();
|
||||
while (scanner.hasNextLine()) {
|
||||
String message = scanner.nextLine();
|
||||
if (!message.trim().isEmpty()) {
|
||||
messages.add(message.trim());
|
||||
newMessages.add(message.trim());
|
||||
}
|
||||
}
|
||||
return messages;
|
||||
return newMessages;
|
||||
}
|
||||
|
||||
private String getServerStatistics() {
|
||||
|
|
|
@ -96,7 +96,7 @@ class MisthollowGriffinPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(source.getSourceId())) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Zone.EXILED) {
|
||||
|
|
|
@ -40,6 +40,8 @@ import mage.players.Player;
|
|||
import mage.target.common.TargetOpponent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -86,20 +88,22 @@ class StolenGoodsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null && player.getLibrary().size() > 0) {
|
||||
Library library = player.getLibrary();
|
||||
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (opponent != null && opponent.getLibrary().size() > 0) {
|
||||
Library library = opponent.getLibrary();
|
||||
Card card;
|
||||
do {
|
||||
card = library.removeFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToExile(source.getId(), "Stolen Goods", source.getSourceId(), game);
|
||||
opponent.moveCardToExileWithInfo(card, source.getId(), "Stolen Goods", source.getSourceId(), game, Zone.LIBRARY);
|
||||
}
|
||||
} while (library.size() > 0 && card != null && card.getCardType().contains(CardType.LAND));
|
||||
|
||||
if (card != null) {
|
||||
player.revealCards("Card to cast", new CardsImpl(card), game);
|
||||
game.addEffect(new StolenGoodsCastFromExileEffect(card.getId()), source);
|
||||
opponent.revealCards("Card to cast", new CardsImpl(card), game);
|
||||
ContinuousEffect effect = new StolenGoodsCastFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -109,17 +113,13 @@ class StolenGoodsEffect extends OneShotEffect {
|
|||
|
||||
class StolenGoodsCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
private final UUID cardId;
|
||||
|
||||
public StolenGoodsCastFromExileEffect(UUID cardId) {
|
||||
public StolenGoodsCastFromExileEffect() {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may cast card from exile";
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public StolenGoodsCastFromExileEffect(final StolenGoodsCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,14 +133,12 @@ class StolenGoodsCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getZone(this.cardId) == Zone.EXILED) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && player.chooseUse(Outcome.Benefit, "Cast the card without paying cost?", game)) {
|
||||
player.cast(card.getSpellAbility(), game, true);
|
||||
}
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (getTargetPointer().getFirst(game, source).equals(sourceId) && affectedControllerId.equals(source.getControllerId())) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
|
||||
Player player = game.getPlayer(affectedControllerId);
|
||||
player.setCastSourceIdWithoutMana(sourceId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class OrnateKanzashiCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getZone(this.cardId) == Zone.EXILED) {
|
||||
|
|
|
@ -99,7 +99,7 @@ class BlockTappedEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
|
|
|
@ -99,7 +99,7 @@ class ThousandYearElixirEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
return permanent != null
|
||||
&& permanent.getCardType().contains(CardType.CREATURE)
|
||||
|
|
|
@ -118,7 +118,7 @@ class FiendOfTheShadowsEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
ExileZone zone = game.getExile().getExileZone(exileId);
|
||||
|
|
|
@ -89,7 +89,7 @@ class GravecrawlerPlayEffect extends AsThoughEffectImpl {
|
|||
|
||||
public GravecrawlerPlayEffect() {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit);
|
||||
staticText = "You may cast Gravecrawler from your graveyard as long as you control a Zombie";
|
||||
staticText = "You may cast {this} from your graveyard as long as you control a Zombie";
|
||||
}
|
||||
|
||||
public GravecrawlerPlayEffect(final GravecrawlerPlayEffect effect) {
|
||||
|
@ -107,10 +107,10 @@ class GravecrawlerPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(source.getSourceId())) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(source.getSourceId()) && source.getControllerId().equals(affectedControllerId)) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD && game.canPlaySorcery(source.getControllerId())) {
|
||||
if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
||||
if (game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -114,16 +114,8 @@ class HavengulLichPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (targetPointer.getFirst(game, source).equals(sourceId)) {
|
||||
if (game.getState().getZone(sourceId) == Zone.GRAVEYARD) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && card.getSpellAbility() != null && card.getSpellAbility().spellCanBeActivatedRegularlyNow(source.getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return targetPointer.getFirst(game, source).equals(sourceId) && game.getState().getZone(sourceId) == Zone.GRAVEYARD;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class AsThoughNoDefenderEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent nivixCyclops = game.getPermanent(source.getSourceId());
|
||||
if (nivixCyclops != null
|
||||
&& nivixCyclops.getAbilities().containsKey(DefenderAbility.getInstance().getId())) {
|
||||
|
|
|
@ -246,7 +246,7 @@ class BaneAlleyBrokerLookAtCardEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
|
|
|
@ -111,7 +111,7 @@ class GlaringSpotlightEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent creature = game.getPermanent(sourceId);
|
||||
if (creature != null) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(creature.getControllerId())) {
|
||||
|
|
|
@ -149,7 +149,7 @@ class NightveilSpecterEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && card != null && game.getState().getZone(card.getId()) == Zone.EXILED) {
|
||||
|
|
|
@ -114,7 +114,7 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (quickenWatcher.isQuickenSpellActive(source.getSourceId(), zoneChangeCounter)) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && card.getCardType().contains(CardType.SORCERY) && card.getOwnerId().equals(source.getControllerId())) {
|
||||
|
|
|
@ -30,9 +30,9 @@ package mage.sets.journeyintonyx;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
|
@ -42,13 +42,13 @@ import mage.constants.AsThoughEffectType;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -110,7 +110,9 @@ class PropheticFlamespeakerExileEffect extends OneShotEffect {
|
|||
if (card != null) {
|
||||
String exileName = new StringBuilder(sourcePermanent.getName()).append(" <this card may be played the turn it was exiled>").toString();
|
||||
controller.moveCardToExileWithInfo(card, source.getSourceId(), exileName, source.getSourceId(), game, Zone.LIBRARY);
|
||||
game.addEffect(new PropheticFlamespeakerCastFromExileEffect(card.getId()), source);
|
||||
ContinuousEffect effect = new PropheticFlamespeakerCastFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -120,17 +122,13 @@ class PropheticFlamespeakerExileEffect extends OneShotEffect {
|
|||
|
||||
class PropheticFlamespeakerCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
private final UUID cardId;
|
||||
|
||||
public PropheticFlamespeakerCastFromExileEffect(UUID cardId) {
|
||||
public PropheticFlamespeakerCastFromExileEffect() {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may play card from exile";
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public PropheticFlamespeakerCastFromExileEffect(final PropheticFlamespeakerCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,32 +142,7 @@ class PropheticFlamespeakerCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getZone(this.cardId) == Zone.EXILED) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null ) {
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
// If the revealed card is a land, you can play it only if it's your turn and you can play still a land this turn.
|
||||
if (player.canPlayLand()
|
||||
&& game.getActivePlayerId().equals(player.getId())
|
||||
&& game.getStack().isEmpty()
|
||||
&& (game.getStep().getType().equals(PhaseStep.PRECOMBAT_MAIN) || game.getStep().getType().equals(PhaseStep.POSTCOMBAT_MAIN))
|
||||
&& player.chooseUse(Outcome.Benefit, "Play this card?", game)) {
|
||||
return player.playLand(card, game);
|
||||
}
|
||||
} else {
|
||||
Ability ability = card.getSpellAbility();
|
||||
if (ability != null && ability instanceof SpellAbility
|
||||
&& ((SpellAbility)ability).spellCanBeActivatedRegularlyNow(player.getId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, "Play this card?", game)) {
|
||||
return player.cast((SpellAbility) ability, game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(getTargetPointer().getFirst(game, source)) && game.getState().getZone(sourceId) == Zone.EXILED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ class ChandraPyromasterCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (targetPointer.getTargets(game, source).contains(sourceId)) {
|
||||
return game.getState().getZone(sourceId).equals(Zone.EXILED);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class SavageSummoningAsThoughEffect extends AsThoughEffectImpl {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (watcher.isSavageSummoningSpellActive()) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE) && card.getOwnerId().equals(source.getControllerId())) {
|
||||
|
|
|
@ -140,7 +140,7 @@ class ActOnImpulseMayPlayExiledEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
|
||||
|
|
|
@ -138,7 +138,7 @@ class PraetorsGraspPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(cardId)) {
|
||||
Card card = game.getCard(cardId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
@ -177,7 +177,7 @@ class PraetorsGraspRevealEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(cardId)) {
|
||||
Card card = game.getCard(cardId);
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
|
|
|
@ -104,7 +104,7 @@ class OgreJailbreakerEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(source.getSourceId()) && gateCondition.apply(game, source)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public class WarmongersChariot extends CardImpl {
|
||||
|
||||
private static final String staticText = "As long as equipped creature has defender, it can attack as though it didn't have defender";
|
||||
|
||||
public WarmongersChariot(UUID ownerId) {
|
||||
super(ownerId, 226, "Warmonger's Chariot", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
this.expansionSetCode = "ROE";
|
||||
|
@ -95,7 +93,7 @@ class WarmongersChariotEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(equipment.getAttachedTo());
|
||||
|
|
|
@ -152,7 +152,7 @@ class KnacksawCliqueCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getExile().getExileZone(exileId).contains(cardId)) {
|
||||
|
|
|
@ -95,7 +95,7 @@ class CanBlockAsThoughtIthadShadowEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(source.getSourceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -49,6 +50,7 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
@ -129,7 +131,9 @@ class DaxosOfMeletisEffect extends OneShotEffect {
|
|||
// allow to cast the card
|
||||
game.addEffect(new DaxosOfMeletisCastFromExileEffect(card.getId(), exileId), source);
|
||||
// and you may spend mana as though it were mana of any color to cast it
|
||||
game.addEffect(new DaxosOfMeletisSpendAnyManaEffect(card.getId()), source);
|
||||
ContinuousEffect effect = new DaxosOfMeletisSpendAnyManaEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -168,32 +172,20 @@ class DaxosOfMeletisCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getExile().getExileZone(exileId).contains(cardId)) {
|
||||
if (card.getSpellAbility() != null && card.getSpellAbility().spellCanBeActivatedRegularlyNow(source.getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(cardId) && game.getState().getExile().getExileZone(exileId).contains(cardId);
|
||||
}
|
||||
}
|
||||
|
||||
class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl {
|
||||
|
||||
private final UUID cardId;
|
||||
|
||||
public DaxosOfMeletisSpendAnyManaEffect(UUID cardId) {
|
||||
public DaxosOfMeletisSpendAnyManaEffect() {
|
||||
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "you may spend mana as though it were mana of any color to cast it";
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public DaxosOfMeletisSpendAnyManaEffect(final DaxosOfMeletisSpendAnyManaEffect effect) {
|
||||
super(effect);
|
||||
this.cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,7 +199,7 @@ class DaxosOfMeletisSpendAnyManaEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
return sourceId.equals(this.cardId);
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.sets.theros;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -44,6 +45,7 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
@ -100,13 +102,13 @@ class PsychicIntrusionExileEffect extends OneShotEffect {
|
|||
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (opponent != null) {
|
||||
opponent.revealCards("Psychic Intrusion", opponent.getHand(), game);
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int cardsGraveyard = opponent.getGraveyard().count(filter, game);
|
||||
int cardsHand = opponent.getHand().count(filter, game);
|
||||
boolean fromHand = false;
|
||||
if (cardsGraveyard > 0 && cardsHand > 0) {
|
||||
if (you.chooseUse(Outcome.Detriment, "Exile card from opponents Hand?", game)) {
|
||||
if (controller.chooseUse(Outcome.Detriment, "Exile card from opponents Hand?", game)) {
|
||||
fromHand = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -117,15 +119,15 @@ class PsychicIntrusionExileEffect extends OneShotEffect {
|
|||
|
||||
Card card = null;
|
||||
if (cardsHand > 0 && fromHand) {
|
||||
TargetCard target = new TargetCard(Zone.PICK, filter);
|
||||
if (you.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
|
||||
TargetCard target = new TargetCard(Zone.HAND, filter);
|
||||
if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
|
||||
card = opponent.getHand().get(target.getFirstTarget(), game);
|
||||
|
||||
}
|
||||
}
|
||||
if (cardsGraveyard > 0 && !fromHand) {
|
||||
TargetCard target = new TargetCard(Zone.PICK, filter);
|
||||
if (you.choose(Outcome.Benefit, opponent.getGraveyard(), target, game)) {
|
||||
TargetCard target = new TargetCard(Zone.GRAVEYARD, filter);
|
||||
if (controller.choose(Outcome.Benefit, opponent.getGraveyard(), target, game)) {
|
||||
card = opponent.getGraveyard().get(target.getFirstTarget(), game);
|
||||
|
||||
}
|
||||
|
@ -133,18 +135,15 @@ class PsychicIntrusionExileEffect extends OneShotEffect {
|
|||
if (card != null) {
|
||||
// move card to exile
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
card.moveToExile(exileId, "Psychic Intrusion", source.getSourceId(), game);
|
||||
controller.moveCardToExileWithInfo(card, exileId, "Psychic Intrusion", source.getSourceId(), game, fromHand ? Zone.HAND:Zone.GRAVEYARD);
|
||||
// allow to cast the card
|
||||
game.addEffect(new PsychicIntrusionCastFromExileEffect(card.getId(), exileId), source);
|
||||
ContinuousEffect effect = new PsychicIntrusionCastFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
// and you may spend mana as though it were mana of any color to cast it
|
||||
game.addEffect(new PsychicIntrusionSpendAnyManaEffect(card.getId()), source);
|
||||
game.informPlayers(new StringBuilder("Psychic Intrusion: ")
|
||||
.append(you.getName())
|
||||
.append(" exiles ")
|
||||
.append(card.getName())
|
||||
.append(" from")
|
||||
.append(fromHand ? " hand":" graveyard").toString());
|
||||
|
||||
effect = new PsychicIntrusionSpendAnyManaEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -155,20 +154,13 @@ class PsychicIntrusionExileEffect extends OneShotEffect {
|
|||
|
||||
class PsychicIntrusionCastFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
private UUID cardId;
|
||||
private UUID exileId;
|
||||
|
||||
public PsychicIntrusionCastFromExileEffect(UUID cardId, UUID exileId) {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit);
|
||||
public PsychicIntrusionCastFromExileEffect() {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.Custom, Outcome.Benefit);
|
||||
staticText = "You may cast that card for as long as it remains exiled, and you may spend mana as though it were mana of any color to cast that spell";
|
||||
this.cardId = cardId;
|
||||
this.exileId = exileId;
|
||||
}
|
||||
|
||||
public PsychicIntrusionCastFromExileEffect(final PsychicIntrusionCastFromExileEffect effect) {
|
||||
super(effect);
|
||||
this.cardId = effect.cardId;
|
||||
this.exileId = effect.exileId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,13 +174,12 @@ class PsychicIntrusionCastFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getExile().getExileZone(exileId).contains(cardId)) {
|
||||
if (card.getSpellAbility().spellCanBeActivatedRegularlyNow(source.getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(getTargetPointer().getFirst(game, source))) {
|
||||
if (game.getState().getZone(sourceId).equals(Zone.EXILED)) {
|
||||
return true;
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -197,17 +188,13 @@ class PsychicIntrusionCastFromExileEffect extends AsThoughEffectImpl {
|
|||
|
||||
class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl {
|
||||
|
||||
private UUID cardId;
|
||||
|
||||
public PsychicIntrusionSpendAnyManaEffect(UUID cardId) {
|
||||
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.EndOfGame, Outcome.Benefit);
|
||||
public PsychicIntrusionSpendAnyManaEffect() {
|
||||
super(AsThoughEffectType.SPEND_ANY_MANA, Duration.Custom, Outcome.Benefit);
|
||||
staticText = "you may spend mana as though it were mana of any color to cast it";
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public PsychicIntrusionSpendAnyManaEffect(final PsychicIntrusionSpendAnyManaEffect effect) {
|
||||
super(effect);
|
||||
this.cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -221,9 +208,13 @@ class PsychicIntrusionSpendAnyManaEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
return true;
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(getTargetPointer().getFirst(game, source))) {
|
||||
if (game.getState().getZone(sourceId).equals(Zone.EXILED)) {
|
||||
return true;
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ public class GrinningTotem extends CardImpl {
|
|||
ability.addCost(new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetOpponent());
|
||||
// ability.addEffect(new GrinningTotemMayPlayEffect());
|
||||
// At the beginning of your next upkeep, if you haven't played it, put it into its owner's graveyard.
|
||||
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new GrinningTotemDelayedTriggeredAbility()));
|
||||
|
||||
|
@ -165,7 +164,7 @@ class GrinningTotemMayPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (targetPointer.getTargets(game, source).contains(sourceId)) {
|
||||
return game.getState().getZone(sourceId).equals(Zone.EXILED);
|
||||
}
|
||||
|
|
|
@ -28,20 +28,27 @@
|
|||
package mage.sets.worldwake;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.*;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.IslandwalkAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterArtifactCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -81,7 +88,7 @@ class ThadaAdelAcquisitorEffect extends OneShotEffect {
|
|||
|
||||
ThadaAdelAcquisitorEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "search that player's library for an artifact card and exile it. Then that player shuffles his or her library. Until end of turn, you may play that card";
|
||||
staticText = "search that player's library for an artifact card and exile it. Then that player shuffles his or her library. Until end of turn, you may play that card";
|
||||
}
|
||||
|
||||
ThadaAdelAcquisitorEffect(final ThadaAdelAcquisitorEffect effect) {
|
||||
|
@ -90,20 +97,21 @@ class ThadaAdelAcquisitorEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (you == null || damagedPlayer == null) {
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller == null || damagedPlayer == null || sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterArtifactCard());
|
||||
you.searchLibrary(target, game, damagedPlayer.getId());
|
||||
if (you.searchLibrary(target, game)) {
|
||||
if (controller.searchLibrary(target, game, damagedPlayer.getId())) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
UUID cardId = target.getTargets().get(0);
|
||||
Card card = damagedPlayer.getLibrary().remove(cardId, game);
|
||||
Card card = damagedPlayer.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.moveToExile(source.getSourceId(), "Thada Adel", source.getId(), game);
|
||||
game.addEffect(new ThadaAdelPlayFromExileEffect(card.getId()), source);
|
||||
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game, Zone.LIBRARY);
|
||||
ContinuousEffect effect = new ThadaAdelPlayFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,17 +127,13 @@ class ThadaAdelAcquisitorEffect extends OneShotEffect {
|
|||
|
||||
class ThadaAdelPlayFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
private final UUID cardId;
|
||||
|
||||
public ThadaAdelPlayFromExileEffect(UUID cardId) {
|
||||
public ThadaAdelPlayFromExileEffect() {
|
||||
super(AsThoughEffectType.CAST_FROM_NON_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may play this card from exile";
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public ThadaAdelPlayFromExileEffect(final ThadaAdelPlayFromExileEffect effect) {
|
||||
super(effect);
|
||||
cardId = effect.cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,13 +147,7 @@ class ThadaAdelPlayFromExileEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
if (sourceId.equals(this.cardId)) {
|
||||
Card card = game.getCard(this.cardId);
|
||||
if (card != null && game.getState().getZone(this.cardId) == Zone.EXILED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(getTargetPointer().getFirst(game, source)) && game.getState().getZone(sourceId) == Zone.EXILED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import mage.abilities.condition.FixedCondition;
|
|||
import mage.abilities.effects.AsThoughEffect;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
@ -100,17 +99,17 @@ public class ConditionalAsThoughEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (lockedInCondition && !(condition instanceof FixedCondition)) {
|
||||
condition = new FixedCondition(condition.apply(game, source));
|
||||
}
|
||||
conditionState = condition.apply(game, source);
|
||||
if (conditionState) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
return effect.applies(sourceId, source,game);
|
||||
return effect.applies(sourceId, source, affectedControllerId, game);
|
||||
} else if (otherwiseEffect != null) {
|
||||
otherwiseEffect.setTargetPointer(this.targetPointer);
|
||||
return otherwiseEffect.applies(sourceId, source, game);
|
||||
return otherwiseEffect.applies(sourceId, source, affectedControllerId, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.game.Game;
|
|||
public interface AsThoughEffect extends ContinuousEffect {
|
||||
|
||||
boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game);
|
||||
boolean applies(UUID sourceId, Ability source, Game game);
|
||||
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game);
|
||||
AsThoughEffectType getAsThoughEffectType();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,7 +57,7 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game) {
|
||||
return applies(sourceId, source, game);
|
||||
return applies(sourceId, source, affectedAbility.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -440,7 +440,7 @@ public class ContinuousEffects implements Serializable {
|
|||
for (Ability ability : abilities) {
|
||||
if (controllerId.equals(ability.getControllerId())) {
|
||||
if (affectedAbility == null) {
|
||||
if (effect.applies(objectId, ability, game)) {
|
||||
if (effect.applies(objectId, ability, controllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class CanAttackAsThoughtItDidntHaveDefenderAllEffect extends AsThoughEffe
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null && filter.match(permanent, game)) {
|
||||
return true;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class CanAttackAsThoughtItDidntHaveDefenderEffect extends AsThoughEffectI
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return sourceId.equals(source.getSourceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CastAsThoughItHadFlashEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && filter.match(card, game) && card.getSpellAbility().isInUseableZone(game, card, false)) {
|
||||
if (anyPlayer) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && filter.match(card, game)) {
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
|
|
|
@ -179,7 +179,7 @@ class HideawayLookAtFaceDownCardEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
|
|
|
@ -100,7 +100,7 @@ class MadnessPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (sourceId.equals(source.getSourceId())) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Zone.EXILED) {
|
||||
|
|
|
@ -130,7 +130,7 @@ class OfferingAsThoughEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -479,4 +479,13 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* Free resources on match end
|
||||
*/
|
||||
void cleanUpOnMatchEnd();
|
||||
|
||||
/**
|
||||
* If the next cast spell has the set sourceId, the spell will
|
||||
* be cast without mana.
|
||||
*
|
||||
* @param sourceId the source that can be cast without mana
|
||||
*/
|
||||
void setCastSourceIdWithoutMana(UUID sourceId);
|
||||
UUID getCastSourceIdWithoutMana();
|
||||
}
|
||||
|
|
|
@ -163,6 +163,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// They neither expire immediately nor last indefinitely.
|
||||
protected boolean reachedNextTurnAfterLeaving = false;
|
||||
|
||||
// indicates that a sourceId will be cast without paying mana
|
||||
protected UUID castSourceIdWithoutMana;
|
||||
|
||||
protected UserData userData;
|
||||
|
||||
/**
|
||||
|
@ -247,6 +250,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.passedAllTurns = player.passedAllTurns;
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.reachedNextTurnAfterLeaving = player.reachedNextTurnAfterLeaving;
|
||||
|
||||
this.castSourceIdWithoutMana = player.castSourceIdWithoutMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -303,6 +308,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.passed = player.isPassed();
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.reachedNextTurnAfterLeaving = player.hasReachedNextTurnAfterLeaving();
|
||||
this.castSourceIdWithoutMana = player.getCastSourceIdWithoutMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -354,7 +360,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.topCardRevealed = false;
|
||||
this.setLife(game.getLife(), game);
|
||||
this.setReachedNextTurnAfterLeaving(false);
|
||||
game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
|
||||
game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
|
||||
this.castSourceIdWithoutMana = null;
|
||||
}
|
||||
/**
|
||||
* called before apply effects
|
||||
|
@ -375,6 +382,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.canPlayCardsFromGraveyard = false;
|
||||
this.topCardRevealed = false;
|
||||
this.alternativeSourceCosts.clear();
|
||||
this.castSourceIdWithoutMana = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -734,6 +742,15 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCastSourceIdWithoutMana(UUID sourceId) {
|
||||
castSourceIdWithoutMana = sourceId;
|
||||
}
|
||||
|
||||
public UUID getCastSourceIdWithoutMana() {
|
||||
return castSourceIdWithoutMana;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean cast(SpellAbility ability, Game game, boolean noMana) {
|
||||
|
@ -751,6 +768,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
Zone fromZone = game.getState().getZone(card.getId());
|
||||
card.cast(game, fromZone, ability, playerId);
|
||||
Spell spell = game.getStack().getSpell(ability.getId());
|
||||
// some effects set sourceId to cast without paying mana costs
|
||||
if (ability.getSourceId().equals(getCastSourceIdWithoutMana())) {
|
||||
noMana = true;
|
||||
}
|
||||
setCastSourceIdWithoutMana(null);
|
||||
if (spell.activate(game, noMana)) {
|
||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.SPELL_CAST, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId);
|
||||
event.setZone(fromZone);
|
||||
|
|
Loading…
Reference in a new issue