From d63cdfd131626c980360deb3f5a842d087dbf098 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Mon, 19 Sep 2011 10:08:54 -0400 Subject: [PATCH] NPH - Spinebiter --- .../src/mage/sets/newphyrexia/Spinebiter.java | 67 ++++++++++++++++ .../DamageAsThoughNotBlockedAbility.java | 65 +++++++++++++++ Mage/src/mage/game/combat/CombatGroup.java | 80 +++++++++++-------- 3 files changed, 178 insertions(+), 34 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/newphyrexia/Spinebiter.java create mode 100644 Mage/src/mage/abilities/common/DamageAsThoughNotBlockedAbility.java diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Spinebiter.java b/Mage.Sets/src/mage/sets/newphyrexia/Spinebiter.java new file mode 100644 index 0000000000..76fe4cf0a2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/newphyrexia/Spinebiter.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.sets.newphyrexia; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.DamageAsThoughNotBlockedAbility; +import mage.abilities.keyword.InfectAbility; +import mage.cards.CardImpl; + +/** + * + * @author BetaSteward + */ +public class Spinebiter extends CardImpl { + + public Spinebiter(UUID ownerId) { + super(ownerId, 121, "Spinebiter", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{4}{G}{G}"); + this.expansionSetCode = "NPH"; + this.subtype.add("Beast"); + + this.color.setGreen(true); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + this.addAbility(InfectAbility.getInstance()); + + // You may have Spinebiter assign its combat damage as though it weren't blocked. + this.addAbility(DamageAsThoughNotBlockedAbility.getInstance()); + } + + public Spinebiter(final Spinebiter card) { + super(card); + } + + @Override + public Spinebiter copy() { + return new Spinebiter(this); + } +} diff --git a/Mage/src/mage/abilities/common/DamageAsThoughNotBlockedAbility.java b/Mage/src/mage/abilities/common/DamageAsThoughNotBlockedAbility.java new file mode 100644 index 0000000000..695c5d231c --- /dev/null +++ b/Mage/src/mage/abilities/common/DamageAsThoughNotBlockedAbility.java @@ -0,0 +1,65 @@ +/* + * Copyright 2011 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.common; + +import java.io.ObjectStreamException; +import mage.abilities.StaticAbility; + + +import static mage.Constants.*; + +/** + * @author BetaSteward + */ +public class DamageAsThoughNotBlockedAbility extends StaticAbility { + + private static final DamageAsThoughNotBlockedAbility fINSTANCE = new DamageAsThoughNotBlockedAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } + + public static DamageAsThoughNotBlockedAbility getInstance() { + return fINSTANCE; + } + + private DamageAsThoughNotBlockedAbility() { + super(AbilityType.STATIC, Zone.BATTLEFIELD); + } + + @Override + public String getRule() { + return "You may have {this} assign its combat damage as though it weren't blocked."; + } + + @Override + public DamageAsThoughNotBlockedAbility copy() { + return fINSTANCE; + } + +} \ No newline at end of file diff --git a/Mage/src/mage/game/combat/CombatGroup.java b/Mage/src/mage/game/combat/CombatGroup.java index 82e8d1209a..cf20183726 100644 --- a/Mage/src/mage/game/combat/CombatGroup.java +++ b/Mage/src/mage/game/combat/CombatGroup.java @@ -30,13 +30,13 @@ package mage.game.combat; import java.io.Serializable; import java.util.*; +import mage.Constants.Outcome; +import mage.abilities.common.DamageAsThoughNotBlockedAbility; import mage.abilities.keyword.DeathtouchAbility; import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.TrampleAbility; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -148,15 +148,25 @@ public class CombatGroup implements Serializable, Copyable { public void assignDamageToBlockers(boolean first, Game game) { if (attackers.size() > 0 && (!first || hasFirstOrDoubleStrike(game))) { - if (blockers.size() == 0) { + if (blockers.isEmpty()) { unblockedDamage(first, game); } - else if (blockers.size() == 1) { - singleBlockerDamage(first, game); - } - else { - multiBlockerDamage(first, game); - } + else { + Permanent attacker = game.getPermanent(attackers.get(0)); + if (attacker.getAbilities().containsKey(DamageAsThoughNotBlockedAbility.getInstance().getId())) { + Player player = game.getPlayer(attacker.getControllerId()); + if (player.chooseUse(Outcome.Damage, "Do you wish to assign damage for " + attacker.getName() + " as though it weren't blocked?", game)) { + blocked = false; + unblockedDamage(first, game); + } + } + if (blockers.size() == 1) { + singleBlockerDamage(first, game); + } + else { + multiBlockerDamage(first, game); + } + } } } @@ -228,7 +238,7 @@ public class CombatGroup implements Serializable, Copyable { Permanent blocker = game.getPermanent(blockers.get(0)); Permanent attacker = game.getPermanent(attackers.get(0)); if (blocker != null && attacker != null) { - if (canDamage(attacker, first)) { + if (blocked && canDamage(attacker, first)) { int damage = attacker.getPower().getValue(); if (hasTrample(attacker)) { int lethalDamage = blocker.getToughness().getValue() - blocker.getDamage(); @@ -266,30 +276,32 @@ public class CombatGroup implements Serializable, Copyable { Player player = game.getPlayer(attacker.getControllerId()); int damage = attacker.getPower().getValue(); if (canDamage(attacker, first)) { - Map assigned = new HashMap(); - for (UUID blockerId: blockerOrder) { - Permanent blocker = game.getPermanent(blockerId); - int lethalDamage; - if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) - lethalDamage = 1; - else - lethalDamage = blocker.getToughness().getValue() - blocker.getDamage(); - if (lethalDamage >= damage) { - // Issue#73 - //blocker.damage(damage, attacker.getId(), game, true, true); - assigned.put(blockerId, damage); - damage = 0; - break; - } - int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game); - // Issue#73 - //blocker.damage(damageAssigned, attacker.getId(), game, true, true); - assigned.put(blockerId, damageAssigned); - damage -= damageAssigned; - } - if (damage > 0 && hasTrample(attacker)) { - defenderDamage(attacker, damage, game); - } + Map assigned = new HashMap(); + if (blocked) { + for (UUID blockerId: blockerOrder) { + Permanent blocker = game.getPermanent(blockerId); + int lethalDamage; + if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) + lethalDamage = 1; + else + lethalDamage = blocker.getToughness().getValue() - blocker.getDamage(); + if (lethalDamage >= damage) { + // Issue#73 + //blocker.damage(damage, attacker.getId(), game, true, true); + assigned.put(blockerId, damage); + damage = 0; + break; + } + int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game); + // Issue#73 + //blocker.damage(damageAssigned, attacker.getId(), game, true, true); + assigned.put(blockerId, damageAssigned); + damage -= damageAssigned; + } + if (damage > 0 && hasTrample(attacker)) { + defenderDamage(attacker, damage, game); + } + } for (UUID blockerId: blockerOrder) { Permanent blocker = game.getPermanent(blockerId); if (canDamage(blocker, first)) {