It is currently 12 Sep 2025, 06:47
   
Text Size

Remembering Integers

Post MTG Forge Related Programming Questions Here

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

Remembering Integers

Postby moomarc » 07 Apr 2012, 05:00

moomarc wrote:I've just committed some work that enables the ability to remember and recall integer values. This is needed for cards like Tree of Redemption where the referenced value might change. It currently only supports RememberToughness, but it can be referenced easily for other values. To recall the value, use SVar:X:Number$RememberedValue.

It would probably be better to expand it to the form of RememberValue$Toughness instead of RememberToughness$True. It would make it neater to expand, but I couldn't get it to work properly. Anyway, the groundwork is there with a nice test-piece (Tree of Redemption) if anyone feels it needs to be improved.
friarsol wrote:It'd probably be even better if we reused Count for this, which already does this same thing, but doesn't store it anywhere.

RememberValue$ CardToughness
Continueing this where I'd originally meant to post this...

I had initially wanted (and tried) to implement this directly in xCount but couldn't work out how to get the same value (eg card toughness) at different points of resolution. It seems like it has to be stored temporarily. You said yourself to Mark that we needed the facility to store a value for cards like Tree of Redemption. But if you can give me some hints on how to do it I'll try to add directly to count again. Or perhaps I'm just misunderstanding what you want.
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Remembering Integers

Postby friarsol » 07 Apr 2012, 16:49

Sounds like you misunderstood. I'm just saying instead of having yet another parser for RememberingValues, we just setup RememberValue to calculate via xCount. Perhaps it would be it's own Factory.

So let's take your Tree of Redemption Script. It might in theory look like this.

A:AB$ StoreSVar | Cost$ T | SVar$ OldToughness | Type$ Count | Expression$ CardToughness | SubAbility$ TreeRedemption | SpellDescription$ Exchange your life total with Tree of CARDNAME's toughness.
SVar:TreeRedemption:DB$ Animate | Toughness$ X | Permanent$ True | SubAbility$ SetLife
SVar:SetLife:DB$ SetLife | Defined$ You | LifeAmount$ OldToughness
SVar:DBCleanup:DB$ Cleanup | ClearSVars$ OldToughness
SVar:X:Count$YourLifeTotal

So instead of sticking the whole Expression into OldToughness it would calculate the express and stick Number$13 into it, and it makes things much more standardized.

Busy weekend for me with Family stuff, but if someone else doesn't hop on it first, I could probably put the StoreSVar together when I have a free hour or two.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Remembering Integers

Postby moomarc » 07 Apr 2012, 17:16

Ah, that sounds great. It was just beyond my skills though, and I think my general java knowledge is lacking too much so I thought what I'd done was the lightest method. Thanks for walking me through so well while I get the hang of things. Hopefully I don't annoy you experienced guys with my attempts, but I think so far I just submit sub-optimal code rather than anything blatantly horrible (if not, point it out so I know for future reference).
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Remembering Integers

Postby moomarc » 07 Apr 2012, 21:04

On another note, I used the gain and lose life AFs with conditions because of the second half of this ruling:
When the ability resolves, Tree of Redemption's toughness will become your former life total and you will gain or lose an amount of life necessary so that your life total equals Tree of Redemption's former toughness. Other effects that interact with life gain or life loss will interact with this effect accordingly.
Does SetLife interact correctly with this? I thought it worked like Dev mode's set life which just sets the value, but doesn't cause life gain or life loss.
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Remembering Integers

Postby friarsol » 07 Apr 2012, 21:11

moomarc wrote:On another note, I used the gain and lose life AFs with conditions because of the second half of this ruling:
When the ability resolves, Tree of Redemption's toughness will become your former life total and you will gain or lose an amount of life necessary so that your life total equals Tree of Redemption's former toughness. Other effects that interact with life gain or life loss will interact with this effect accordingly.
Does SetLife interact correctly with this? I thought it worked like Dev mode's set life which just sets the value, but doesn't cause life gain or life loss.
Code: Select all
    public final boolean setLife(final int newLife, final Card source) {
        boolean change = false;
        // rule 118.5
        if (this.life > newLife) {
            change = this.loseLife(this.life - newLife, source);
        } else if (newLife > this.life) {
            change = this.gainLife(newLife - this.life, source);
        } else {
            // life == newLife
            change = false;
        }
        this.updateObservers();
        return change;
    }
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Remembering Integers

Postby moomarc » 07 Apr 2012, 21:38

Thanks Sol.
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Remembering Integers

Postby friarsol » 13 Apr 2012, 03:51

I just added StoreSVar and converted Tree of Redemption to use it. I didn't do anything to the RememberToughness that you added in, you should probably go in and remove those references, since they are no longer needed.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 29 users online :: 0 registered, 0 hidden and 29 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 29 guests

Login Form