mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
[AFR] Implemented Bruenor Battlehammer
This commit is contained in:
parent
4bdd4cb66d
commit
961a07e78c
2 changed files with 162 additions and 0 deletions
161
Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java
Normal file
161
Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package mage.cards.b;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static mage.constants.Outcome.Benefit;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class BruenorBattlehammer extends CardImpl {
|
||||
|
||||
public BruenorBattlehammer(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{W}");
|
||||
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.DWARF);
|
||||
this.subtype.add(SubType.WARRIOR);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// Each creature you control gets +2/+0 for each Equipment attached to it.
|
||||
this.addAbility(new SimpleStaticAbility(new BruenorBattlehammerBoostEffect()));
|
||||
|
||||
// You may pay {0} rather than pay the equip cost of the first equip ability you activate each turn.
|
||||
this.addAbility(new SimpleStaticAbility(new BruenorBattlehammerCostEffect()), new BruenorBattlehammerWatcher());
|
||||
}
|
||||
|
||||
private BruenorBattlehammer(final BruenorBattlehammer card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BruenorBattlehammer copy() {
|
||||
return new BruenorBattlehammer(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BruenorBattlehammerBoostEffect extends ContinuousEffectImpl {
|
||||
|
||||
BruenorBattlehammerBoostEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
staticText = "each creature you control gets +2/+0 for each Equipment attached to it";
|
||||
}
|
||||
|
||||
private BruenorBattlehammerBoostEffect(final BruenorBattlehammerBoostEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BruenorBattlehammerBoostEffect copy() {
|
||||
return new BruenorBattlehammerBoostEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_CREATURE,
|
||||
source.getControllerId(), source.getSourceId(), game
|
||||
)) {
|
||||
int equipped = permanent
|
||||
.getAttachments()
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.mapToInt(p -> p.hasSubtype(SubType.EQUIPMENT, game) ? 1 : 0)
|
||||
.sum();
|
||||
permanent.addPower(2 * equipped);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class BruenorBattlehammerCostEffect extends CostModificationEffectImpl {
|
||||
|
||||
BruenorBattlehammerCostEffect() {
|
||||
super(Duration.Custom, Benefit, CostModificationType.SET_COST);
|
||||
this.staticText = "you may pay {0} rather than pay the equip cost " +
|
||||
"of the first equip ability you activate each turn.";
|
||||
}
|
||||
|
||||
BruenorBattlehammerCostEffect(final BruenorBattlehammerCostEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return source.isControlledBy(abilityToModify.getControllerId())
|
||||
&& !BruenorBattlehammerWatcher.checkPlayer(abilityToModify.getControllerId(), game)
|
||||
&& abilityToModify instanceof EquipAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
if (!game.inCheckPlayableState()) {
|
||||
return false;
|
||||
}
|
||||
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
||||
if (controller == null || !controller.chooseUse(
|
||||
Outcome.PlayForFree, "Pay {0} to equip?", source, game
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
abilityToModify.getCosts().clear();
|
||||
abilityToModify.getManaCostsToPay().clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BruenorBattlehammerCostEffect copy() {
|
||||
return new BruenorBattlehammerCostEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BruenorBattlehammerWatcher extends Watcher {
|
||||
|
||||
private final Set<UUID> playerSet = new HashSet<>();
|
||||
|
||||
BruenorBattlehammerWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY) {
|
||||
return;
|
||||
}
|
||||
StackObject object = game.getStack().getStackObject(event.getSourceId());
|
||||
if (object != null && object.getStackAbility() instanceof EquipAbility) {
|
||||
playerSet.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playerSet.clear();
|
||||
}
|
||||
|
||||
static boolean checkPlayer(UUID playerId, Game game) {
|
||||
BruenorBattlehammerWatcher watcher = game.getState().getWatcher(BruenorBattlehammerWatcher.class);
|
||||
return watcher != null && watcher.playerSet.contains(playerId);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
|
|||
this.numBoosterRare = 1;
|
||||
this.maxCardNumberInBooster = 275;
|
||||
|
||||
cards.add(new SetCardInfo("Bruenor Battlehammer", 219, Rarity.UNCOMMON, mage.cards.b.BruenorBattlehammer.class));
|
||||
cards.add(new SetCardInfo("Drizzt Do'Urden", 220, Rarity.RARE, mage.cards.d.DrizztDoUrden.class));
|
||||
cards.add(new SetCardInfo("Flumph", 15, Rarity.RARE, mage.cards.f.Flumph.class));
|
||||
cards.add(new SetCardInfo("Forest", 281, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
|
||||
|
|
Loading…
Reference in a new issue