From fa635acab8ea816ee4d4b3afa70f5103b8a099fa Mon Sep 17 00:00:00 2001 From: LevelX Date: Wed, 21 Dec 2011 19:43:15 +0100 Subject: [PATCH] [CHK] General's Kabuto, Hair-Strung Koto EquipAbility - Added constructor with filter for equipments with equip restriction (Konda's Banner), fixed missing mana output for equip costs (please check if ok) --- .../championsofkamigawa/GeneralsKabuto.java | 146 ++++++++++++++++++ .../championsofkamigawa/HairStrungKoto.java | 81 ++++++++++ .../mage/abilities/keyword/EquipAbility.java | 10 +- 3 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/championsofkamigawa/GeneralsKabuto.java create mode 100644 Mage.Sets/src/mage/sets/championsofkamigawa/HairStrungKoto.java diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/GeneralsKabuto.java b/Mage.Sets/src/mage/sets/championsofkamigawa/GeneralsKabuto.java new file mode 100644 index 00000000000..1cdd9cd4a0d --- /dev/null +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/GeneralsKabuto.java @@ -0,0 +1,146 @@ +/* + * 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.championsofkamigawa; + +/** + * + * @author Ludwig + */ +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.abilities.keyword.ShroudAbility; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; + +/** + * + * @author Loki + */ +public class GeneralsKabuto extends CardImpl { + + public GeneralsKabuto (UUID ownerId) { + super(ownerId, 251, "General's Kabuto", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}"); + this.expansionSetCode = "CHK"; + this.subtype.add("Equipment"); + + // Equipped creature has shroud. (It can't be the target of spells or abilities.) + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ShroudAbility.getInstance(), Constants.AttachmentType.EQUIPMENT))); + + // Prevent all combat damage that would be dealt to equipped creature + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GeneralsKabutoEffect())); + + // Equip {2} + this.addAbility(new EquipAbility(Outcome.PreventDamage, new GenericManaCost(2))); + } + + public GeneralsKabuto (final GeneralsKabuto card) { + super(card); + } + + @Override + public GeneralsKabuto copy() { + return new GeneralsKabuto(this); + } +} + +class GeneralsKabutoEffect extends PreventionEffectImpl { + + public GeneralsKabutoEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Prevent all combat damage that would be dealt to equipped creature"; + } + + public GeneralsKabutoEffect(final GeneralsKabutoEffect effect) { + super(effect); + } + + @Override + public GeneralsKabutoEffect copy() { + return new GeneralsKabutoEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + GameEvent preventEvent = new GameEvent( + GameEvent.EventType.PREVENT_DAMAGE, + source.getFirstTarget(), + source.getId(), + source.getControllerId(), + event.getAmount(), + false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + game.fireEvent(GameEvent.getEvent( + GameEvent.EventType.PREVENTED_DAMAGE, + source.getFirstTarget(), + source.getId(), + source.getControllerId(), + damage)); + } + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (super.applies(event, source, game) && event instanceof DamageEvent) { + DamageEvent damageEvent = (DamageEvent) event; + if (damageEvent.isCombatDamage()) { + Permanent aura = game.getPermanent(source.getSourceId()); + if (aura != null && aura.getAttachedTo() != null) { + if (event.getTargetId().equals(aura.getAttachedTo())) { + return true; + } + } + } + } + return false; + } + +} + diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HairStrungKoto.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HairStrungKoto.java new file mode 100644 index 00000000000..0b83661bbce --- /dev/null +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HairStrungKoto.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.sets.championsofkamigawa; + +import java.util.UUID; + +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.target.TargetPlayer; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author LevelX + */ +public class HairStrungKoto extends CardImpl { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creature you control"); + + static { + filter.setTapped(false); + filter.setUseTapped(true); + } + + public HairStrungKoto (UUID ownerId) { + super(ownerId, 252, "Hair-Strung Koto", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{6}"); + this.expansionSetCode = "CHK"; + + /* Tap an untapped creature you control: Target player puts the top + * card of his or her library into his or her graveyard. + */ + SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new PutLibraryIntoGraveTargetEffect(1), + new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, false))); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + public HairStrungKoto (final HairStrungKoto card) { + super(card); + } + + @Override + public HairStrungKoto copy() { + return new HairStrungKoto(this); + } + +} diff --git a/Mage/src/mage/abilities/keyword/EquipAbility.java b/Mage/src/mage/abilities/keyword/EquipAbility.java index eec54b66fe2..a78a46e6cc2 100644 --- a/Mage/src/mage/abilities/keyword/EquipAbility.java +++ b/Mage/src/mage/abilities/keyword/EquipAbility.java @@ -34,6 +34,7 @@ import mage.Constants.Zone; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.Cost; import mage.abilities.effects.common.AttachEffect; +import mage.target.Target; import mage.target.common.TargetControlledCreaturePermanent; /** @@ -43,10 +44,15 @@ import mage.target.common.TargetControlledCreaturePermanent; public class EquipAbility extends ActivatedAbilityImpl { public EquipAbility(Outcome outcome, Cost cost) { + this(outcome, cost, new TargetControlledCreaturePermanent()); + } + + public EquipAbility(Outcome outcome, Cost cost, Target target) { super(Zone.BATTLEFIELD, new AttachEffect(outcome, "Equip"), cost); - this.addTarget(new TargetControlledCreaturePermanent()); + this.addTarget(target); this.timing = TimingRule.SORCERY; } + public EquipAbility(final EquipAbility ability) { super(ability); @@ -59,7 +65,7 @@ public class EquipAbility extends ActivatedAbilityImpl { @Override public String getRule() { - return "Equip " + costs.getText(); + return "Equip " + costs.getText() + manaCosts.getText(); } }