It is currently 08 Sep 2025, 15:51
   
Text Size

New features for unless and stack description

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

New features for unless and stack description

Postby Max mtg » 11 Feb 2013, 02:04

Since noone seems to read Card development questions, I'll copy that part with new features announcement here.

New features include: UnlessResolveSubs$ - indicates when subabilities should be resolved. By default they are resolved at all times. That's useful for cards like Disrupt, but Power Sink should resolve its "tap all lands" and DrainMana only if X cost is not paid. So specify "UnlessResolveSubs$ WhenNotPaid" and you'll get the intended behaviour.

Stack Descriptions now may contain other varaibles besides CARDNAME. When a spell is put onto stack its targets are alredy known, so thay can be substituted in description. For instance
Code: Select all
SVar:TapLands:DB$ TapAll | ValidCards$ Land.hasManaAbility | Defined$ TargetedController | SubAbility$ ManaLose| StackDescription$ If {p:TargetedController} doesn't, that player taps all lands with mana abilities he or she controls and (subability text will get appended here)
And there's a little explaination how the text inside braces is parsed.
how it works | Open
Code: Select all
if ( isPlainText )
    sb.append(t.replace("CARDNAME", sa.getSourceCard().getName()));
else {
    List<?> objs = null;
    if ( t.startsWith("p:") )
        objs = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), t.substring(2), sa);
    else if ( t.startsWith("s:"))
        objs = AbilityFactory.getDefinedSpellAbilities(sa.getSourceCard(), t.substring(2), sa);
    else if ( t.startsWith("c:"))
        objs = AbilityFactory.getDefinedCards(sa.getSourceCard(), t.substring(2), sa);
    else
        objs = AbilityFactory.getDefinedObjects(sa.getSourceCard(), t, sa);
           
    sb.append(StringUtils.join(objs, ", "));
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: New features for unless and stack description

Postby friarsol » 11 Feb 2013, 02:18

UnlessResolvesSubs looks to be useful when the Effect that's occurring in the Unless line isn't really something that can be remembered, and can definitely simplify some scripts that have unnecessary remembering/forking.

I'll need to see the StackDescription macros to see how seemless they are, but it seems very useful for spells like "Do X to target Blah. Do Y to target Blah." such as Consume Strength.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: New features for unless and stack description

Postby Max mtg » 11 Feb 2013, 03:11

friarsol wrote:UnlessResolvesSubs looks to be useful when the Effect that's occurring in the Unless line isn't really something that can be remembered
Shocklands!

I think unless as a separate api should have been added to forge long ago.

I'll need to see the StackDescription macros to see how seemless they are, but it seems very useful for spells like "Do X to target Blah. Do Y to target Blah." such as Consume Strength.
Calculated values are not supported there yet
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 58 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 58 users online :: 0 registered, 0 hidden and 58 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 58 guests

Login Form