33cases_list = '''
44once per turn:|
55" once per turn|
6+ can only be activated once per turn|
7+ can only be used once per turn|
68target |
79destroy |
810then|
1214from your deck to your hand|
1315except "|
1416special summon|
15- '''
17+ you cannot special summon for the rest of this turn, except|
18+ '''
1619# next, add a bunch of FROMs
1720cases_list = str (cases_list .replace ('\n ' , '' ))
1821
1922# a few templates used in many cases
2023base_target = 'function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n <edit target>\n end'
2124target_initial = 'e1:SetTarget(s.target)\n <expand effect>'
25+ add_target = ('<expand effect>' ,target_initial ,'<add condition>' ,base_target )
2226base_operation = 'function s.operation(e,tp,eg,ep,ev,re,r,rp)\n <edit operation>\n end'
2327operation_initial = 'e1:SetTarget(s.operation)\n <expand effect>'
28+ add_operation = ('<expand effect>' ,operation_initial ,'<add condition>' ,base_operation )
29+ base_condition = 'function s.condition(e,tp,eg,ep,ev,re,r,rp)\n <edit condition>\n end'
30+ condition_initial = 'e1:SetCondition(s.condition)\n <expand effect>'
31+ add_condition = ('<expand effect>' ,condition_initial ,'<add condition>' ,base_condition )
2432base_filter = 'function s.filter(c)\n return <filter>\n end\n <add func>'
2533
2634# func that finds the scriptable bit and returns the corresponding script
@@ -30,10 +38,20 @@ def scriptranslate(psct):
3038 if res is None :
3139 return ('All autoscripts done.' ,'' ,'' )
3240 # find what option to autoscript
41+ print (res )
3342 match res [0 ]:
3443 case '" once per turn' :
3544 return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
3645
46+ case 'can only be activated once per turn' :
47+ return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
48+
49+ case 'can only be used once per turn' :
50+ return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
51+
52+ case 'once per chain' :
53+ return (res [0 ])+ add_condition + ('<edit condition>' ,'if e:GetHandler():IsStatus(STATUS_CHAINING) then return false end\n <edit condition>' )
54+
3755 case 'once per turn:' :
3856 return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1)\n <expand effect>' ,'<edit settype>' ,'EFFECT_TYPE_IGNITION' ,'<edit setcode>' ,'EVENT_FREE_CHAIN' )
3957
@@ -63,7 +81,11 @@ def scriptranslate(psct):
6381
6482 case 'special summon' :
6583 return (res [0 ],'<add func>' ,base_filter ,'<expand effect>' ,target_initial ,'<add target>' ,base_target ,'<expand effect>' ,operation_initial ,'<add operation>' ,base_operation ,'<expand effect>' ,'e1:SetCategory(CATEGORY_SPECIAL_SUMMON)\n <expand effect>' ,'<edit target>' ,'if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0\n and Duel.IsExistingMatchingCard(s.filter,tp,<from>,0,1,nil,e,tp) end\n Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,<from>)\n <edit target>' ,'<edit operation>' ,'if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end\n Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)\n local g=Duel.SelectMatchingCard(tp,s.filter,tp,<from>,0,1,1,nil,e,tp)\n local tc=g:GetFirst()\n Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)\n <edit operation>' )
66-
84+
85+ case 'you cannot special summon for the rest of this turn, except' :
86+ ret = (res [0 ])+ add_operation + ('<edit operation>' ,'local e1=Effect.CreateEffect(c)\n e1:SetDescription(aux.Stringid(id,2))\n e1:SetType(EFFECT_TYPE_FIELD)\n e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)\n e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CLIENT_HINT)\n e1:SetTargetRange(1,0)\n e1:SetTarget(s.splimit)\n e1:SetReset(RESET_PHASE+PHASE_END)\n Duel.RegisterEffect(e1,tp)\n <edit operation>' ,'<add func>' ,'function s.splimit(e,c)\n return not <filter>\n end\n <add func>' )
87+ print ('RET IS HERE:' )
88+ print (ret )
6789# "return" structured as follow:
6890# (case found, toreplace, replacement, toreplace, replacement,...)
6991# as many replacements as you want (executed from left to right)
0 commit comments