It is currently 02 Nov 2025, 07:39
   
Text Size

delete doDrawBack?

Post MTG Forge Related Programming Questions Here

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

delete doDrawBack?

Postby Sloth » 05 Jun 2011, 15:29

I converted Dream Cache to newer style drawback and I think it was the last card to use the old function. Can we delete doDrawBack in CardFactoryUtil?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: delete doDrawBack?

Postby slapshot5 » 05 Jun 2011, 15:36

I say yes. Sol and I were converting a bunch of these a month ago or so. This was one of two leftovers that couldn't be done then. (The other has since been converted I think.)

Sol may have a comment, but my guess is he'd be all for removing that code. It's not like there's AI in there we need to keep.

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

Re: delete doDrawBack?

Postby friarsol » 05 Jun 2011, 15:46

Yea Dream Cache was the only thing left on the list. So nuke away. As far as AFs goes, we can change the last few lines of Resolve() from (generally)

Code: Select all
if (af.hasSubAbility()){
   Ability_Sub abSub = sa.getSubAbility();
   if (abSub != null){
      abSub.resolve();
   }
   else
      CardFactoryUtil.doDrawBack(DrawBack, 0, card.getController(), card.getController().getOpponent(), card.getController(), card, tgtCards.get(0), sa);
}
to

Code: Select all
AbilityFactory.resolveSubAbility(sa);
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: delete doDrawBack?

Postby Rob Cashwalker » 05 Jun 2011, 16:02

{sniff} so sad to see it go...
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: delete doDrawBack?

Postby friarsol » 05 Jun 2011, 16:09

Rob Cashwalker wrote:{sniff} so sad to see it go...
One of these days Rob is going to be yelling at us to get off his lawn. :wink:
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: delete doDrawBack?

Postby slapshot5 » 05 Jun 2011, 16:11

friarsol wrote:
Rob Cashwalker wrote:{sniff} so sad to see it go...
One of these days Rob is going to be yelling at us to get off his lawn. :wink:
I wish I could just click "Like" on this post.
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: delete doDrawBack?

Postby Sloth » 05 Jun 2011, 16:16

Can't we do something like a super resolve function now, to not repeat so much code. It should do just the following things:

1. check condition (and maybe fizzling and unless costs)
1a. if true let it resolve (in the corresponding AF).

2. go to super resolve of next subability.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: delete doDrawBack?

Postby friarsol » 05 Jun 2011, 16:26

Sloth wrote:Can't we do something like a super resolve function now, to not repeat so much code. It should do just the following things:

1. check condition (and maybe fizzling and unless costs)
1a. if true let it resolve (in the corresponding AF).

2. go to super resolve of next subability.
Yea it's definitely a good idea to go through and simplify as much as the common resolution code as possible.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: delete doDrawBack?

Postby Rob Cashwalker » 05 Jun 2011, 18:16

I
friarsol wrote:
Rob Cashwalker wrote:{sniff} so sad to see it go...
One of these days Rob is going to be yelling at us to get off his lawn. :wink:
I don't get it...
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: delete doDrawBack?

Postby Sloth » 05 Jun 2011, 19:48

friarsol wrote:
Sloth wrote:Can't we do something like a super resolve function now, to not repeat so much code. It should do just the following things:

1. check condition (and maybe fizzling and unless costs)
1a. if true let it resolve (in the corresponding AF).

2. go to super resolve of next subability.
Yea it's definitely a good idea to go through and simplify as much as the common resolution code as possible.
After taking a look at the structure, I think I have to pass implementing this. I can't find a way to add something before the resolve without detroying the nice structure of the ability factory. I just can't code so elegantly. Unless someone gives me a hint or batch of code I can start from I'm gonna drop this.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: delete doDrawBack?

Postby friarsol » 05 Jun 2011, 20:01

Sloth wrote:After taking a look at the structure, I think I have to pass implementing this. I can't find a way to add something before the resolve without detroying the nice structure of the ability factory. I just can't code so elegantly. Unless someone gives me a hint or batch of code I can start from I'm gonna drop this.
The hooks need to happen on the MagicStack side, instead of calling sa.resolve() there we would call need to be a call to a AF.resolve(sa) which would do as you suggest, pulling out the appropriate conditional checks, as well as looping through each of the subAbilities afterwards and resolving those. If the SpellAbility didn't have an attached AF, then no need to do any of the AF specific things, and we could just call sa.resolve() straight up from there.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: delete doDrawBack?

Postby Sloth » 05 Jun 2011, 20:56

friarsol wrote:
Sloth wrote:After taking a look at the structure, I think I have to pass implementing this. I can't find a way to add something before the resolve without detroying the nice structure of the ability factory. I just can't code so elegantly. Unless someone gives me a hint or batch of code I can start from I'm gonna drop this.
The hooks need to happen on the MagicStack side, instead of calling sa.resolve() there we would call need to be a call to a AF.resolve(sa) which would do as you suggest, pulling out the appropriate conditional checks, as well as looping through each of the subAbilities afterwards and resolving those. If the SpellAbility didn't have an attached AF, then no need to do any of the AF specific things, and we could just call sa.resolve() straight up from there.
Thanks Sol. I commited the change. It was really easy with your help.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: delete doDrawBack?

Postby friarsol » 05 Jun 2011, 21:09

Sloth wrote:Thanks Sol. I commited the change. It was really easy with your help.
Wow that took no time at all. Little things like this will keep our structure clean and the copy-pasted code to a minimum.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: delete doDrawBack?

Postby Sloth » 06 Jun 2011, 09:19

My next plan is to add unless costs to this resolve function. The only difference in the existing unless cost mechanic in AF counters is, that the unless cost is checked for each target of the counterspell. There is no counter ability that allows multiple targeted/defined spells and has an unless cost (and the prompt for the human isn't really worked out to support this).
Is it ok to pull out the unless cost from AF counterspell and put an all or nothing unless cost in front of sa.resolve() (like a Condition)? Subabilities would still resolve (for cards like Offering to Asha).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: delete doDrawBack?

Postby friarsol » 06 Jun 2011, 11:54

Sloth wrote:My next plan is to add unless costs to this resolve function. The only difference in the existing unless cost mechanic in AF counters is, that the unless cost is checked for each target of the counterspell. There is no counter ability that allows multiple targeted/defined spells and has an unless cost (and the prompt for the human isn't really worked out to support this).
Is it ok to pull out the unless cost from AF counterspell and put an all or nothing unless cost in front of sa.resolve() (like a Condition)? Subabilities would still resolve (for cards like Offering to Asha).
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 22 guests

cron

Main Menu

User Menu

Our Partners


Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 22 guests

Login Form