It is currently 05 Jun 2024, 23:01
   
Text Size

Suspend Fix

Post MTG Forge Related Programming Questions Here

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

Suspend Fix

Postby friarsol » 29 Oct 2010, 04:28

So it looks like Suspend needed a bit more of an update since I wrote the Restrictions recently. I updated a block of code to take this into account and tested to confirm the fix works.

However, my codebase right now is a wreck, I don't want to just submit this blind, and I can't really revert my code down just for this fix. So if someone could merge this in, and do a quick test with Lotus Bloom, and then submit for me that'd be great.

The change was only in canPlay() but I'll copy the whole function so it can be easier to find.

Code: Select all
    public static SpellAbility ability_suspend(final Card sourceCard, final String suspendCost, final int suspendCounters) {
       // be careful with Suspend ability, it will not hit the stack
        final SpellAbility suspend = new Ability_Static(sourceCard, suspendCost) {
         private static final long serialVersionUID = 21625903128384507L;

         @Override
         public boolean canPlay(){
              if (!(getRestrictions().canPlay(sourceCard, this)))     
                 return false;
            
            if (sourceCard.isInstant())
               return true;
            
            return Phase.canCastSorcery(sourceCard.getOwner());
         }
         
         @Override
            public boolean canPlayAI() {
                return false;
            }
           
            @Override
            public void resolve() {
               AllZone.GameAction.exile(sourceCard);
               sourceCard.addCounter(Counters.TIME, suspendCounters);
            }
        };
        suspend.setDescription("Suspend " +suspendCounters + ": "+ suspendCost);
        suspend.setStackDescription(sourceCard.getName() + " suspending for " + suspendCounters + " turns.)");
        suspend.getRestrictions().setActivateZone(Constant.Zone.Hand);
        return suspend;
    }//ability_suspend()
Thanks.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Suspend Fix

Postby slapshot5 » 29 Oct 2010, 11:47

friarsol wrote:So it looks like Suspend needed a bit more of an update since I wrote the Restrictions recently. I updated a block of code to take this into account and tested to confirm the fix works.

However, my codebase right now is a wreck, I don't want to just submit this blind, and I can't really revert my code down just for this fix. So if someone could merge this in, and do a quick test with Lotus Bloom, and then submit for me that'd be great.

The change was only in canPlay() but I'll copy the whole function so it can be easier to find.

Code: Select all
    public static SpellAbility ability_suspend(final Card sourceCard, final String suspendCost, final int suspendCounters) {
       // be careful with Suspend ability, it will not hit the stack
        final SpellAbility suspend = new Ability_Static(sourceCard, suspendCost) {
         private static final long serialVersionUID = 21625903128384507L;

         @Override
         public boolean canPlay(){
              if (!(getRestrictions().canPlay(sourceCard, this)))     
                 return false;
            
            if (sourceCard.isInstant())
               return true;
            
            return Phase.canCastSorcery(sourceCard.getOwner());
         }
         
         @Override
            public boolean canPlayAI() {
                return false;
            }
           
            @Override
            public void resolve() {
               AllZone.GameAction.exile(sourceCard);
               sourceCard.addCounter(Counters.TIME, suspendCounters);
            }
        };
        suspend.setDescription("Suspend " +suspendCounters + ": "+ suspendCost);
        suspend.setStackDescription(sourceCard.getName() + " suspending for " + suspendCounters + " turns.)");
        suspend.getRestrictions().setActivateZone(Constant.Zone.Hand);
        return suspend;
    }//ability_suspend()
Thanks.
Ok. Tested and it works. I'll submit.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Suspend Fix

Postby friarsol » 29 Oct 2010, 13:44

Thanks. Hopefully, I'll have this Phase stuff done soon so I can actually submit updates when I need to.
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 44 guests


Who is online

In total there are 44 users online :: 0 registered, 0 hidden and 44 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 44 guests

Login Form