Discord, Lord of Disharmony + Support (#5073)

* Discord, Lord of Disharmony + Support

* Prevent AI use for now.

* Include chosen name's description in text box

* Clean up DescriptionFromChosenName

* Remove blank lines from Discord card script

---------

Co-authored-by: Jetz <Jetz722@gmail.com>
This commit is contained in:
Jetz72
2024-04-20 13:32:27 -04:00
committed by GitHub
parent 63d387d3ad
commit 8fe39bca9b
4 changed files with 74 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityPredicates;
import forge.game.spellability.TargetChoices;
import forge.game.staticability.StaticAbility;
import forge.game.staticability.StaticAbilityCastWithFlash;
import forge.game.trigger.Trigger;
import forge.game.zone.ZoneType;
import forge.util.Expressions;
@@ -388,6 +389,34 @@ public class ForgeScript {
if (sa.isManaAbilityFor(paidFor, colorCanUse)) {
return false;
}
} else if(property.equals("NamedSpell")) {
boolean found = false;
for (String name : source.getNamedCards()) {
if (sa.cardState.getName().equals(name)) {
found = true;
break;
}
}
return found;
}
else if (property.equals("CouldCastTiming")) {
Card host = sa.getHostCard();
Game game = host.getGame();
if (game.getStack().isSplitSecondOnStack()) {
return false;
}
// Adapted from SpellAbility.canCastTiming, to determine if the SA could be cast at the current timing (assuming the controller had priority).
if (sourceController.canCastSorcery() || sa.getRestrictions().isInstantSpeed()) {
return true;
}
if (sa.isSpell()) {
return host.isInstant() || host.hasKeyword(Keyword.FLASH) || StaticAbilityCastWithFlash.anyWithFlash(sa, host, sourceController);
}
if (sa.isActivatedAbility()) {
return !sa.isPwAbility() && !sa.getRestrictions().isSorcerySpeed();
}
return true;
} else if (sa.getHostCard() != null) {
return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility);
}

View File

@@ -160,16 +160,23 @@ public class PlayEffect extends SpellAbilityEffect {
return;
}
} else if (sa.hasParam("CopyFromChosenName")) {
String name = controller.getNamedCard();
if (name.trim().isEmpty()) return;
String name = source.getNamedCard();
if (name.trim().isEmpty()) {
name = controller.getNamedCard();
if(name.trim().isEmpty()) {
return;
}
}
Card card = Card.fromPaperCard(StaticData.instance().getCommonCards().getUniqueByName(name), controller);
// so it gets added to stack
card.setCopiedPermanent(card);
// Keeps adventures from leaving the recast effect
card.setCopiedSpell(true);
card.setToken(true);
tgtCards = new CardCollection(card);
} else {
tgtCards = new CardCollection();
// filter only cards that didn't changed zones
// filter only cards that didn't change zones
for (Card c : getTargetCards(sa)) {
Card gameCard = game.getCardState(c, null);
if (c.equalsWithGameTimestamp(gameCard)) {
@@ -280,6 +287,7 @@ public class PlayEffect extends SpellAbilityEffect {
tgtCard.setZone(zone);
// to fix the CMC
tgtCard.setCopiedPermanent(original);
tgtCard.setCopiedSpell(true);
if (zone != null) {
zone.add(tgtCard);
}

View File

@@ -2824,6 +2824,21 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
sAbility = sbSA.toString();
} else if (sa.isSpell() && sa.isBasicSpell()) {
continue;
} else if (sa.hasParam("DescriptionFromChosenName") && !getNamedCard().isEmpty()) {
String name = getNamedCard();
ICardFace namedFace = StaticData.instance().getCommonCards().getFaceByName(name);
StringBuilder sbSA = new StringBuilder(sAbility);
sbSA.append(linebreak);
sbSA.append(Localizer.getInstance().getMessage("lblSpell"));
sbSA.append("");
if(!namedFace.getManaCost().isNoCost()) {
sbSA.append(namedFace.getManaCost().getSimpleString()).append(": ");
}
sbSA.append(namedFace.getName()).append("\r\n");
sbSA.append(namedFace.getType()).append("\r\n");
sbSA.append(namedFace.getOracleText().replaceAll("\\\\n", "\r\n"));
sbSA.append(linebreak);
sAbility = sbSA.toString();
}
if (sa.getManaPart() != null) {