Multi-Targeting Issue
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
27 posts
• Page 1 of 2 • 1, 2
Multi-Targeting Issue
by friarsol » 13 May 2011, 04:25
For everyone who has ever reported an issue with multi-targeting: I'm currently working on this issue.
I'm not sure how long it will take, but I've gotten it far enough to proof of concept that my solution works. Gorilla Shaman was ale to target two different Moxen on the stack and kill both of them properly.
Now I just need to expand it for all of the AFs. I don't look forward to doing it in CardFactories so hopefully that won't be a major problem. I'm not certain if this will fix the multi-Triggering problem, but it is possible (and I'm hopeful that it will).
This certainly will not be making it into the next Release, so maybe I can recruit some helpers once I do all the AFs to replicate the need changes throughout everywhere else it needs to go.
I'm not sure how long it will take, but I've gotten it far enough to proof of concept that my solution works. Gorilla Shaman was ale to target two different Moxen on the stack and kill both of them properly.
Now I just need to expand it for all of the AFs. I don't look forward to doing it in CardFactories so hopefully that won't be a major problem. I'm not certain if this will fix the multi-Triggering problem, but it is possible (and I'm hopeful that it will).
This certainly will not be making it into the next Release, so maybe I can recruit some helpers once I do all the AFs to replicate the need changes throughout everywhere else it needs to go.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by slapshot5 » 13 May 2011, 04:47
I'll volunteer to help with the needed changes. Let me know.
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: Multi-Targeting Issue
by Sloth » 13 May 2011, 06:26
Thanks for always taking care of the complicated stuff Sol. Of course I will help.friarsol wrote:For everyone who has ever reported an issue with multi-targeting: I'm currently working on this issue.
I'm not sure how long it will take, but I've gotten it far enough to proof of concept that my solution works. Gorilla Shaman was ale to target two different Moxen on the stack and kill both of them properly.
Now I just need to expand it for all of the AFs. I don't look forward to doing it in CardFactories so hopefully that won't be a major problem. I'm not certain if this will fix the multi-Triggering problem, but it is possible (and I'm hopeful that it will).
This certainly will not be making it into the next Release, so maybe I can recruit some helpers once I do all the AFs to replicate the need changes throughout everywhere else it needs to go.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Multi-Targeting Issue
by friarsol » 15 May 2011, 01:38
So I'm starting to think that we're going to have some further complications down the line with SpellAbilities the way they currently are handled. I may just take the plunge and revamp how SpellAbilities live on the Stack. Right now we just add a SpellAbility (which normally is attached to a Card) to the Stack. This causes the current issue I was looking into resolving with the Target, where things are overwritten.
I'm thinking of creating a SpellAbility_Choices which would have a pointer to the original SA, but would also have things like specific Cost payments, specific Targets, and would be an centralized place for other related things. Then instead of adding the SA to the Stack, we would add the SA_Choices.
I'm starting to lean on taking this route, but it's going to be much larger changes and take longer than the original Target stuff.
I'm thinking of creating a SpellAbility_Choices which would have a pointer to the original SA, but would also have things like specific Cost payments, specific Targets, and would be an centralized place for other related things. Then instead of adding the SA to the Stack, we would add the SA_Choices.
I'm starting to lean on taking this route, but it's going to be much larger changes and take longer than the original Target stuff.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by Hellfish » 15 May 2011, 07:09
Just throwing out a random thought here, maybe that Spellability_Choices could have a list of SAs to point to instead, which we could add other SAs to for "Splice to Arcane" cards.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-

Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Multi-Targeting Issue
by friarsol » 15 May 2011, 12:31
If I can think of an elegant way to do it, I'll try to add hooks there for Splice into Arcane. I think it'll be more similar to how SubAbilities work right now though. This is already big enough that I'm starting to worry about it, so hopefully I'll be able to get it done.Hellfish wrote:Just throwing out a random thought here, maybe that Spellability_Choices could have a list of SAs to point to instead, which we could add other SAs to for "Splice to Arcane" cards.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by friarsol » 26 May 2011, 02:49
So originally I was planning on just making this a Stack of Targets and pushing/popping as appropriate. But there's a design flaw in this which could cause some major issues. So I'm scrapping this for possibly a larger overhaul.
The ultimate goal is to not use SpellAbilities in MagicStack, and instead use something I'm calling SpellAbility_StackInstance. A StackInstance has things like: a pointer to the original SpellAbility, Targets, Cost Related information, SubStackInstances. Part of these plans entail narrowing the entry points into adding Abilities to the Stack. Ideally, we can be passing SpellAbilities in to Stack.add() and I can convert the SpellAbility on the fly to a StackInstance (and clear out SA related information at the same time). This would require the least amount of changes in the existing AF code.
Right now it looks like the biggest piece of groundwork is converting all remaining hardcoded SAs to Cost/Target system. I know there will be some hardcoded cards we can't handle in the system, I'll figure out a way to handle those when I get there, but if I can get some people to help go through and convert any remaining SAs to use Cost/Target I think that will help get everything in the same entry point.
Edit: Specifically, these functions I want to completely remove:
CardFactoryUtil.input_targetPlayer
CardFactoryUtil.input_targetCreaturePlayer
CardFactoryUtil.input_targetCreature
and if possible everything after the following codeBlock in GameAction.playSpellAbilityForFree
The last part will require moving everything over to Cost. The other three should be moving any hardcoded Spells that Target over to Target.
The ultimate goal is to not use SpellAbilities in MagicStack, and instead use something I'm calling SpellAbility_StackInstance. A StackInstance has things like: a pointer to the original SpellAbility, Targets, Cost Related information, SubStackInstances. Part of these plans entail narrowing the entry points into adding Abilities to the Stack. Ideally, we can be passing SpellAbilities in to Stack.add() and I can convert the SpellAbility on the fly to a StackInstance (and clear out SA related information at the same time). This would require the least amount of changes in the existing AF code.
Right now it looks like the biggest piece of groundwork is converting all remaining hardcoded SAs to Cost/Target system. I know there will be some hardcoded cards we can't handle in the system, I'll figure out a way to handle those when I get there, but if I can get some people to help go through and convert any remaining SAs to use Cost/Target I think that will help get everything in the same entry point.
Edit: Specifically, these functions I want to completely remove:
CardFactoryUtil.input_targetPlayer
CardFactoryUtil.input_targetCreaturePlayer
CardFactoryUtil.input_targetCreature
and if possible everything after the following codeBlock in GameAction.playSpellAbilityForFree
The last part will require moving everything over to Cost. The other three should be moving any hardcoded Spells that Target over to Target.
- Code: Select all
if (sa.getPayCosts() != null){
Target_Selection ts = new Target_Selection(sa.getTarget(), sa);
Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa);
SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment);
req.setFree(true);
req.fillRequirements();
}
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by friarsol » 03 Jun 2011, 16:17
Ok. So I think I'm on the next phase of this, as the three input_target functions are no longer used, and I've restricted the "problem" cards in playSAForFree to just a few of them, which I can handle in the separate functions that they are already using. Now to the fun part of actually ripping up MagicStack to use Instances.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by friarsol » 10 Jun 2011, 18:05
So my local build now has a functional multi-targeting system, as tested via Gorilla Shaman. As usual, some serious changes went into this so if you can think of any good test cases for me, especially corner cases I might not think of, feel free to recommend so I can give this a fair testing.
I definitely have more work, related to handling specific SA info, but I feel like testing some working code before I finish that off.
I definitely have more work, related to handling specific SA info, but I feel like testing some working code before I finish that off.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by SoulStorm » 11 Jun 2011, 07:47
Thanks for working on this Sol!
Here are some test cases for you that suffered from the multi-targeting problem:
Ronin Cliffrider with a Sword of Kaldra equipped (would only exile one creature no matter how many were damaged).
Thrashing Wumpus with Rite of Passage on the Battlefield (all the counters are added to one creature no matter how many are in play). Note that this is using the revision of Rite of Passage by Keybone which uses a trigger. I later changed Rite of Passage to keyword due to the multi-targeting problem.
Patron Wizard (currently need to let the stack resolve for each mana spent).
Forgotten Ancient (must resolve the stack for each counter transferred or each counter after the first is lost).
Here are some test cases for you that suffered from the multi-targeting problem:
Ronin Cliffrider with a Sword of Kaldra equipped (would only exile one creature no matter how many were damaged).
Thrashing Wumpus with Rite of Passage on the Battlefield (all the counters are added to one creature no matter how many are in play). Note that this is using the revision of Rite of Passage by Keybone which uses a trigger. I later changed Rite of Passage to keyword due to the multi-targeting problem.
Patron Wizard (currently need to let the stack resolve for each mana spent).
Forgotten Ancient (must resolve the stack for each counter transferred or each counter after the first is lost).
Re: Multi-Targeting Issue
by friarsol » 11 Jun 2011, 13:23
So Patron Wizard now works as well as Masticore and Phelddagrif and a few others I tried. I'll probably wait till after Chris posts the new Beta to commit these changes so if something slips through the cracks it won't affect the Beta. Forgotten Ancient should "work" now, even though it's Upkeep trigger is completely incorrect (Not an Activated Ability. Removing the Counter isn't a Cost.)
The Multi-targeting currently doesn't handle triggers. Basically it can use the same idea where the StackInstance "stores" the Triggering Object, but I'd have to look through the Trigger code to see what's going on. Does anyone know why the TriggeringObject is stored on the Card and not the Trigger/SA? Do some TriggeringObjects need to remain on the Card after the Trigger resolves?
It might be easiest testing-wise to focus on SAs first, then bring Triggers along afterwards. Since the structure would be in place, making Triggers work should be much faster.
The Multi-targeting currently doesn't handle triggers. Basically it can use the same idea where the StackInstance "stores" the Triggering Object, but I'd have to look through the Trigger code to see what's going on. Does anyone know why the TriggeringObject is stored on the Card and not the Trigger/SA? Do some TriggeringObjects need to remain on the Card after the Trigger resolves?
It might be easiest testing-wise to focus on SAs first, then bring Triggers along afterwards. Since the structure would be in place, making Triggers work should be much faster.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by jeffwadsworth » 11 Jun 2011, 17:57
Cheers.
Last edited by jeffwadsworth on 12 Jun 2011, 04:28, edited 2 times in total.
- jeffwadsworth
- Super Tester Elite
- Posts: 1172
- Joined: 20 Oct 2010, 04:47
- Location: USA
- Has thanked: 287 times
- Been thanked: 70 times
Re: Multi-Targeting Issue
by friarsol » 11 Jun 2011, 19:10
Jeff that isn't quite right either since it isn't targeted either and you can transfer to any number of creatures as it resolves
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by friarsol » 12 Jun 2011, 21:00
Since Chris has declared a Revision to base the next Beta on, I'm committing my Target changes as r9630. Please check them out. The situations that were fixed are ONLY for Activated Abilities being activated multiple times (Umezawa's Jitte, Masticore, Gorilla Shaman, etc) NOT Triggered Abilities triggering multiple times (No Mercy, some others SoulStorm suggested).
If you see anything that looks weird relating to this, I'd prefer you post them in this Thread so it's easier for me to find.
If you see anything that looks weird relating to this, I'd prefer you post them in this Thread so it's easier for me to find.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Multi-Targeting Issue
by Sloth » 13 Jun 2011, 09:04
I found something very weird:friarsol wrote:Since Chris has declared a Revision to base the next Beta on, I'm committing my Target changes as r9630. Please check them out. The situations that were fixed are ONLY for Activated Abilities being activated multiple times (Umezawa's Jitte, Masticore, Gorilla Shaman, etc) NOT Triggered Abilities triggering multiple times (No Mercy, some others SoulStorm suggested).
If you see anything that looks weird relating to this, I'd prefer you post them in this Thread so it's easier for me to find.
For some reason this fixed the issues with the human input killing spells on the stack (unless costs, Ulamog, the Infinite Gyre and Deathbringer Liege). Maybe someone else can double check this. It would be fantastic, if it is true.

-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
27 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: Timothysow and 22 guests