From 42c28883409c246e895158541f7a7fbd21527ed5 Mon Sep 17 00:00:00 2001 From: Loki Date: Sun, 27 Feb 2011 21:19:07 +0200 Subject: [PATCH] MBS and improvements --- .../sets/scarsofmirrodin/MolderBeast.java | 102 ++++++++++++++++++ .../sets/scarsofmirrodin/ViridianRevel.java | 96 +++++++++++++++++ .../condition/common/HaveCounter.java | 19 ++++ .../continious/GainAbilityTargetEffect.java | 16 ++- .../counter/AddCountersTargetEffect.java | 19 ++-- Mage/src/mage/counters/CounterType.java | 5 +- .../counters/common/AwakeningCounter.java | 14 +++ Utils/cardclass.tmpl | 6 +- Utils/gen-card.pl | 1 + 9 files changed, 258 insertions(+), 20 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/MolderBeast.java create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/ViridianRevel.java create mode 100644 Mage/src/mage/abilities/condition/common/HaveCounter.java create mode 100644 Mage/src/mage/counters/common/AwakeningCounter.java diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/MolderBeast.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/MolderBeast.java new file mode 100644 index 0000000000..bb6110fc94 --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/MolderBeast.java @@ -0,0 +1,102 @@ +/* + * 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.scarsofmirrodin; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; + +/** + * + * @author Loki + */ +public class MolderBeast extends CardImpl { + + public MolderBeast (UUID ownerId) { + super(ownerId, 125, "Molder Beast", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{G}"); + this.expansionSetCode = "SOM"; + this.subtype.add("Beast"); + this.color.setGreen(true); + this.power = new MageInt(5); + this.toughness = new MageInt(3); + this.addAbility(new MolderBeastTriggeredAbility()); + } + + public MolderBeast (final MolderBeast card) { + super(card); + } + + @Override + public MolderBeast copy() { + return new MolderBeast(this); + } + +} + +class MolderBeastTriggeredAbility extends TriggeredAbilityImpl { + MolderBeastTriggeredAbility() { + super(Constants.Zone.BATTLEFIELD, new BoostSourceEffect(2, 0, Constants.Duration.EndOfTurn)); + } + + MolderBeastTriggeredAbility(final MolderBeastTriggeredAbility ability) { + super(ability); + } + + @Override + public MolderBeastTriggeredAbility copy() { + return new MolderBeastTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD && zEvent.getTarget().getCardType().contains(CardType.ARTIFACT)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever an artifact is put into a graveyard from the battlefield, Molder Beast gets +2/+0 until end of turn."; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/ViridianRevel.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/ViridianRevel.java new file mode 100644 index 0000000000..7caf1e26f3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/ViridianRevel.java @@ -0,0 +1,96 @@ +/* + * 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.scarsofmirrodin; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; + +/** + * + * @author Loki + */ +public class ViridianRevel extends CardImpl { + + public ViridianRevel (UUID ownerId) { + super(ownerId, 132, "Viridian Revel", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}{G}"); + this.expansionSetCode = "SOM"; + this.color.setGreen(true); + this.addAbility(new ViridianRevelTriggeredAbility()); + } + + public ViridianRevel (final ViridianRevel card) { + super(card); + } + + @Override + public ViridianRevel copy() { + return new ViridianRevel(this); + } +} + +class ViridianRevelTriggeredAbility extends TriggeredAbilityImpl { + ViridianRevelTriggeredAbility() { + super(Constants.Zone.BATTLEFIELD, new DrawCardControllerEffect(1), true); + } + + ViridianRevelTriggeredAbility(final ViridianRevelTriggeredAbility ability) { + super(ability); + } + + @Override + public ViridianRevelTriggeredAbility copy() { + return new ViridianRevelTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever an artifact is put into an opponent's graveyard from the battlefield, you may draw a card."; + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/condition/common/HaveCounter.java b/Mage/src/mage/abilities/condition/common/HaveCounter.java new file mode 100644 index 0000000000..eb304fd140 --- /dev/null +++ b/Mage/src/mage/abilities/condition/common/HaveCounter.java @@ -0,0 +1,19 @@ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.counters.CounterType; +import mage.game.Game; + +public class HaveCounter implements Condition { + private CounterType counterType; + + public HaveCounter(CounterType type) { + this.counterType = type; + } + + @Override + public boolean apply(Game game, Ability source) { + return game.getPermanent(source.getSourceId()).getCounters().getCount(counterType) > 0; + } +} diff --git a/Mage/src/mage/abilities/effects/common/continious/GainAbilityTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/GainAbilityTargetEffect.java index a80b6707b5..e81fba46ee 100644 --- a/Mage/src/mage/abilities/effects/common/continious/GainAbilityTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/GainAbilityTargetEffect.java @@ -37,6 +37,8 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -62,15 +64,19 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getFirstTarget()); - if (permanent != null) { - permanent.addAbility(ability.copy()); - return true; + int affectedTargets = 0; + for (UUID permanentId : source.getTargets().get(0).getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null) { + permanent.addAbility(ability.copy()); + affectedTargets++; + } } - return false; + return affectedTargets > 0; } @Override + //TODO redone text for multiple targets public String getText(Ability source) { StringBuilder sb = new StringBuilder(); sb.append("Target ").append(source.getTargets().get(0).getTargetName()).append(" gains "); diff --git a/Mage/src/mage/abilities/effects/common/counter/AddCountersTargetEffect.java b/Mage/src/mage/abilities/effects/common/counter/AddCountersTargetEffect.java index 4bcf51e536..7c2f8790d4 100644 --- a/Mage/src/mage/abilities/effects/common/counter/AddCountersTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/counter/AddCountersTargetEffect.java @@ -35,6 +35,8 @@ import mage.counters.Counter; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -45,12 +47,6 @@ public class AddCountersTargetEffect extends OneShotEffect 0; } @Override diff --git a/Mage/src/mage/counters/CounterType.java b/Mage/src/mage/counters/CounterType.java index 4942c8596c..1f848309c5 100644 --- a/Mage/src/mage/counters/CounterType.java +++ b/Mage/src/mage/counters/CounterType.java @@ -46,7 +46,8 @@ public enum CounterType { FEATHER(new FeatherCounter().name), QUEST(new QuestCounter().name), ARROWHEAD(new ArrowheadCounter().name), - EON(new EonCounter().name); + EON(new EonCounter().name), + AWAKENING(new AwakeningCounter().name); private String name; @@ -102,6 +103,8 @@ public enum CounterType { return new ArrowheadCounter(amount); case EON: return new EonCounter(amount); + case AWAKENING: + return new AwakeningCounter(amount); } return null; } diff --git a/Mage/src/mage/counters/common/AwakeningCounter.java b/Mage/src/mage/counters/common/AwakeningCounter.java new file mode 100644 index 0000000000..9fa9aee26f --- /dev/null +++ b/Mage/src/mage/counters/common/AwakeningCounter.java @@ -0,0 +1,14 @@ +package mage.counters.common; + +import mage.counters.Counter; + +public class AwakeningCounter extends Counter { + public AwakeningCounter() { + this(1); + } + + public AwakeningCounter(int amount) { + super("Awakening"); + this.count = amount; + } +} diff --git a/Utils/cardclass.tmpl b/Utils/cardclass.tmpl index 0f99c7ed4b..f0e6171d8b 100644 --- a/Utils/cardclass.tmpl +++ b/Utils/cardclass.tmpl @@ -30,9 +30,7 @@ package mage.sets.[=$longset=]; import java.util.UUID; import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Rarity; -import mage.Constants.Zone;[= if (defined($power)) {$OUT .= "\nimport mage.MageInt;"}=] +import mage.Constants.Rarity;[= if (defined($power)) {$OUT .= "\nimport mage.MageInt;"}=] import mage.cards.CardImpl; /** @@ -48,7 +46,7 @@ public class [=$classname=] extends CardImpl<[=$classname=]> { [=if (defined($power)) { $OUT .= "this.power = new MageInt($power);\n"; }=][=if (defined($toughness)) { - $OUT .= " this.toughness = new MageInt($toughness);"; + $OUT .= " this.toughness = new MageInt($toughness);"; }=] } diff --git a/Utils/gen-card.pl b/Utils/gen-card.pl index 9949940f0a..1ffc7fa511 100755 --- a/Utils/gen-card.pl +++ b/Utils/gen-card.pl @@ -365,6 +365,7 @@ foreach my $div (@divs) { } } if ($id =~m/currentSetSymbol/) { + print "*** " . $div->as_HTML(); my ($imgurl) = $div->look_down('_tag', 'img'); $imgurl->attr('src') =~m/set=(\w+)\&.*rarity=(\w+)/; my $multiverseid = $multiverses[0];