Skip to content

Commit

Permalink
[UNF] Implement Strength-Testing Hammer; fix Six-Sided Die (#12756)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidorovich77 authored Sep 15, 2024
1 parent e2531a4 commit 1af0814
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 23 deletions.
62 changes: 39 additions & 23 deletions Mage.Sets/src/mage/cards/s/SixSidedDie.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package mage.cards.s;

import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
Expand All @@ -25,20 +22,13 @@ public final class SixSidedDie extends CardImpl {

public SixSidedDie(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{B}");

// Choose target creature. Roll a six-sided die.
//
//1 — It has base toughness 1 until end of turn.
//
//2 — Put two -1/-1 counters on it.
//
//3 — Six-Sided Die deals 3 damage to it, and you gain 3 life.
//
//4 — It gets -4/-4 until end of turn.
//
//5 — Destroy it.
//
//6 — Exile it.
// 1 — It has base toughness 1 until end of turn.
// 2 — Put two -1/-1 counters on it.
// 3 — Six-Sided Die deals 3 damage to it, and you gain 3 life.
// 4 — It gets -4/-4 until end of turn.
// 5 — Destroy it.
// 6 — Exile it.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new SixSidedDieEffect());
}
Expand All @@ -56,7 +46,8 @@ public SixSidedDie copy() {
class SixSidedDieEffect extends OneShotEffect {

SixSidedDieEffect() {
super(Outcome.Benefit);
super(Outcome.Detriment);

setText("choose target creature. Roll a six-sided die." +
"<br>1 — It has base toughness 1 until end of turn." +
"<br>2 — Put two -1/-1 counters on it." +
Expand All @@ -82,10 +73,11 @@ public boolean apply(Game game, Ability source) {
if (player == null || permanent == null) {
return false;
}
int result = player.rollDice(outcome, source, game, 1);
int result = player.rollDice(outcome, source, game, 6);
switch (result) {
case 6:
game.addEffect(new SetBasePowerToughnessTargetEffect(1, 1, Duration.EndOfTurn), source);
case 1:
//Based on Chariot of the Sun
game.addEffect(new SixSidedDieToughnessEffect(), source);
break;
case 2:
permanent.addCounters(CounterType.M1M1.createInstance(2), source, game);
Expand All @@ -100,10 +92,34 @@ public boolean apply(Game game, Ability source) {
case 5:
permanent.destroy(source, game);
break;
case 1:
case 6:

player.moveCards(permanent, Zone.EXILED, source, game);
break;
}
return true;
}
}

class SixSidedDieToughnessEffect extends ContinuousEffectImpl {

SixSidedDieToughnessEffect() {
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.UnboostCreature);
}

private SixSidedDieToughnessEffect(final SixSidedDieToughnessEffect effect) {
super(effect);
}

@Override
public SixSidedDieToughnessEffect copy() {
return new SixSidedDieToughnessEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
permanent.getToughness().setModifiedBaseValue(1);
return true;
}
}
105 changes: 105 additions & 0 deletions Mage.Sets/src/mage/cards/s/StrengthTestingHammer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package mage.cards.s;

import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;

import java.util.UUID;

/**
* @author Sidorovich77
*/
public final class StrengthTestingHammer extends CardImpl {


public StrengthTestingHammer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");

this.subtype.add(SubType.EQUIPMENT);

//Whenever equipped creature attacks, roll a six-sided die.
// That creature gets +X/+0 until end of turn, where X is the result.
// Then, if it has the greatest power or is tied for greatest power among creatures on the battlefield, draw a card.


TriggeredAbility ability = new AttacksAttachedTriggeredAbility(new StrengthTestingHammerEffect());
ability.addEffect(new ConditionalOneShotEffect(new DrawCardSourceControllerEffect(1), StrengthTestingHammerCondition.instance).setText("Then if it has the greatest power or is tied for greatest power among creatures on the battlefield, draw a card."));
this.addAbility(ability);

// Equip {3}
this.addAbility(new EquipAbility(3));
}

private StrengthTestingHammer(final StrengthTestingHammer card) {
super(card);
}

@Override
public StrengthTestingHammer copy() {
return new StrengthTestingHammer(this);
}
}

//Based on Historian's Wisdom
enum StrengthTestingHammerCondition implements Condition {
instance;

@Override
public boolean apply(Game game, Ability source) {
Permanent hammer = source.getSourcePermanentIfItStillExists(game);
if (hammer == null) {
return false;
}
Permanent creature = game.getPermanent(hammer.getAttachedTo());
if (creature == null) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, creature.getPower().getValue()));
return game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game).isEmpty();
}
}

class StrengthTestingHammerEffect extends OneShotEffect {

StrengthTestingHammerEffect() {
super(Outcome.Benefit);
staticText = "roll a six-sided die. That creature gets +X/+0 until end of turn, where X is the result.";
}

private StrengthTestingHammerEffect(final StrengthTestingHammerEffect effect) {
super(effect);
}

@Override
public StrengthTestingHammerEffect copy() {
return new StrengthTestingHammerEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int result = player.rollDice(outcome, source, game, 6);
game.addEffect(new BoostEquippedEffect(result, 0, Duration.EndOfTurn), source);
}
return false;
}
}



1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/Unfinity.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private Unfinity() {
cards.add(new SetCardInfo("Slight Malfunction", 123, Rarity.COMMON, mage.cards.s.SlightMalfunction.class));
cards.add(new SetCardInfo("Starlight Spectacular", 28, Rarity.RARE, mage.cards.s.StarlightSpectacular.class));
cards.add(new SetCardInfo("Steam Vents", 283, Rarity.RARE, mage.cards.s.SteamVents.class));
cards.add(new SetCardInfo("Strength-Testing Hammer", 193, Rarity.UNCOMMON, mage.cards.s.StrengthTestingHammer.class));
cards.add(new SetCardInfo("Stomping Ground", 280, Rarity.RARE, mage.cards.s.StompingGround.class));
cards.add(new SetCardInfo("Swamp", 237, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_UST_VARIOUS));
cards.add(new SetCardInfo("Swamp", 242, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_UST_VARIOUS));
Expand Down

0 comments on commit 1af0814

Please sign in to comment.