[DotP2013] Simic Manipulator
Posted: 15 Mar 2013, 14:57
I thought this card would be very difficult to implement.
I tried my solution, but it leads to crash (yes, crash, not error)
Is there a way to implement this card?
Here's my code:
I tried my solution, but it leads to crash (yes, crash, not error)
Is there a way to implement this card?
Here's my code:
- Code: Select all
<ACTIVATED_ABILITY filter_zone="ZONE_IN_PLAY">
<COST type="TapSelf"/>
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:AddCardType(CARD_TYPE_CREATURE)
filter:SetZone(ZONE_IN_PLAY)
</TARGET_DEFINITION>
<TARGET_DETERMINATION>
return AtLeastOneTargetFromDefinition(0)
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION>
local index = ObjectDC():Get_Int(0)
EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_CREATURE_TO_GAIN_CONTROL", EffectDC():Make_Targets(index) )
</PLAY_TIME_ACTION>
<PLAY_TIME_ACTION>
EffectController():BeginNewNumericalChoice()
EffectController():AddNumericalChoiceAnswer(Object():CountCounters(MTG():PlusOnePlusOneCounters()))
EffectController():AskNumericalChoiceQuestion("CARD_QUERY_CHOOSE_REMOVE_X_1_1_COUNTER")
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local index = ObjectDC():Get_Int(0)
local target = EffectDC():Get_Targets(index) and EffectDC():Get_Targets(index):Get_CardPtr(0)
local x = Object():GetNumericalChoiceResult()
if (target ~= nil and
Object():CountCounters(MTG():PlusOnePlusOneCounters()) > x - 1 and
target:GetCurrentPower() < x + 1) then
Object():RemoveCounters(MTG():PlusOnePlusOneCounters(), x)
ObjectDC():Set_CardPtr(index, target)
ObjectDC():Set_Int(0, index + 1)
end
</RESOLUTION_TIME_ACTION>
<CONTINUOUS_ACTION layer="4">
local count = ObjectDC():Get_Int(0)
for i=0,count do
local target = ObjectDC():Get_CardPtr(i)
if (target ~= nil) then
target:SetController(Object():GetController())
end
end
</CONTINUOUS_ACTION>
</ACTIVATED_ABILITY>