@@ -40,13 +40,21 @@ function s.initial_effect(c)
4040 end )
4141end
4242s .listed_series = {SET_CLOWN_CREW }
43+ function s .popcount (value )
44+ local count = 0
45+ while value > 0 do
46+ value = value & (value - 1 )
47+ count = count + 1
48+ end
49+ return count
50+ end
4351function s .checkop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
4452 local g = eg :Filter (Card .IsType ,nil ,TYPE_RITUAL |TYPE_PENDULUM |TYPE_EXTRA )
4553 for rc in g :Iter () do
4654 local card_type = (rc :GetOriginalType ()&(TYPE_RITUAL |TYPE_PENDULUM |TYPE_EXTRA ))
47- local label = Duel .GetFlagEffectLabel (0 ,id )
48- if not label or card_type & label == 0 then
49- local new_label = label and ( card_type | label ) or card_type
55+ local current_label = Duel .GetFlagEffectLabel (0 ,id ) or 0
56+ local new_label = current_label | card_type
57+ if new_label ~= current_label then
5058 Duel .RegisterFlagEffect (0 ,id ,RESET_PHASE |PHASE_END ,0 ,1 )
5159 Duel .SetFlagEffectLabel (0 ,id ,new_label )
5260 end
@@ -86,12 +94,15 @@ function s.aclimit(e,re,tp)
8694 return re :IsMonsterEffect () and rc :IsOnField () and rc :IsSummonLocation (LOCATION_DECK |LOCATION_EXTRA )
8795end
8896function s .drtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
89- local ct = Duel .GetFlagEffect (0 ,id )
97+ local types = Duel .GetFlagEffectLabel (0 ,id ) or 0
98+ local ct = s .popcount (types )
9099 if chk == 0 then return ct > 0 and Duel .IsPlayerCanDraw (tp ,ct ) end
91100 Duel .SetOperationInfo (0 ,CATEGORY_DRAW ,nil ,0 ,tp ,ct )
92101end
93102function s .drop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
94- if Duel .Draw (tp ,Duel .GetFlagEffect (0 ,id ),REASON_EFFECT )> 0 then
103+ local types = Duel .GetFlagEffectLabel (0 ,id ) or 0
104+ local ct = s .popcount (types )
105+ if Duel .Draw (tp ,ct ,REASON_EFFECT )> 0 then
95106 Duel .ShuffleHand (tp )
96107 if Duel .IsExistingMatchingCard (Card .IsSSetable ,tp ,LOCATION_HAND ,0 ,1 ,nil )
97108 and Duel .SelectYesNo (tp ,aux .Stringid (id ,3 )) then
0 commit comments