From e0fb91f380a2daee4ec9e4a748908867d949d272 Mon Sep 17 00:00:00 2001 From: "maurer.it" Date: Thu, 13 Oct 2011 22:34:03 -0400 Subject: [PATCH] Fixed issue 212, created a getter for the copiedSpell member to use in the copied spells resolution of the rebound effect. --- .../mage/ai/ConfigurableComputerConfig.java | 75 ------------------- .../abilities/keyword/ReboundAbility.java | 44 +++++------ Mage/src/mage/game/stack/Spell.java | 4 + 3 files changed, 27 insertions(+), 96 deletions(-) delete mode 100644 Mage.Server.Plugins/Mage.Player.AI.Standard/src/main/java/org/mage/ai/ConfigurableComputerConfig.java diff --git a/Mage.Server.Plugins/Mage.Player.AI.Standard/src/main/java/org/mage/ai/ConfigurableComputerConfig.java b/Mage.Server.Plugins/Mage.Player.AI.Standard/src/main/java/org/mage/ai/ConfigurableComputerConfig.java deleted file mode 100644 index efd921e3cef..00000000000 --- a/Mage.Server.Plugins/Mage.Player.AI.Standard/src/main/java/org/mage/ai/ConfigurableComputerConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ - -package org.mage.ai; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import mage.util.Logging; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class ConfigurableComputerConfig { - - private final static Logger logger = Logging.getLogger(ConfigurableComputerConfig.class.getName()); - -// public static final int maxDepth; - public static final int maxNodes; - public static final int evaluatorLifeFactor; - public static final int evaluatorPermanentFactor; - public static final int evaluatorCreatureFactor; - public static final int evaluatorHandFactor; -// public static final int maxThinkSeconds; - - static { - Properties p = new Properties(); - try { - File file = new File(ConfigurableComputerConfig.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); - p.load(new FileInputStream(new File(file.getParent() + File.separator + "AIMinimax.properties"))); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } catch (URISyntaxException ex) { - Logger.getLogger(ConfigurableComputerConfig.class.getName()).log(Level.SEVERE, null, ex); - } -// maxDepth = Integer.parseInt(p.getProperty("maxDepth")); - maxNodes = Integer.parseInt(p.getProperty("maxNodes")); - evaluatorLifeFactor = Integer.parseInt(p.getProperty("evaluatorLifeFactor")); - evaluatorPermanentFactor = Integer.parseInt(p.getProperty("evaluatorPermanentFactor")); - evaluatorCreatureFactor = Integer.parseInt(p.getProperty("evaluatorCreatureFactor")); - evaluatorHandFactor = Integer.parseInt(p.getProperty("evaluatorHandFactor")); -// maxThinkSeconds = Integer.parseInt(p.getProperty("maxThinkSeconds")); - } - -} diff --git a/Mage/src/mage/abilities/keyword/ReboundAbility.java b/Mage/src/mage/abilities/keyword/ReboundAbility.java index 78a7877593c..5150a35cf82 100644 --- a/Mage/src/mage/abilities/keyword/ReboundAbility.java +++ b/Mage/src/mage/abilities/keyword/ReboundAbility.java @@ -47,7 +47,6 @@ import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.stack.Spell; import mage.players.Player; -import org.apache.log4j.Logger; /** * This ability has no effect by default and will always return false on the call @@ -104,7 +103,7 @@ public class ReboundAbility extends TriggeredAbilityImpl { if ( event.getType() == EventType.SPELL_CAST && this.installReboundEffect ) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getSourceId().equals(this.getSourceId())) { - spell.getSpellAbility().addEffect(new ReboundEffect(spell.getId())); + spell.getSpellAbility().addEffect(new ReboundEffect()); this.installReboundEffect = false; } } @@ -132,34 +131,31 @@ public class ReboundAbility extends TriggeredAbilityImpl { */ class ReboundEffect extends OneShotEffect { - private Logger log = Logger.getLogger(ReboundEffect.class); - private UUID originalId; - public ReboundEffect(UUID originalId) { + public ReboundEffect() { super(Outcome.Benefit); - this.originalId = originalId; } public ReboundEffect ( ReboundEffect effect ) { super(effect); - this.originalId = effect.originalId; } @Override public boolean apply(Game game, Ability source) { - if (!originalId.equals(source.getId())) { - log.warn("rebound was ignored. was it copied spell?"); + Spell sourceSpell = (Spell)game.getObject(source.getId()); + if ( sourceSpell.isCopiedSpell() ) { return false; } + else { + Card sourceCard = (Card)game.getObject(source.getSourceId()); + ReboundEffectCastFromExileDelayedTrigger trigger = new ReboundEffectCastFromExileDelayedTrigger(sourceCard.getId(), sourceCard.getId()); + trigger.setControllerId(source.getControllerId()); + game.addDelayedTriggeredAbility(trigger); - Card sourceCard = (Card)game.getObject(source.getSourceId()); - ReboundEffectCastFromExileDelayedTrigger trigger = new ReboundEffectCastFromExileDelayedTrigger(sourceCard.getId(), sourceCard.getId()); - trigger.setControllerId(source.getControllerId()); - game.addDelayedTriggeredAbility(trigger); - - game.getContinuousEffects().addEffect(new ReboundCastFromHandReplacementEffect(sourceCard.getId()), source); - return true; + game.getContinuousEffects().addEffect(new ReboundCastFromHandReplacementEffect(sourceCard.getId()), source); + return true; + } } @Override @@ -204,13 +200,19 @@ class ReboundCastFromHandReplacementEffect extends ReplacementEffectImpl> implements StackObject, Card { public void setCopiedSpell(boolean isCopied) { this.copiedSpell = isCopied; } + + public boolean isCopiedSpell ( ) { + return this.copiedSpell; + } }