mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
* Stinkdrinker Bandit - Fixed triggered ability only triggering for controlled creatures now.
This commit is contained in:
parent
a796fe5adb
commit
6458a95912
3 changed files with 66 additions and 34 deletions
|
@ -29,22 +29,20 @@ package mage.sets.morningtide;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.abilities.keyword.ProwlAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.common.SimpleTriggeredAbility;
|
||||
import mage.abilities.effects.common.continuous.BoostControlledEffect;
|
||||
import mage.abilities.keyword.ProwlAbility;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.filter.predicate.permanent.BlockedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,30 +50,20 @@ import mage.game.events.GameEvent;
|
|||
*/
|
||||
public class StinkdrinkerBandit extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Attacking and unblocked Rogues");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Rogue"));
|
||||
filter.add(new AttackingPredicate());
|
||||
filter.add(Predicates.not(new BlockedPredicate()));
|
||||
}
|
||||
|
||||
public StinkdrinkerBandit(UUID ownerId) {
|
||||
super(ownerId, 80, "Stinkdrinker Bandit", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{B}");
|
||||
this.expansionSetCode = "MOR";
|
||||
this.subtype.add("Goblin");
|
||||
this.subtype.add("Rogue");
|
||||
|
||||
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
|
||||
// Prowl {1}, {B} (You may cast this for its prowl cost if you dealt combat damage to a player this turn with a Goblin or Rogue.)
|
||||
this.addAbility(new ProwlAbility(this, "{1}{B}"));
|
||||
|
||||
|
||||
// Whenever a Rogue you control attacks and isn't blocked, it gets +2/+1 until end of turn.
|
||||
Effect effect = new BoostControlledEffect(2,1,Duration.EndOfTurn, filter);
|
||||
Ability ability = new SimpleTriggeredAbility(Zone.BATTLEFIELD, GameEvent.EventType.DECLARED_BLOCKERS, effect, "Whenever a Rogue you control attacks and isn't blocked,");
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new StinkdrinkerBanditTriggeredAbility());
|
||||
}
|
||||
|
||||
public StinkdrinkerBandit(final StinkdrinkerBandit card) {
|
||||
|
@ -86,4 +74,42 @@ public class StinkdrinkerBandit extends CardImpl {
|
|||
public StinkdrinkerBandit copy() {
|
||||
return new StinkdrinkerBandit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StinkdrinkerBanditTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public StinkdrinkerBanditTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new BoostTargetEffect(2, 1, Duration.EndOfTurn));
|
||||
}
|
||||
|
||||
public StinkdrinkerBanditTriggeredAbility(final StinkdrinkerBanditTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StinkdrinkerBanditTriggeredAbility copy() {
|
||||
return new StinkdrinkerBanditTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(EventType.UNBLOCKED_ATTACKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent attackingCreature = game.getPermanent(event.getTargetId());
|
||||
if (attackingCreature != null && attackingCreature.hasSubtype("Rogue")) {
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a Rogue you control attacks and isn't blocked, it gets +2/+1 until end of turn.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
|
@ -415,6 +416,12 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_BLOCKERS, attackerId, attackerId))) {
|
||||
game.getCombat().selectBlockers(null, game);
|
||||
}
|
||||
for (UUID attackingCreatureID : game.getCombat().getAttackers()) {
|
||||
Permanent permanent = game.getPermanent(attackingCreatureID);
|
||||
if (permanent != null && permanent.getBlocking() == 0) {
|
||||
game.fireEvent(GameEvent.getEvent(EventType.UNBLOCKED_ATTACKER, attackingCreatureID, attackerId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -822,8 +829,8 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
// the creature is blocking a forcing attacker, so the block is ok
|
||||
blockIsValid = true;
|
||||
break CombatGroups;
|
||||
} else {
|
||||
// check if the blocker blocks a attacker that must be blocked at least by one and is the only blocker, this block is also valid
|
||||
} else // check if the blocker blocks a attacker that must be blocked at least by one and is the only blocker, this block is also valid
|
||||
{
|
||||
if (combatGroup.getBlockers().size() == 1) {
|
||||
if (mustBeBlockedByAtLeastOne.containsKey(forcingAttackerId)) {
|
||||
if (mustBeBlockedByAtLeastOne.get(forcingAttackerId).contains(creatureForcedToBlock.getId())) {
|
||||
|
@ -910,7 +917,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
* @return
|
||||
*/
|
||||
public boolean checkBlockRestrictionsAfter(Player player, Player controller, Game game) {
|
||||
// Restrictions applied to blocking creatures
|
||||
// Restrictions applied to blocking creatures
|
||||
for (UUID blockingCreatureId : this.getBlockers()) {
|
||||
Permanent blockingCreature = game.getPermanent(blockingCreatureId);
|
||||
if (blockingCreature != null) {
|
||||
|
@ -998,12 +1005,10 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
if (defendingPlayer != null) {
|
||||
if (defendingPlayer.getMaxAttackedBy() == Integer.MAX_VALUE) {
|
||||
maxAttackers = Integer.MAX_VALUE;
|
||||
} else if (maxAttackers == Integer.MIN_VALUE) {
|
||||
maxAttackers = defendingPlayer.getMaxAttackedBy();
|
||||
} else {
|
||||
if (maxAttackers == Integer.MIN_VALUE) {
|
||||
maxAttackers = defendingPlayer.getMaxAttackedBy();
|
||||
} else {
|
||||
maxAttackers += defendingPlayer.getMaxAttackedBy();
|
||||
}
|
||||
maxAttackers += defendingPlayer.getMaxAttackedBy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,7 @@ public class GameEvent implements Serializable {
|
|||
DECLARED_BLOCKERS,
|
||||
DECLARE_BLOCKER, BLOCKER_DECLARED,
|
||||
CREATURE_BLOCKED,
|
||||
UNBLOCKED_ATTACKER,
|
||||
SEARCH_LIBRARY, LIBRARY_SEARCHED,
|
||||
SHUFFLE_LIBRARY, LIBRARY_SHUFFLED,
|
||||
ENCHANT_PLAYER, ENCHANTED_PLAYER,
|
||||
|
|
Loading…
Reference in a new issue