Enumerating Targets
Moderators: North, BetaSteward, noxx, jeffwadsworth, JayDi, TheElk801, LevelX, CCGHQ Admins
Enumerating Targets
by duncancmt » 18 Jan 2015, 20:14
Hi!
I'm trying to implement Ink-Treader Nephilim. I'm having a hard time enumerating all the targets of modal spells like Cryptic Command. What's the interface for getting all the abilities and targets of a spell on the stack? Can spells have multiple SpellAbility's/Effect's?
I hope to be able to contribute a couple other cards to the project, but this one is giving me some trouble.
Thanks!
I'm trying to implement Ink-Treader Nephilim. I'm having a hard time enumerating all the targets of modal spells like Cryptic Command. What's the interface for getting all the abilities and targets of a spell on the stack? Can spells have multiple SpellAbility's/Effect's?
I hope to be able to contribute a couple other cards to the project, but this one is giving me some trouble.
Thanks!
- duncancmt
- Posts: 7
- Joined: 18 Jan 2015, 19:55
- Has thanked: 0 time
- Been thanked: 0 time
Re: Enumerating Targets
by duncancmt » 18 Jan 2015, 22:41
I think I figured it out. Is this approximately right?
I have another question: how do I let a player control the order in which objects go on the stack?
Thanks a lot!
EDIT: Argh! I can't get my whitespace to format correctly :(
- Code: Select all
Spell spell;
for (SpellAbility sa: spell.getSpellAbilities()){
Modes modes = sa.getModes();
for (UUID mode : modes.getSelectedModes()) {
for (Target targetInstance : modes.get(mode).getTargets()) {
for (UUID target : targetInstance.getTargets()) {
// do stuff
}
}
}
}
I have another question: how do I let a player control the order in which objects go on the stack?
Thanks a lot!
EDIT: Argh! I can't get my whitespace to format correctly :(
- duncancmt
- Posts: 7
- Joined: 18 Jan 2015, 19:55
- Has thanked: 0 time
- Been thanked: 0 time
Re: Enumerating Targets
by LevelX » 19 Jan 2015, 08:19
Looks good.duncancmt wrote:I think I figured it out. Is this approximately right?
You're right, for getting the targets you don't need to iterate through the effects.duncancmt wrote:It looks like I don't need to look through a Spell's Effect's. Is that right?
They go to the stack in the order they are created and so added to the stack.duncancmt wrote:I have another question: how do I let a player control the order in which objects go on the stack?
If more than one object is created at the same time (e.g. two trigger) the user selects the order by using the "select order of triggered effects" window that is popping up.
Or didn't I get the point of your question correctly?
-
LevelX - DEVELOPER
- Posts: 1677
- Joined: 08 Dec 2011, 15:08
- Has thanked: 174 times
- Been thanked: 374 times
Re: Enumerating Targets
by duncancmt » 19 Jan 2015, 16:18
The copies from Ink-Treader Nephilim's ability are all controlled by Ink-Treader's controller. Since they go on the stack with fixed targets, it's not like Storm where the copies can go on in any order, but the player can choose the targets after the fact. Basically, I don't know how to invoke the popup window from the effect. I took a look at Precursor Golem because that's a similar effect, and Precursor Golem just puts them on the stack in a random order without allowing the spells' controller to choose (which I believe is wrong).LevelX wrote:They go to the stack in the order they are created and so added to the stack.
If more than one object is created at the same time (e.g. two trigger) the user selects the order by using the "select order of triggered effects" window that is popping up.
Or didn't I get the point of your question correctly?
- duncancmt
- Posts: 7
- Joined: 18 Jan 2015, 19:55
- Has thanked: 0 time
- Been thanked: 0 time
Re: Enumerating Targets
by LevelX » 20 Jan 2015, 18:02
I guess such a dialog does not exist yet.
Maybe it's best to ask the caster of Ink-Treader Nephilim to set the order by clicking on the possible targets. If target was clicked, the spell copy is added to the stack and this target can't be used again.
Maybe with the option to set the targets automatically (ask the controller first).
Maybe it's best to ask the caster of Ink-Treader Nephilim to set the order by clicking on the possible targets. If target was clicked, the spell copy is added to the stack and this target can't be used again.
Maybe with the option to set the targets automatically (ask the controller first).
-
LevelX - DEVELOPER
- Posts: 1677
- Joined: 08 Dec 2011, 15:08
- Has thanked: 174 times
- Been thanked: 374 times
Re: Enumerating Targets
by duncancmt » 21 Jan 2015, 01:30
Here's what I've got right now. I make a bunch of copies, set their targets, then move them to the "pick" zone. I made a target class that chooses things out of the "pick" zone. However, when I invoke Player.choose on the "pick" zone target class, I get the text prompt, but no ability to actually click on anything to select an object. Any idea what's going on here? I could easily go back and just have them go on the stack in the order that the game creates them, but I'd rather be 100% correct.LevelX wrote:I guess such a dialog does not exist yet.
Maybe it's best to ask the caster of Ink-Treader Nephilim to set the order by clicking on the possible targets. If target was clicked, the spell copy is added to the stack and this target can't be used again.
Maybe with the option to set the targets automatically (ask the controller first).
Argh! The forum won't let me attach files, or link to my github. Take a look at <github>/duncant/mage/blob/ink_treader/Mage.Sets/src/mage/sets/guildpact/InkTreaderNephilim.java
- duncancmt
- Posts: 7
- Joined: 18 Jan 2015, 19:55
- Has thanked: 0 time
- Been thanked: 0 time
Re: Enumerating Targets
by duncancmt » 22 Jan 2015, 07:02
Ok. I figured it all out. I ended up doing what you suggested. I made a pull request with Ink-Treader Nephilim and a couple other cards that I've implemented. I also fixed up Precursor Golem so that it works correctly.LevelX wrote:Maybe it's best to ask the caster of Ink-Treader Nephilim to set the order by clicking on the possible targets. If target was clicked, the spell copy is added to the stack and this target can't be used again.
Maybe with the option to set the targets automatically (ask the controller first).
I hope it's useful!
- duncancmt
- Posts: 7
- Joined: 18 Jan 2015, 19:55
- Has thanked: 0 time
- Been thanked: 0 time
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest