It is currently 29 Oct 2025, 12:31
   
Text Size

canPlayFromEffectAI

Post MTG Forge Related Programming Questions Here

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

canPlayFromEffectAI

Postby Sloth » 14 Jan 2012, 10:55

I want to add a new AI function to all AbilityFactories that checks whether a spell should be cast from effects like Cascade and Ripple. Other cards that could make use of it in the future are: Memory Plunder, Omen Machine, Sins of the Past,...

It will normaly just use the trigger AI function. The parameters will be whether it's mandatory (Omen Machine) and whether it's without mana cost.

Any suggestions or warnings?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: canPlayFromEffectAI

Postby friarsol » 14 Jan 2012, 14:27

I would have it check where the card is located too. If it's not in the AIs hand then it's card advantage and should generally be played as long as there is a minor positive effect.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: canPlayFromEffectAI

Postby Sloth » 14 Jan 2012, 15:34

friarsol wrote:I would have it check where the card is located too. If it's not in the AIs hand then it's card advantage and should generally be played as long as there is a minor positive effect.
The number of cards that have these effect on cards in your hand is next to zero and doTrigger generally returns true unless the effect is negative.

First testings showed good results.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: canPlayFromEffectAI

Postby friarsol » 14 Jan 2012, 21:49

Sloth, I have an infinite loop here:

Code: Select all
    private boolean pumpTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
        if (!ComputerUtil.canPayCost(sa)) {
            return false;
        }
        return pumpTriggerAI(af, sa, mandatory);
    }
Not sure what you were trying to do?

Edit: I put in a temporary fix. Not sure if this is what it's sposed to do, or if this exists anywhere else.
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 14 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form