Trigger handling for AI
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Trigger handling for AI
by excessum » 30 Jul 2016, 12:50
What is the exact meaning of "isMandatory" in the various trigger-related methods like doTrigger()? I thought that they meant forced triggers like Necrogen Scudder or Triskaidekaphobia but TriggerHandler.runSingleTrigger() defines all triggers with no cost as mandatory. As an aside, do all non-forced triggers mean that SpellAbility.isOptionalTrigger() returns true?
Both PlayerControllerAi.doTrigger() and confirmTrigger() make calls to AiController.doTrigger() with possibly different arguments and the latter seems to take precedence.
Both PlayerControllerAi.doTrigger() and confirmTrigger() make calls to AiController.doTrigger() with possibly different arguments and the latter seems to take precedence.
Re: Trigger handling for AI
by friarsol » 30 Jul 2016, 13:11
I haven't poked in this part of the code in a while, but here's the general idea.
To be put on the stack they are set as mandatory, since all triggers are added to the stack if able, and targets are required.
During resolution, they should be checking if they are optional ('may') or have a cost, and then running that through for confirmation.
To be put on the stack they are set as mandatory, since all triggers are added to the stack if able, and targets are required.
During resolution, they should be checking if they are optional ('may') or have a cost, and then running that through for confirmation.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Trigger handling for AI
by excessum » 31 Jul 2016, 02:58
Is SpellAbility.isOptionalTrigger() the same as checking "sa.isTrigger && !mandatory"? I was trying to think of a way to consolidate canPlayAi(), chkAIDrawback() and doTriggerAINoCostWithSubs() since they only differ in how "mandatory" they are.
Re: Trigger handling for AI
by friarsol » 31 Jul 2016, 11:59
Looks like the only thing that sets optionalTrigger is this block in TriggerHandler.runSingleTrigger -excessum wrote:Is SpellAbility.isOptionalTrigger() the same as checking "sa.isTrigger && !mandatory"? I was trying to think of a way to consolidate canPlayAi(), chkAIDrawback() and doTriggerAINoCostWithSubs() since they only differ in how "mandatory" they are.
- Code: Select all
if (triggerParams.containsKey("OptionalDecider")) {
sa.setOptionalTrigger(true);
decider = AbilityUtils.getDefinedPlayers(host, triggerParams.get("OptionalDecider"), sa).get(0);
}
else if (sa instanceof AbilitySub || !sa.hasParam("Cost") || sa.getParam("Cost").equals("0")) {
mand = true;
}
else { // triggers with a cost can't be mandatory
sa.setOptionalTrigger(true);
decider = sa.getActivatingPlayer();
}
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 101 guests