From 9b1388b322ba04ddb2b9325756f8ceeee4504062 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 1 Sep 2014 19:28:06 +0200 Subject: [PATCH] [KTK] Added Raid-, Prowess-, and Outlast ability. Added FerociousCondition. --- .../MinamoSightbender.java | 7 -- .../src/mage/sets/gatecrash/RustScarab.java | 5 -- .../mage/sets/lorwyn/WindbriskHeights.java | 45 +--------- .../src/mage/sets/prophecy/AvatarOfHope.java | 9 +- .../abilities/abilityword/RaidAbility.java | 81 ++++++++++++++++++ .../condition/common/FerociousCondition.java | 63 ++++++++++++++ .../costs/common/ExileFromGraveCost.java | 2 +- .../common/AddManaToManaPoolEffect.java | 6 ++ .../abilities/keyword/OutlastAbility.java | 67 +++++++++++++++ .../abilities/keyword/ProwessAbility.java | 69 +++++++++++++++ .../common/PlayerAttackedWatcher.java | 83 +++++++++++++++++++ Utils/keywords.txt | 3 + 12 files changed, 383 insertions(+), 57 deletions(-) create mode 100644 Mage/src/mage/abilities/abilityword/RaidAbility.java create mode 100644 Mage/src/mage/abilities/condition/common/FerociousCondition.java create mode 100644 Mage/src/mage/abilities/keyword/OutlastAbility.java create mode 100644 Mage/src/mage/abilities/keyword/ProwessAbility.java create mode 100644 Mage/src/mage/watchers/common/PlayerAttackedWatcher.java diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java index b1a17eabd6..0c4e885adf 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java @@ -33,26 +33,19 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.ActivatedAbilityImpl; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.combat.UnblockableTargetEffect; import mage.cards.CardImpl; -import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.Filter; -import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.filter.predicate.mageobject.PowerPredicate; import mage.game.Game; -import mage.players.Player; import mage.target.Target; -import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * diff --git a/Mage.Sets/src/mage/sets/gatecrash/RustScarab.java b/Mage.Sets/src/mage/sets/gatecrash/RustScarab.java index 574b2a2b29..c204ad0872 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/RustScarab.java +++ b/Mage.Sets/src/mage/sets/gatecrash/RustScarab.java @@ -69,11 +69,6 @@ public class RustScarab extends CardImpl { } - @Override - public void adjustTargets(Ability ability, Game game) { - - } - public RustScarab(final RustScarab card) { super(card); } diff --git a/Mage.Sets/src/mage/sets/lorwyn/WindbriskHeights.java b/Mage.Sets/src/mage/sets/lorwyn/WindbriskHeights.java index e2d096654e..c84430d3e2 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/WindbriskHeights.java +++ b/Mage.Sets/src/mage/sets/lorwyn/WindbriskHeights.java @@ -39,11 +39,9 @@ import mage.abilities.mana.WhiteManaAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.WatcherScope; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.watchers.Watcher; +import mage.watchers.common.PlayerAttackedWatcher; /** * @@ -65,7 +63,7 @@ public class WindbriskHeights extends CardImpl { ability.addCost(new TapSourceCost()); this.addAbility(ability); - this.addWatcher(new WindbriskHeightsWatcher()); + this.addWatcher(new PlayerAttackedWatcher()); } @@ -79,41 +77,6 @@ public class WindbriskHeights extends CardImpl { } } -class WindbriskHeightsWatcher extends Watcher { - - private int numberOfattackers; - - public WindbriskHeightsWatcher() { - super("WindbriskHeightsAttackersWatcher", WatcherScope.PLAYER); - } - - public WindbriskHeightsWatcher(final WindbriskHeightsWatcher watcher) { - super(watcher); - this.numberOfattackers = watcher.numberOfattackers; - } - - @Override - public WindbriskHeightsWatcher copy() { - return new WindbriskHeightsWatcher(this); - } - - @Override - public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(this.getControllerId())) { - numberOfattackers += game.getCombat().getAttackers().size(); // because there are more than one attack phase possible, sum up the attackers - if (numberOfattackers > 2) { - condition = true; - } - } - } - - @Override - public void reset() { - super.reset(); - numberOfattackers = 0; - } -} - class WindbriskHeightsAttackersCondition implements Condition { private static final WindbriskHeightsAttackersCondition fInstance = new WindbriskHeightsAttackersCondition(); @@ -124,8 +87,8 @@ class WindbriskHeightsAttackersCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get("WindbriskHeightsAttackersWatcher", source.getControllerId()); - return watcher != null && watcher.conditionMet(); + PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get("PlayerAttackedWatcher"); + return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) >= 3; } @Override diff --git a/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java b/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java index 2bde2c397c..4910c80aa1 100644 --- a/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java +++ b/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java @@ -49,6 +49,7 @@ import mage.players.Player; import mage.util.CardUtil; import java.util.UUID; +import mage.constants.AbilityType; import mage.constants.CostModificationType; /** @@ -106,9 +107,11 @@ class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSour @Override public void adjustCosts(Ability ability, Game game) { - Player player = game.getPlayer(ability.getControllerId()); - if (player != null && player.getLife() < 4) { - CardUtil.adjustCost((SpellAbility)ability, 6); + if (ability.getAbilityType().equals(AbilityType.SPELL)) { + Player player = game.getPlayer(ability.getControllerId()); + if (player != null && player.getLife() < 4) { + CardUtil.adjustCost((SpellAbility)ability, 6); + } } } } diff --git a/Mage/src/mage/abilities/abilityword/RaidAbility.java b/Mage/src/mage/abilities/abilityword/RaidAbility.java new file mode 100644 index 0000000000..d57acfbf08 --- /dev/null +++ b/Mage/src/mage/abilities/abilityword/RaidAbility.java @@ -0,0 +1,81 @@ +/* + * 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.abilityword; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.cards.Card; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.watchers.common.PlayerAttackedWatcher; + +/** + * + * @author LevelX2 + */ +public class RaidAbility extends TriggeredAbilityImpl { + + public RaidAbility(Card card, Effect effect) { + this(card, effect, false); + } + + public RaidAbility(Card card, Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + card.addWatcher(new PlayerAttackedWatcher()); + // this.setAbilityWord(AbilityWord.RAID); // not supported yet for rule generation + } + + public RaidAbility(final RaidAbility ability) { + super(ability); + } + + @Override + public RaidAbility copy() { + return new RaidAbility(this); + } + + @Override + public boolean checkInterveningIfClause(Game game) { + // seems unneccessary to check twice because condition can't change until effect resolves, but who knows what the future brings + PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get("PlayerAttackedWatcher"); + return watcher != null && watcher.getNumberOfAttackersCurrentTurn(getControllerId()) > 0; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return EventType.ENTERS_THE_BATTLEFIELD.equals(event.getType()) && getSourceId().equals(event.getTargetId()); + } + + @Override + public String getRule() { + return "Raid - When {this} enters the battlefield, if you attacked with a creature this turn, " + super.getRule(); + } +} diff --git a/Mage/src/mage/abilities/condition/common/FerociousCondition.java b/Mage/src/mage/abilities/condition/common/FerociousCondition.java new file mode 100644 index 0000000000..ebabb79a59 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/FerociousCondition.java @@ -0,0 +1,63 @@ +/* + * 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.filter.Filter; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.PowerPredicate; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ +public class FerociousCondition implements Condition { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + static { + filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 3)); + } + + private static final FerociousCondition fInstance = new FerociousCondition(); + + private FerociousCondition() {}; + + public static FerociousCondition getInstance() { + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + return game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0; + } + +} diff --git a/Mage/src/mage/abilities/costs/common/ExileFromGraveCost.java b/Mage/src/mage/abilities/costs/common/ExileFromGraveCost.java index e3d1fc8ed1..7dd5fef4bd 100644 --- a/Mage/src/mage/abilities/costs/common/ExileFromGraveCost.java +++ b/Mage/src/mage/abilities/costs/common/ExileFromGraveCost.java @@ -70,7 +70,7 @@ public class ExileFromGraveCost extends CostImpl { } - public ExileFromGraveCost(ExileFromGraveCost cost) { + public ExileFromGraveCost(final ExileFromGraveCost cost) { super(cost); } diff --git a/Mage/src/mage/abilities/effects/common/AddManaToManaPoolEffect.java b/Mage/src/mage/abilities/effects/common/AddManaToManaPoolEffect.java index 1cf0b52789..10b3586967 100644 --- a/Mage/src/mage/abilities/effects/common/AddManaToManaPoolEffect.java +++ b/Mage/src/mage/abilities/effects/common/AddManaToManaPoolEffect.java @@ -22,6 +22,12 @@ public class AddManaToManaPoolEffect extends OneShotEffect { protected Mana mana; + /** + * Adds mana to the mana pool of target pointer player + * + * @param mana mana that will be added to the pool + * @param textManaPoolOwner text that references to the mana pool owner (e.g. "damaged player's") + */ public AddManaToManaPoolEffect(Mana mana, String textManaPoolOwner) { super(Outcome.PutManaInPool); this.mana = mana; diff --git a/Mage/src/mage/abilities/keyword/OutlastAbility.java b/Mage/src/mage/abilities/keyword/OutlastAbility.java new file mode 100644 index 0000000000..1fda18b78a --- /dev/null +++ b/Mage/src/mage/abilities/keyword/OutlastAbility.java @@ -0,0 +1,67 @@ +/* + * 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.keyword; + +import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.constants.TimingRule; +import mage.constants.Zone; +import mage.counters.CounterType; + +/** + * + * @author LevelX2 + */ +public class OutlastAbility extends ActivatedAbilityImpl { + + public OutlastAbility(Cost cost) { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), cost); + this.addCost(new TapSourceCost()); + this.timing = TimingRule.SORCERY; + } + + public OutlastAbility(final OutlastAbility ability) { + super(ability); + } + + @Override + public OutlastAbility copy() { + return new OutlastAbility(this); + } + + @Override + public String getRule() { + StringBuilder sb = new StringBuilder("Outcast ").append(manaCosts.getText()); + sb.append(" (").append(costs.getText()).append("{T}: Put a +1/+1 counter on this creature. Outlast only as a sorcery.)").toString(); + return sb.toString(); + } + +} diff --git a/Mage/src/mage/abilities/keyword/ProwessAbility.java b/Mage/src/mage/abilities/keyword/ProwessAbility.java new file mode 100644 index 0000000000..2047fe9aec --- /dev/null +++ b/Mage/src/mage/abilities/keyword/ProwessAbility.java @@ -0,0 +1,69 @@ +/* + * 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.keyword; + +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.filter.FilterSpell; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; + +/** + * + * @author LevelX2 + */ +public class ProwessAbility extends SpellCastControllerTriggeredAbility { + + private static final FilterSpell filterNonCreatureSpell = new FilterSpell("noncreature spell"); + + static { + filterNonCreatureSpell.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); + } + + public ProwessAbility() { + super(new BoostSourceEffect(1,1,Duration.EndOfTurn), false); + this.filter = filterNonCreatureSpell; + } + + public ProwessAbility(final ProwessAbility ability) { + super(ability); + } + + @Override + public String getRule() { + return "Prowess (Whenever you cast a noncreature spell, this creature gets +1/+1 until end of turn.)"; + } + + @Override + public ProwessAbility copy() { + return new ProwessAbility(this); + } +} diff --git a/Mage/src/mage/watchers/common/PlayerAttackedWatcher.java b/Mage/src/mage/watchers/common/PlayerAttackedWatcher.java new file mode 100644 index 0000000000..9fbcd9b6ff --- /dev/null +++ b/Mage/src/mage/watchers/common/PlayerAttackedWatcher.java @@ -0,0 +1,83 @@ +/* + * 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 java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +/** + * + * @author LevelX2 + */ + +public class PlayerAttackedWatcher extends Watcher { + + // With how many creatures attacked this player this turn + private final Map playerAttacked = new HashMap<>(); + + public PlayerAttackedWatcher() { + super("PlayerAttackedWatcher", WatcherScope.GAME); + } + + public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) { + super(watcher); + for (Map.Entry entry: playerAttacked.entrySet()) { + this.playerAttacked.put(entry.getKey(), entry.getValue()); + + } + } + + @Override + public PlayerAttackedWatcher copy() { + return new PlayerAttackedWatcher(this); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DECLARED_ATTACKERS) { + int numberAttackers = playerAttacked.containsKey(event.getPlayerId()) ? playerAttacked.get(event.getPlayerId()) : 0; + playerAttacked.put(event.getPlayerId(), numberAttackers + game.getCombat().getAttackers().size()); + } + } + + @Override + public void reset() { + super.reset(); + playerAttacked.clear(); + } + + public int getNumberOfAttackersCurrentTurn(UUID playerId) { + return playerAttacked.containsKey(playerId) ? playerAttacked.get(playerId) : 0; + } +} diff --git a/Utils/keywords.txt b/Utils/keywords.txt index 3ce42e8bd4..64755498c4 100644 --- a/Utils/keywords.txt +++ b/Utils/keywords.txt @@ -8,6 +8,7 @@ Cascade|new| Cumulative upkeep|cost| Cycling|cost| Deathtouch|instance| +Delve|new| Dethrone|new| Defender|instance| Double Strike|instance| @@ -38,11 +39,13 @@ Miracle|cost| Mountaincycling|cost| Mountainwalk|new| Morph|card, cost| +Outlast|cost| Persist|new| Phasing|instance| Plainscycling|cost| Plainswalk|new| Provoke|new| +Prowess|new| Reach|instance| Rebound|new| Scavenge|cost|