[NEO] Implemented Bronze Cudgels

This commit is contained in:
Evan Kranzler 2022-02-05 18:22:42 -05:00
parent dece8da0ad
commit b92128dd41
5 changed files with 96 additions and 15 deletions

View file

@ -0,0 +1,82 @@
package mage.cards.b;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.hint.common.AbilityResolutionCountHint;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.AbilityResolvedWatcher;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class BronzeCudgels extends CardImpl {
public BronzeCudgels(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
this.subtype.add(SubType.EQUIPMENT);
// {2}: Equipped creature gets +X/+0 until end of turn, where X is the number of times this ability has resolved this turn.
this.addAbility(new SimpleActivatedAbility(
new BronzeCudgelsEffect(), new GenericManaCost(2)
).addHint(AbilityResolutionCountHint.instance), new AbilityResolvedWatcher());
// Equip {1}
this.addAbility(new EquipAbility(1));
}
private BronzeCudgels(final BronzeCudgels card) {
super(card);
}
@Override
public BronzeCudgels copy() {
return new BronzeCudgels(this);
}
}
class BronzeCudgelsEffect extends OneShotEffect {
BronzeCudgelsEffect() {
super(Outcome.Benefit);
staticText = "equipped creature gets +X/+0 until end of turn, " +
"where X is the number of times this ability has resolved this turn";
}
private BronzeCudgelsEffect(final BronzeCudgelsEffect effect) {
super(effect);
}
@Override
public BronzeCudgelsEffect copy() {
return new BronzeCudgelsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (permanent == null || game.getPermanent(permanent.getAttachedTo()) == null) {
return false;
}
int resolvedCount = AbilityResolvedWatcher.getResolutionCount(game, source);
if (resolvedCount < 1) {
return false;
}
game.addEffect(new BoostTargetEffect(resolvedCount, 0)
.setTargetPointer(new FixedTarget(permanent.getOwnerId(), game)), source);
return true;
}
}

View file

@ -56,6 +56,7 @@ public final class KamigawaNeonDynasty extends ExpansionSet {
cards.add(new SetCardInfo("Boseiju Reaches Skyward", 177, Rarity.UNCOMMON, mage.cards.b.BoseijuReachesSkyward.class));
cards.add(new SetCardInfo("Branch of Boseiju", 177, Rarity.UNCOMMON, mage.cards.b.BranchOfBoseiju.class));
cards.add(new SetCardInfo("Brilliant Restoration", 7, Rarity.RARE, mage.cards.b.BrilliantRestoration.class));
cards.add(new SetCardInfo("Bronze Cudgels", 240, Rarity.UNCOMMON, mage.cards.b.BronzeCudgels.class));
cards.add(new SetCardInfo("Bronzeplate Boar", 135, Rarity.UNCOMMON, mage.cards.b.BronzeplateBoar.class));
cards.add(new SetCardInfo("Brute Suit", 241, Rarity.COMMON, mage.cards.b.BruteSuit.class));
cards.add(new SetCardInfo("Careful Cultivation", 178, Rarity.COMMON, mage.cards.c.CarefulCultivation.class));

View file

@ -15,11 +15,7 @@ public enum AbilityResolutionCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
AbilityResolvedWatcher watcher = game.getState().getWatcher(AbilityResolvedWatcher.class);
if (watcher != null) {
return watcher.getResolutionCount(game, sourceAbility);
}
return 0;
return AbilityResolvedWatcher.getResolutionCount(game, sourceAbility);
}
@Override

View file

@ -38,15 +38,13 @@ public class IfAbilityHasResolvedXTimesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
AbilityResolvedWatcher watcher = game.getState().getWatcher(AbilityResolvedWatcher.class);
if (watcher != null && watcher.getResolutionCount(game, source) == resolutionNumber) {
if (effect instanceof OneShotEffect) {
return effect.apply(game, source);
} else {
game.addEffect((ContinuousEffect) effect, source);
return true;
}
if (AbilityResolvedWatcher.getResolutionCount(game, source) != resolutionNumber) {
return true;
}
if (effect instanceof OneShotEffect) {
return effect.apply(game, source);
}
game.addEffect((ContinuousEffect) effect, source);
return true;
}
}

View file

@ -33,7 +33,11 @@ public class AbilityResolvedWatcher extends Watcher {
resolutionMap.clear();
}
public int getResolutionCount(Game game, Ability source) {
return resolutionMap.getOrDefault(source.getOriginalId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), 0);
public static int getResolutionCount(Game game, Ability source) {
return game
.getState()
.getWatcher(AbilityResolvedWatcher.class)
.resolutionMap
.getOrDefault(source.getOriginalId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()), 0);
}
}