Multi-Mode "Charm" spells

Okay, I seem to have gotten Charms working.
Charms are tricky because they could have different targets depending on which mode you select as the card is played.
Note that the repository already had Funeral Charm, but there was a flaw in that it only chose targets after it resolved, giving opposing players no clue what was about to happen until it was too late to cast a counterspell.
This solution is to trigger an ability as the spell is cast, have the triggered ability choose the targets, and then resolve the spell's effect onto the triggered ability's target. Here's how I handled the two relevant abilities of Fury Charm :
The only weird thing is that there will be a slight delay between the targeting and the resolving of the spell, because it's really two things that are resolving.
Charms are tricky because they could have different targets depending on which mode you select as the card is played.
Note that the repository already had Funeral Charm, but there was a flaw in that it only chose targets after it resolved, giving opposing players no clue what was about to happen until it was too late to cast a counterspell.
This solution is to trigger an ability as the spell is cast, have the triggered ability choose the targets, and then resolve the spell's effect onto the triggered ability's target. Here's how I handled the two relevant abilities of Fury Charm :
- Code: Select all
<SPELL_ABILITY layer="7c" tag="FURY_CHARM_RULE_1" simple_filter="Target">
<TARGET_DETERMINATION>
return TargetArtifactOrCreatureBad()
</TARGET_DETERMINATION>
<PLAYTIME>
Object():GetFilter():Clear()
Object():GetPlayer():BeginNewMultipleChoice( true )
Object():GetPlayer():AddMultipleChoiceAnswer( "FURY_CHARM_MODAL_1" )
Object():GetPlayer():AddMultipleChoiceAnswer( "FURY_CHARM_MODAL_2" )
Object():GetPlayer():AskMultipleChoiceQuestion( "MODAL_TITLE" )
</PLAYTIME>
<EFFECT>
if ((Object():GetMultipleChoiceResult() == 1) and (Object():GetTargetCard() ~= nil)) then
PlusOnePlusOneToTargetCard()
Trample()
end
if ((Object():GetMultipleChoiceResult() == 0) and (Object():GetTargetCard() ~= nil)) then
DestroyTargetCard()
end
</EFFECT>
<DURATION>
return UntilEndOfTurn()
</DURATION>
</SPELL_ABILITY>
<TRIGGERED_ABILITY layer="7c" zone="HAND" auto_skip="1" >
<TRIGGER value="SPELL_PLAYED">
return SelfTriggered()
</TRIGGER>
<PLAYTIME>
if Object():GetMultipleChoiceResult() == 0 then
TargetArtifactBad()
ChooseTargetArtifact()
end
if Object():GetMultipleChoiceResult() == 1 then
TargetCreatureBad()
ChooseTargetCreature()
end
</PLAYTIME>
<FILTER>
return TargetCard()
</FILTER>
<EFFECT>
<!-- Triggered ability has no real effect -->
</EFFECT>
</TRIGGERED_ABILITY>
The only weird thing is that there will be a slight delay between the targeting and the resolving of the spell, because it's really two things that are resolving.