Merge pull request #5137 from NoahGleason/predatory-focus

Implement Predatory Focus
This commit is contained in:
LevelX2 2018-07-13 12:34:18 +02:00 committed by GitHub
commit b628ac1f10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 136 additions and 17 deletions

View file

@ -0,0 +1,81 @@
package mage.cards.p;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffect;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author noahg
*/
public final class PredatoryFocus extends CardImpl {
public PredatoryFocus(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{G}");
// You may have creatures you control assign their combat damage this turn as though they weren't blocked.
this.getSpellAbility().addEffect(new PredatoryFocusEffect());
}
public PredatoryFocus(final PredatoryFocus card) {
super(card);
}
@Override
public PredatoryFocus copy() {
return new PredatoryFocus(this);
}
}
class PredatoryFocusEffect extends AsThoughEffectImpl {
private boolean choseUse;
public PredatoryFocusEffect() {
super(AsThoughEffectType.DAMAGE_NOT_BLOCKED, Duration.EndOfTurn, Outcome.Damage);
this.staticText = "You may have creatures you control assign their combat damage this turn as though they weren't blocked.";
}
public PredatoryFocusEffect(PredatoryFocusEffect effect) {
super(effect);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player controller = game.getPlayer(source.getControllerId());
String sourceName = source.getSourceObject(game).getLogName();
choseUse = controller.chooseUse(Outcome.Damage, "Have creatures you control deal combat damage this turn" +
" as though they weren't blocked?", source, game);
game.informPlayers(choseUse ? controller.getName()+" chose to use "+sourceName+"'s effect" :
controller.getName()+" chose not to use "+sourceName+"'s effect.");
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
return choseUse && affectedControllerId.equals(source.getControllerId());
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public PredatoryFocusEffect copy() {
return new PredatoryFocusEffect(this);
}
}

View file

@ -3,19 +3,21 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DamageAsThoughNotBlockedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.SourceAttackingCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -34,15 +36,9 @@ public final class SiegeBehemoth extends CardImpl {
// Hexproof
this.addAbility(HexproofAbility.getInstance());
// As long as Siege Behemoth is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked.
// TODO: DamageAsThoughNotBlockedAbility should be done by rule modifying effect instead of adding ability (if controlled creature looses all abilities it should'nt loose this effect)
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new ConditionalContinuousEffect(
new GainAbilityControlledEffect(DamageAsThoughNotBlockedAbility.getInstance(), Duration.WhileOnBattlefield, filter),
SourceAttackingCondition.instance,
"As long as {this} is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked"
)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SiegeBehemothEffect()));
}
public SiegeBehemoth(final SiegeBehemoth card) {
@ -54,3 +50,39 @@ public final class SiegeBehemoth extends CardImpl {
return new SiegeBehemoth(this);
}
}
class SiegeBehemothEffect extends AsThoughEffectImpl {
public SiegeBehemothEffect() {
super(AsThoughEffectType.DAMAGE_NOT_BLOCKED, Duration.WhileOnBattlefield, Outcome.Damage);
this.staticText = "As long as {this} is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked";
}
public SiegeBehemothEffect(SiegeBehemothEffect effect) {
super(effect);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent != null && sourcePermanent.isAttacking()){
Player controller = game.getPlayer(source.getControllerId());
Permanent otherCreature = game.getPermanent(sourceId);
if (controller != null && otherCreature != null && otherCreature.isControlledBy(controller.getId())){
return controller.chooseUse(Outcome.Damage, "Do you wish to assign damage for "
+ otherCreature.getLogName() + " as though it weren't blocked?", source, game);
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public SiegeBehemothEffect copy() {
return new SiegeBehemothEffect(this);
}
}

View file

@ -130,6 +130,7 @@ public final class Guildpact extends ExpansionSet {
cards.add(new SetCardInfo("Pillory of the Sleepless", 125, Rarity.COMMON, mage.cards.p.PilloryOfTheSleepless.class));
cards.add(new SetCardInfo("Plagued Rusalka", 56, Rarity.UNCOMMON, mage.cards.p.PlaguedRusalka.class));
cards.add(new SetCardInfo("Poisonbelly Ogre", 57, Rarity.COMMON, mage.cards.p.PoisonbellyOgre.class));
cards.add(new SetCardInfo("Predatory Focus", 92, Rarity.UNCOMMON, mage.cards.p.PredatoryFocus.class));
cards.add(new SetCardInfo("Primeval Light", 93, Rarity.UNCOMMON, mage.cards.p.PrimevalLight.class));
cards.add(new SetCardInfo("Pyromatics", 72, Rarity.COMMON, mage.cards.p.Pyromatics.class));
cards.add(new SetCardInfo("Quicken", 31, Rarity.RARE, mage.cards.q.Quicken.class));

View file

@ -18,6 +18,7 @@ public enum AsThoughEffectType {
BLOCK_SWAMPWALK,
BLOCK_MOUNTAINWALK,
BLOCK_FORESTWALK,
DAMAGE_NOT_BLOCKED,
BE_BLOCKED,
PLAY_FROM_NOT_OWN_HAND_ZONE,
CAST_AS_INSTANT,

View file

@ -12,6 +12,7 @@ import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.constants.AsThoughEffectType;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.game.Game;
@ -124,11 +125,14 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
return;
} else {
Player player = game.getPlayer(defenderAssignsCombatDamage(game) ? defendingPlayerId : attacker.getControllerId());
if (attacker.getAbilities().containsKey(DamageAsThoughNotBlockedAbility.getInstance().getId())) { // for handling creatures like Thorn Elemental
if (player.chooseUse(Outcome.Damage, "Do you wish to assign damage for " + attacker.getLogName() + " as though it weren't blocked?", null, game)) {
blocked = false;
unblockedDamage(first, game);
}
if ((attacker.getAbilities().containsKey(DamageAsThoughNotBlockedAbility.getInstance().getId()) &&
player.chooseUse(Outcome.Damage, "Do you wish to assign damage for "
+ attacker.getLogName() + " as though it weren't blocked?", null, game)) ||
game.getContinuousEffects().asThough(attacker.getId(), AsThoughEffectType.DAMAGE_NOT_BLOCKED
, null, attacker.getControllerId(), game) != null) {
// for handling creatures like Thorn Elemental
blocked = false;
unblockedDamage(first, game);
}
if (blockers.size() == 1) {
singleBlockerDamage(player, first, game);