22-- Phantom of Chaos
33local s ,id = GetID ()
44function s .initial_effect (c )
5- -- Copy
5+ -- Banish a monster and this card's name/original ATK become that monster's, and replace this effect with that monster's original effects
66 local e1 = Effect .CreateEffect (c )
77 e1 :SetDescription (aux .Stringid (id ,0 ))
88 e1 :SetCategory (CATEGORY_REMOVE )
@@ -14,14 +14,14 @@ function s.initial_effect(c)
1414 e1 :SetTarget (s .target )
1515 e1 :SetOperation (s .operation )
1616 c :RegisterEffect (e1 )
17- -- No battle damage
17+ -- Your opponent takes no battle damage from attacks involving this card
1818 local e2 = Effect .CreateEffect (c )
1919 e2 :SetType (EFFECT_TYPE_SINGLE )
2020 e2 :SetCode (EFFECT_NO_BATTLE_DAMAGE )
2121 c :RegisterEffect (e2 )
2222end
2323function s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
24- if chk == 0 then return e :GetHandler ():GetFlagEffect (id )== 0 end
24+ if chk == 0 then return not e :GetHandler ():HasFlagEffect (id ) end
2525 e :GetHandler ():RegisterFlagEffect (id ,RESETS_STANDARD_PHASE_END ,0 ,1 )
2626end
2727function s .filter (c )
@@ -32,30 +32,52 @@ function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
3232 if chk == 0 then return Duel .IsExistingTarget (s .filter ,tp ,LOCATION_MZONE |LOCATION_GRAVE ,0 ,1 ,e :GetHandler ()) end
3333 Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_REMOVE )
3434 local g = Duel .SelectTarget (tp ,s .filter ,tp ,LOCATION_MZONE |LOCATION_GRAVE ,0 ,1 ,1 ,e :GetHandler ())
35- Duel .SetOperationInfo (0 ,CATEGORY_REMOVE ,g ,1 ,0 ,0 )
35+ Duel .SetOperationInfo (0 ,CATEGORY_REMOVE ,g ,1 ,tp ,0 )
3636end
3737function s .operation (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
3838 local c = e :GetHandler ()
3939 local tc = Duel .GetFirstTarget ()
40- if c :IsRelateToEffect (e ) and c :IsFaceup () and tc and tc :IsRelateToEffect (e ) then
41- if Duel .Remove (tc ,POS_FACEUP ,REASON_EFFECT )~= 1 then return end
40+ if tc :IsRelateToEffect (e ) and Duel .Remove (tc ,POS_FACEUP ,REASON_EFFECT )> 0 and c :IsFaceup () and c :IsRelateToEffect (e ) then
4241 local code = tc :GetOriginalCode ()
43- local ba = tc :GetBaseAttack ()
42+ local atk = tc :GetBaseAttack ()
4443 local e1 = Effect .CreateEffect (c )
4544 e1 :SetType (EFFECT_TYPE_SINGLE )
4645 e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
47- e1 :SetReset (RESETS_STANDARD_PHASE_END )
4846 e1 :SetCode (EFFECT_CHANGE_CODE )
4947 e1 :SetValue (code )
48+ e1 :SetReset (RESETS_STANDARD_PHASE_END )
5049 c :RegisterEffect (e1 )
5150 local e2 = Effect .CreateEffect (c )
5251 e2 :SetType (EFFECT_TYPE_SINGLE )
5352 e2 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
54- e2 :SetReset (RESETS_STANDARD_PHASE_END )
55- e2 :SetLabelObject (e1 )
5653 e2 :SetCode (EFFECT_SET_BASE_ATTACK )
57- e2 :SetValue (ba )
54+ e2 :SetValue (atk )
55+ e2 :SetLabelObject (e1 )
56+ e2 :SetReset (RESETS_STANDARD_PHASE_END )
5857 c :RegisterEffect (e2 )
59- c :CopyEffect (code ,RESETS_STANDARD_PHASE_END ,1 )
58+ local cid = c :CopyEffect (code ,RESETS_STANDARD_PHASE_END ,1 )
59+ -- Reset the effects manually (to handle interactions with mandatory effects)
60+ local e3 = Effect .CreateEffect (c )
61+ e3 :SetDescription (aux .Stringid (id ,1 ))
62+ e3 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
63+ e3 :SetCode (EVENT_PHASE + PHASE_END )
64+ e3 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
65+ e3 :SetRange (LOCATION_MZONE )
66+ e3 :SetCountLimit (1 )
67+ e3 :SetLabel (cid )
68+ e3 :SetLabelObject (e1 )
69+ e3 :SetOperation (s .resettop )
70+ e3 :SetReset (RESETS_STANDARD_PHASE_END )
71+ c :RegisterEffect (e3 )
6072 end
61- end
73+ end
74+ function s .resettop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
75+ local c = e :GetHandler ()
76+ local cid = e :GetLabel ()
77+ c :ResetEffect (cid ,RESET_COPY )
78+ c :ResetEffect (RESET_DISABLE ,RESET_EVENT )
79+ local e1 = e :GetLabelObject ()
80+ e1 :Reset ()
81+ Duel .HintSelection (Group .FromCards (c ))
82+ Duel .Hint (HINT_OPSELECTED ,1 - tp ,e :GetDescription ())
83+ end
0 commit comments