diff --git a/Mage.Sets/src/mage/sets/magic2012/BloodOgre.java b/Mage.Sets/src/mage/sets/magic2012/BloodOgre.java new file mode 100644 index 0000000000..746638dcaf --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2012/BloodOgre.java @@ -0,0 +1,68 @@ +/* + * 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.sets.magic2012; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.keyword.BloodthirstAbility; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.cards.CardImpl; +import mage.watchers.common.BloodthirstWatcher; + +/** + * + * @author Loki + */ +public class BloodOgre extends CardImpl { + + public BloodOgre(UUID ownerId) { + super(ownerId, 122, "Blood Ogre", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{R}"); + this.expansionSetCode = "M12"; + this.subtype.add("Ogre"); + this.subtype.add("Warrior"); + this.color.setRed(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + this.addAbility(new BloodthirstAbility(1)); + this.watchers.add(new BloodthirstWatcher(ownerId)); + // Bloodthirst 1 + this.addAbility(FirstStrikeAbility.getInstance()); + } + + public BloodOgre(final BloodOgre card) { + super(card); + } + + @Override + public BloodOgre copy() { + return new BloodOgre(this); + } +} diff --git a/Mage/src/mage/abilities/keyword/BloodthirstAbility.java b/Mage/src/mage/abilities/keyword/BloodthirstAbility.java index 4ba140b8a8..b60e7f4266 100644 --- a/Mage/src/mage/abilities/keyword/BloodthirstAbility.java +++ b/Mage/src/mage/abilities/keyword/BloodthirstAbility.java @@ -4,32 +4,61 @@ import mage.Constants; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.effects.OneShotEffect; +import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.watchers.WatcherImpl; - -import java.util.UUID; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; /** + * This ability depends on BloodthirstWather installed on source card * @author Loki */ public class BloodthirstAbility extends EntersBattlefieldAbility { - public BloodthirstAbility() { - super(new BloodthirstEffect(), ""); + private int amount; + + public BloodthirstAbility(int amount) { + super(new BloodthirstEffect(amount), ""); + this.amount = amount; + } + + public BloodthirstAbility(final BloodthirstAbility ability) { + super(ability); + this.amount = ability.amount; + } + + @Override + public EntersBattlefieldAbility copy() { + return new BloodthirstAbility(this); + } + + @Override + public String getRule() { + return "Bloodthirst " + amount; } } class BloodthirstEffect extends OneShotEffect { - BloodthirstEffect() { + private int amount; + + BloodthirstEffect(int amount) { super(Constants.Outcome.BoostCreature); + this.amount = amount; } BloodthirstEffect(final BloodthirstEffect effect) { super(effect); + this.amount = effect.amount; } @Override public boolean apply(Game game, Ability source) { + Watcher watcher = game.getState().getWatchers().get(source.getControllerId(), "DamagedOpponents"); + if (watcher.conditionMet()) { + Permanent p = game.getPermanent(source.getSourceId()); + if (p != null) { + p.addCounters(CounterType.P1P1.createInstance(amount)); + } + } return false; } @@ -39,22 +68,3 @@ class BloodthirstEffect extends OneShotEffect { } } -class BloodthirstWatcher extends WatcherImpl { - BloodthirstWatcher(UUID controllerId) { - super("", controllerId); - } - - BloodthirstWatcher(final BloodthirstWatcher watcher) { - super(watcher); - } - - @Override - public void watch(GameEvent event, Game game) { - //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public BloodthirstWatcher copy() { - return new BloodthirstWatcher(this); - } -} \ No newline at end of file diff --git a/Mage/src/mage/watchers/common/BloodthirstWatcher.java b/Mage/src/mage/watchers/common/BloodthirstWatcher.java new file mode 100644 index 0000000000..66a6136e32 --- /dev/null +++ b/Mage/src/mage/watchers/common/BloodthirstWatcher.java @@ -0,0 +1,37 @@ +package mage.watchers.common; + +import mage.game.Game; +import mage.game.events.DamagedPlayerEvent; +import mage.game.events.GameEvent; +import mage.watchers.WatcherImpl; + +import java.util.UUID; + +/** + * Must be installed to card for proper Bloodthirst work + * @author Loki + */ +public class BloodthirstWatcher extends WatcherImpl { + public BloodthirstWatcher(UUID controllerId) { + super("DamagedOpponents", controllerId); + } + + public BloodthirstWatcher(final BloodthirstWatcher watcher) { + super(watcher); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { + DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event; + if (game.getOpponents(this.controllerId).contains(damageEvent.getPlayerId())) { + condition = true; + } + } + } + + @Override + public BloodthirstWatcher copy() { + return new BloodthirstWatcher(this); + } +}