Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



Only one spell per turn
Moderator: CCGHQ Admins
Only one spell per turn
by Eglin » 16 Mar 2012, 05:22
Hi guys,
I'm trying to code a card that prevents its owner from playing more than one spell per turn. What I've got looks elegant and concise to me - unfortunately, it doesn't work. Would you please take a look and try to give me a hand?
Thanks in advance,
Eglin
I'm trying to code a card that prevents its owner from playing more than one spell per turn. What I've got looks elegant and concise to me - unfortunately, it doesn't work. Would you please take a look and try to give me a hand?
Thanks in advance,
Eglin
- Code: Select all
<TRIGGERED_ABILITY forced_skip="1" influencing_zone="any" layer="8">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[You can't cast more than one spell each turn.]]></LOCALISED_TEXT>
<TRIGGER value="SPELL_PLAYED">
return TriggerObject():GetPlayer() == Object():GetPlayer()
</TRIGGER>
<FILTER>
return OwnedByYou() and InHand()
</FILTER>
<CONTINUOUS_ACTION>
FilteredCard():GetCurrentCharacteristics():Bool_Set( CHARACTERISTIC_CANT_BE_PLAYED, 1 )
</CONTINUOUS_ACTION>
<DURATION>
return (MTG():GetStep() == STEP_CLEANUP)
</DURATION>
</TRIGGERED_ABILITY>
Re: Only one spell per turn
by thefiremind » 16 Mar 2012, 09:22
We talk about zone attributes again...
if you look at Living Destiny, you see that its code prevents it to be played when there's no creature to reveal, by using the same characteristic you are using here. And the static ability has zone="hand".
Anyway, your idea of implementing one spell per turn is really good! I'll check if I can use it to make Ethersworn Canonist a little shorter.

Anyway, your idea of implementing one spell per turn is really good! I'll check if I can use it to make Ethersworn Canonist a little shorter.

< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: Only one spell per turn
by sadlyblue » 16 Mar 2012, 09:42
And how about the cards with flashback?
This only restricts cards in hand.
This only restricts cards in hand.
Re: Only one spell per turn
by thefiremind » 16 Mar 2012, 10:10
You got a point there. I forgot that I gave my Ethersworn Canonist an ability that overrides playing spells that don't come from hand because of this.sadlyblue wrote:And how about the cards with flashback?
This only restricts cards in hand.
For Eglin's purpose, there is the clean and functional PLAYER_CHARACTERISTIC_CANT_CAST_SPELLS, but it can't be used for Ethersworn Canonist, for obvious reasons.

I should check if the CHARACTERISTIC_CANT_BE_PLAYED can be set on cards in any zone.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: Only one spell per turn
by Eglin » 16 Mar 2012, 19:31
I was under the impression that Living Destiny was marked as hand because Living Destiny needs to be in the hand for its static effect to be active. My card needs to be in play for its static effect to be active. I can actually see the card flash when spells are played, indicating the trigger is firing - I just can't seem to make it refuse to allow further spells. Which zones are you suggesting the card be given?thefiremind wrote:We talk about zone attributes again...if you look at Living Destiny, you see that its code prevents it to be played when there's no creature to reveal, by using the same characteristic you are using here. And the static ability has zone="hand".
Anyway, your idea of implementing one spell per turn is really good! I'll check if I can use it to make Ethersworn Canonist a little shorter.
I think I might shelve what I've got now and switch to simply overriding spells after the first, like your Canonist does. Are there any side effects with that choice, like unintentional mana tapping or anything?
As an aside, I've got an issue where there's some weird interaction between this card and another one that I'm working on. Whenever I try to include both in the same deck, the game goes into some sort of endless loop whenever it tries to load the deck - this happens for both games and the in-game deck editor. It's weird, and I haven't been able to identify the cause yet.
Re: Only one spell per turn
by Eglin » 16 Mar 2012, 20:37
Here's what I ended up with:
I am interested, still, in overriding spells like thefiremind's Canonist.
- Code: Select all
<STATIC_ABILITY active_zone="player" influencing_zone="player">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[You can't cast more than one spell each turn.]]></LOCALISED_TEXT>
<CONTINUOUS_ACTION>
if MTG():DuelDataChest():Get_Int( DUEL_UTILITY_COMPARTMENT_ID_SPELLS_PLAYED_THIS_TURN ) > 0 then
Object():GetPlayer():GetCurrentCharacteristics():Bool_Set( PLAYER_CHARACTERISTIC_CANT_CAST_SPELLS, 1 )
end
</CONTINUOUS_ACTION>
<AI_BASE_SCORE score="450" zone="in_play" />
</STATIC_ABILITY>
I am interested, still, in overriding spells like thefiremind's Canonist.
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests