Skip to content

Remove gold from ObjectColor #13470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 26 additions & 63 deletions Mage.Sets/src/mage/cards/c/CallToArms.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package mage.cards.c;

import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.MostCommonColorCondition;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
Expand All @@ -18,40 +16,45 @@
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;

import java.util.UUID;

/**
*
* @author TheElk801
*/
public final class CallToArms extends CardImpl {

private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();

static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
}

public CallToArms(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");

// As Call to Arms enters the battlefield, choose a color and an opponent.
Ability ability = new AsEntersBattlefieldAbility(
new ChooseColorEffect(Outcome.Detriment)
);
ability.addEffect(new ChooseOpponentEffect(
Outcome.Benefit
).setText("and an opponent"));
Ability ability = new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Detriment));
ability.addEffect(new ChooseOpponentEffect(Outcome.Benefit).setText("and an opponent"));
this.addAbility(ability);

// White creatures get +1/+1 as long as the chosen color is the most common color among nontoken permanents the chosen player controls but isn't tied for most common.
this.addAbility(new SimpleStaticAbility(
new CallToArmsEffect()
));
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false),
CallToArmsCondition.instance, "white creatures get +1/+1 as long as the chosen color " +
"is the most common color among nontoken permanents the chosen player controls but isn't tied for most common"
)));

// When the chosen color isn't the most common color among nontoken permanents the chosen player controls or is tied for most common, sacrifice Call to Arms.
this.addAbility(new CallToArmsStateTriggeredAbility());
Expand All @@ -67,46 +70,17 @@ public CallToArms copy() {
}
}

class CallToArmsEffect extends ContinuousEffectImpl {

private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("White creatures");

static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
}

public CallToArmsEffect() {
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.Benefit);
staticText = "White creatures get +1/+1 as long as the chosen color "
+ "is the most common color among nontoken permanents "
+ "the chosen player controls but isn't tied for most common.";
}

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

@Override
public CallToArmsEffect copy() {
return new CallToArmsEffect(this);
}
enum CallToArmsCondition implements Condition {
instance;

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
UUID playerId = (UUID) game.getState().getValue(source.getSourceId() + ChooseOpponentEffect.VALUE_KEY);
if (permanent != null) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
Condition condition = new MostCommonColorCondition(color, true, new ControllerIdPredicate(playerId));
if (condition.apply(game, source)) {
Effect effect = new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false);
return effect.apply(game, source);
}
}
}
return false;
Player opponent = game.getPlayer((UUID) game.getState().getValue(source.getSourceId() + ChooseOpponentEffect.VALUE_KEY));
return permanent != null && opponent != null && new MostCommonColorCondition(
(ObjectColor) game.getState().getValue(permanent.getId() + "_color"), true,
Predicates.and(TokenPredicate.FALSE, new ControllerIdPredicate(opponent.getId()))
).apply(game, source);
}
}

Expand All @@ -129,17 +103,6 @@ public CallToArmsStateTriggeredAbility copy() {

@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(getSourceId());
UUID playerId = (UUID) game.getState().getValue(getSourceId() + ChooseOpponentEffect.VALUE_KEY);
if (permanent != null) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
Condition condition = new MostCommonColorCondition(color, true, new ControllerIdPredicate(playerId));
return !condition.apply(game, this);
}
}
return false;
return !CallToArmsCondition.instance.apply(game, this);
}

}
109 changes: 33 additions & 76 deletions Mage.Sets/src/mage/cards/s/SwordOfDungeonsAndDragons.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@


package mage.cards.s;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
Expand All @@ -18,50 +12,51 @@
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.DragonTokenGold;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;

import java.util.UUID;

/**
* This creates a "gold" token which is represented as a creature with all colors
* as the color gold is not supported in the black-bordered game rules
*
* @author Saga
*/
public final class SwordOfDungeonsAndDragons extends CardImpl {

private static final FilterCard filter = new FilterCard("Rogues and from Clerics");
static {filter.add(Predicates.or(
SubType.ROGUE.getPredicate(),
SubType.CLERIC.getPredicate()
));

static {
filter.add(Predicates.or(
SubType.ROGUE.getPredicate(),
SubType.CLERIC.getPredicate()
));
}

public SwordOfDungeonsAndDragons(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
this.subtype.add(SubType.EQUIPMENT);

// Equipped creature gets +2/+2 and has protection from Rogues and from Clerics.
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(2, 2));
Effect effect = new GainAbilityAttachedEffect(new ProtectionAbility(filter), AttachmentType.EQUIPMENT);
effect.setText("and has protection from Rogues and from Clerics");
ability.addEffect(effect);
ability.addEffect(new GainAbilityAttachedEffect(
new ProtectionAbility(filter), AttachmentType.EQUIPMENT
).setText("and has protection from Rogues and from Clerics"));
this.addAbility(ability);

// Whenever equipped creature deals combat damage to a player, you create a 4/4 gold Dragon creature token with flying and roll a d20. If you roll a 20, repeat this process.
this.addAbility(new SwordOfDungeonsAndDragonsAbility());
this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(
new SwordOfDungeonsAndDragonsEffect(), "equipped creature", false
));

// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2), new TargetControlledCreaturePermanent(), false));
this.addAbility(new EquipAbility(2));
}

private SwordOfDungeonsAndDragons(final SwordOfDungeonsAndDragons card) {
Expand All @@ -74,49 +69,12 @@ public SwordOfDungeonsAndDragons copy() {
}
}

class SwordOfDungeonsAndDragonsAbility extends TriggeredAbilityImpl {

public SwordOfDungeonsAndDragonsAbility() {
super(Zone.BATTLEFIELD, new SwordOfDungeonsAndDragonsEffect(),false);
}

private SwordOfDungeonsAndDragonsAbility(final SwordOfDungeonsAndDragonsAbility ability) {
super(ability);
}

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

@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
}
return false;
}

@Override
public String getRule() {
return "Whenever equipped creature deals combat damage to a player, you create a 4/4 gold Dragon creature token with flying and roll a d20. If you roll a 20, repeat this process.";
}
}

class SwordOfDungeonsAndDragonsEffect extends OneShotEffect {
public SwordOfDungeonsAndDragonsEffect() {

SwordOfDungeonsAndDragonsEffect() {
super(Outcome.Benefit);
staticText = "you create a 4/4 gold Dragon creature token with flying " +
"and roll a d20. If you roll a 20, repeat this process";
}

private SwordOfDungeonsAndDragonsEffect(final SwordOfDungeonsAndDragonsEffect effect) {
Expand All @@ -131,16 +89,15 @@ public SwordOfDungeonsAndDragonsEffect copy() {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int count = 1;
int amount = controller.rollDice(outcome, source, game, 20);

while (amount == 20) {
count += 1;
amount = controller.rollDice(outcome, source, game, 20);
if (controller == null) {
return false;
}
for (int i = 0; i < 1000; i++) { // just in case loop goes too long
new DragonTokenGold().putOntoBattlefield(1, game, source);
if (controller.rollDice(outcome, source, game, 20) != 20) {
break;
}
return new CreateTokenEffect(new DragonTokenGold(), count).apply(game, source);
}
return false;
return true;
}
}
Loading