diff --git a/Mage/src/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java b/Mage/src/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java new file mode 100644 index 00000000000..efd7774e416 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java @@ -0,0 +1,51 @@ +/* + * 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 mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.watchers.common.CastSpellLastTurnWatcher; + +/** + * @author nantuko + */ +public class NoSpellsWereCastLastTurnCondition implements Condition { + + private static NoSpellsWereCastLastTurnCondition fInstance = new NoSpellsWereCastLastTurnCondition(); + + public static Condition getInstance() { + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(source.getControllerId(), "CastSpellLastTurnWatcher"); + return watcher.getAmountOfSpellsCastOnPrevTurn() == 0; + } +} diff --git a/Mage/src/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java b/Mage/src/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java new file mode 100644 index 00000000000..54316d37ab5 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java @@ -0,0 +1,51 @@ +/* + * 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 mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.watchers.common.CastSpellLastTurnWatcher; + +/** + * @author nantuko + */ +public class TwoOrMoreSpellsWereCastLastTurnCondition implements Condition { + + private static TwoOrMoreSpellsWereCastLastTurnCondition fInstance = new TwoOrMoreSpellsWereCastLastTurnCondition(); + + public static Condition getInstance() { + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(source.getControllerId(), "CastSpellLastTurnWatcher"); + return watcher.getAmountOfSpellsCastOnPrevTurn() >= 2; + } +} diff --git a/Mage/src/mage/abilities/keyword/TransformAbility.java b/Mage/src/mage/abilities/keyword/TransformAbility.java index 944b2ff984e..9e8587f2184 100644 --- a/Mage/src/mage/abilities/keyword/TransformAbility.java +++ b/Mage/src/mage/abilities/keyword/TransformAbility.java @@ -41,6 +41,9 @@ import mage.game.permanent.Permanent; */ public class TransformAbility extends SimpleStaticAbility { + public static final String NO_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if no spells were cast last turn, transform {this}"; + public static final String TWO_OR_MORE_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if a player cast two or more spells last turn, transform {this}"; + public TransformAbility() { super(Constants.Zone.BATTLEFIELD, new TransformEffect()); } diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 73f6bfb4ed1..3f55c7b50da 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -66,6 +66,7 @@ import mage.abilities.mana.TriggeredManaAbility; import mage.cards.CardsImpl; import mage.target.Target; import mage.target.TargetPermanent; +import mage.watchers.common.CastSpellLastTurnWatcher; import mage.watchers.common.MorbidWatcher; import org.apache.log4j.Logger; @@ -435,6 +436,7 @@ public abstract class GameImpl> implements Game, Serializa } state.getWatchers().add(new MorbidWatcher()); + state.getWatchers().add(new CastSpellLastTurnWatcher()); //20100716 - 103.5 for (UUID playerId: state.getPlayerList(startingPlayerId)) { diff --git a/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java b/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java new file mode 100644 index 00000000000..06720ca1eaf --- /dev/null +++ b/Mage/src/mage/watchers/common/CastSpellLastTurnWatcher.java @@ -0,0 +1,76 @@ +/* + * 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 mage.watchers.common; + +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.WatcherImpl; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CastSpellLastTurnWatcher extends WatcherImpl { + + private int amountOfSpellsCastOnPrevTurn; + private int amountOfSpellsCastOnCurrentTurn; + + public CastSpellLastTurnWatcher() { + super("CastSpellLastTurnWatcher"); + } + + public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) { + super(watcher); + this.amountOfSpellsCastOnCurrentTurn = watcher.amountOfSpellsCastOnCurrentTurn; + this.amountOfSpellsCastOnPrevTurn = watcher.amountOfSpellsCastOnPrevTurn; + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.SPELL_CAST) { + amountOfSpellsCastOnCurrentTurn++; + } + } + + @Override + public void reset() { + amountOfSpellsCastOnPrevTurn = amountOfSpellsCastOnCurrentTurn; + amountOfSpellsCastOnCurrentTurn = 0; + } + + public int getAmountOfSpellsCastOnPrevTurn() { + return amountOfSpellsCastOnPrevTurn; + } + + @Override + public CastSpellLastTurnWatcher copy() { + return new CastSpellLastTurnWatcher(this); + } + +}