It is currently 16 Apr 2024, 19:46
   
Text Size

Shared Fate Bug 1.5.51

Post MTG Forge Related Programming Questions Here

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

Shared Fate Bug 1.5.51

Postby oskarolw » 15 Apr 2016, 07:17

When Shared Fate is active and you cast an opponents spell then cancel the cast the card becomes exiled face down and can't be cast anymore.

Prior to 1.5.51 modular spells cast with Shared Fate caused a crash but that seems fixed now!
oskarolw
 
Posts: 39
Joined: 06 Jul 2012, 08:51
Has thanked: 0 time
Been thanked: 2 times

Re: Shared Fate Bug 1.5.51

Postby friarsol » 15 Apr 2016, 12:17

I think Bog Wraith has a Shared Fate club if you want to join it. (But yea, I noted when fixing the crash that if you cancel a spell this is exactly what happens)
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Shared Fate Bug 1.5.51

Postby oskarolw » 15 Apr 2016, 15:50

Are you serious about the club? :D I love the card hehe.
oskarolw
 
Posts: 39
Joined: 06 Jul 2012, 08:51
Has thanked: 0 time
Been thanked: 2 times

Re: Shared Fate Bug 1.5.51

Postby friarsol » 15 Apr 2016, 16:56

Half serious. I think for like 4-5 releases he was asking for the charm crash to be fixed. Now that he's no longer a forum admin, he probably has time to start a Shared Fate club.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Shared Fate Bug 1.5.51

Postby oskarolw » 18 Apr 2016, 09:51

I have tried to debug this a bit more but I am really unfamiliar with how the cardfactory etc works. However this seems like a bit of an issue:

forge/game/card/Card.java line 482:

public boolean turnFaceDown(boolean override) {
if (override || !isDoubleFaced()) {
preFaceDownState = currentStateName;
return setState(CardStateName.FaceDown, true);
}
return false;
}

override doesn't really do much? Shouldn't it be && ?
I experimented and changed that and in Humanplay.java:

if (!req.playAbility(true, false, false)) {
if (flippedToCast && !castFaceDown) {
source.turnFaceDown(false);
}
}
This would atleast still show the card but then I guess it would be visible to the owner of the card aswell? It seems the card loses the ability to be played by opponent but I am to confused by the structure of card abilities :/
oskarolw
 
Posts: 39
Joined: 06 Jul 2012, 08:51
Has thanked: 0 time
Been thanked: 2 times

Re: Shared Fate Bug 1.5.51

Postby friarsol » 18 Apr 2016, 12:22

I don't think that piece of code has anything to do with the bug. Typically DFCs can't be turned down (when they are on the battlefield) so a card like Ixidron doesn't do anything to them. However, DFCs CAN be manifested, so that's when you need to override their innate "not face down" ability.

I think it's more likely that when a card exiled by Shared Fate is moved to the Stack (when you start casting it), and moved back to exile (when you cancel casting it) the ability to cast it is "lost track of" because that's not generally how the rollback code works. This would be in.. HumanSpellAbility.rollbackAbility() if you want to play around with it.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Shared Fate Bug 1.5.51

Postby oskarolw » 19 Apr 2016, 09:54

I have tried debugging this a bit and stepping through the code.
I can't seem to understand where the cancel mechanics are actually ran though.
For example selectButtonCancel() in IGameController is implemented in PlayerControllerHuman 1414 but the InputProxy creates an Input which is an interface in itself and then I get lost...
oskarolw
 
Posts: 39
Joined: 06 Jul 2012, 08:51
Has thanked: 0 time
Been thanked: 2 times

Re: Shared Fate Bug 1.5.51

Postby friarsol » 19 Apr 2016, 13:57

oskarolw wrote:I have tried debugging this a bit and stepping through the code.
I can't seem to understand where the cancel mechanics are actually ran though.
For example selectButtonCancel() in IGameController is implemented in PlayerControllerHuman 1414 but the InputProxy creates an Input which is an interface in itself and then I get lost...
Well, it starts in HumanPlaySpellAbility.playAbility() line 110 or so.

Code: Select all
        final boolean prerequisitesMet = announceValuesLikeX()
                && announceType()
                && (!mayChooseTargets || setupTargets()) // if you can choose targets, then do choose them.
                && (isFree || payment.payCost(new HumanCostDecision(controller, human, ability, ability.getHostCard())));
This is where we do all the things that are required:

Announcing values
Choose Targets
Pay Costs.

Just before that things happen as I mentioned, the Spell is turned FaceUp, and added to the stack.

You don't actually need to debug things through the Inputs. If the prereqs fail, it's going to rollback. Just afterwards:

Code: Select all
        if (!prerequisitesMet) {
            if (!ability.isTrigger()) {
                rollbackAbility(fromZone, fromState, zonePosition);
                if (ability.getHostCard().isMadness()) {
                    // if a player failed to play madness cost, move the card to graveyard
                    game.getAction().moveToGraveyard(c);
                    ability.getHostCard().setMadness(false);
                } else if (ability.getHostCard().isBestowed()) {
                    ability.getHostCard().unanimateBestow();
                }
            }
            if (manaConversion) {
                manapool.restoreColorReplacements();
            }
            if (playerManaConversion) {
                manapool.restoreColorReplacements();
                human.decNumManaConversion();
            }
            return false;
        }
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Shared Fate Bug 1.5.51

Postby oskarolw » 20 Apr 2016, 07:58

You fixed it! :D <3
I was starting to debug again today and was like wtf it works, then I checked svn history :P
oskarolw
 
Posts: 39
Joined: 06 Jul 2012, 08:51
Has thanked: 0 time
Been thanked: 2 times

Re: Shared Fate Bug 1.5.51

Postby friarsol » 20 Apr 2016, 12:46

oskarolw wrote:You fixed it! :D <3
I was starting to debug again today and was like wtf it works, then I checked svn history :P
Yea as I was explaining where you should look, I had a Eureka moment.. "Hmm.. I wonder if it's just clearing it's remembered card in the wrong spot relative to the spell going on the stack." It ended up being a little different than what I thought might be happening, but it was the right clue to figure it out.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Shared Fate Bug 1.5.51

Postby Bog Wraith » 23 Apr 2016, 01:15

The two of you are now officially in my very select members only Shared Fate appreciation club! :)

I haven't been in this Forum for awhile so I was quite pleased to see that my madness is in fact, highly contagious!

Sol knows all too well of my raging obsession with this damn card & its corresponding decks that are built around it.

The last 2 weeks have been very stressful with waiting on my wife's surgery which was finally & successfully carried out last night. It was nice to relax a bit for awhile with watching some of the Pro Tour Shadows over Innistrad streaming video today and this news about Shared Fate has me grinning from ear to ear.

I needed both today, very much.

Thank you both for your efforts & humour. I needed those too!

Sol, you 'da man! 8)
'Twas in the bogs of Cannelbrae
My mate did meet an early grave
'Twas nothing left for us to save
In the peat-filled bogs of Cannelbrae.
User avatar
Bog Wraith
Global Mod 1 (Ret)
 
Posts: 1108
Joined: 28 May 2008, 22:40
Location: Shandalar
Has thanked: 425 times
Been thanked: 153 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 37 guests


Who is online

In total there are 37 users online :: 0 registered, 0 hidden and 37 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 37 guests

Login Form