1515except "|
1616special summon|
1717you cannot special summon for the rest of this turn, except|
18- '''
18+ draw|
19+ 1 |
20+ 2 |
21+ 3 |
22+ 4 |
23+ 5 |
24+ 6 |
25+ 7 |
26+ 8 |
27+ 9 |
28+ '''
1929# next, add a bunch of FROMs
2030cases_list = str (cases_list .replace ('\n ' , '' ))
2131
2232# a few templates used in many cases
2333base_target = 'function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n <edit target>\n end'
2434target_initial = 'e1:SetTarget(s.target)\n <expand effect>'
25- add_target = ('<expand effect>' ,target_initial ,'<add condition >' ,base_target )
35+ add_target = ('<expand effect>' ,target_initial ,'<add target >' ,base_target )
2636base_operation = 'function s.operation(e,tp,eg,ep,ev,re,r,rp)\n <edit operation>\n end'
2737operation_initial = 'e1:SetTarget(s.operation)\n <expand effect>'
28- add_operation = ('<expand effect>' ,operation_initial ,'<add condition >' ,base_operation )
38+ add_operation = ('<expand effect>' ,operation_initial ,'<add operation >' ,base_operation )
2939base_condition = 'function s.condition(e,tp,eg,ep,ev,re,r,rp)\n <edit condition>\n end'
3040condition_initial = 'e1:SetCondition(s.condition)\n <expand effect>'
3141add_condition = ('<expand effect>' ,condition_initial ,'<add condition>' ,base_condition )
@@ -36,58 +46,80 @@ def scriptranslate(psct):
3646 res = re .search (cases_list , psct )
3747 # check if something is scriptable
3848 if res is None :
39- return ('All autoscripts done.' ,'' ,'' )
49+ return ('All autoscripts done.' ,0 , '' ,'' )
4050 # find what option to autoscript
41- print (res )
4251 match res [0 ]:
4352 case '" once per turn' :
44- return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
45-
53+ return (res [0 ],1 , '<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
54+
4655 case 'can only be activated once per turn' :
47- return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
48-
56+ return (res [0 ],1 , '<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
57+
4958 case 'can only be used once per turn' :
50- return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
51-
59+ return (res [0 ],1 , '<expand effect>' ,'e1:SetCountLimit(1,{id,0})\n <expand effect>' )
60+
5261 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-
62+ return (res [0 ], 1 )+ add_condition + ('<edit condition>' ,'if e:GetHandler():IsStatus(STATUS_CHAINING) then return false end\n <edit condition>' )
63+
5564 case 'once per turn:' :
56- return (res [0 ],'<expand effect>' ,'e1:SetCountLimit(1)\n <expand effect>' ,'<edit settype>' ,'EFFECT_TYPE_IGNITION' ,'<edit setcode>' ,'EVENT_FREE_CHAIN' )
57-
65+ return (res [0 ],1 , '<expand effect>' ,'e1:SetCountLimit(1)\n <expand effect>' ,'<edit settype>' ,'EFFECT_TYPE_IGNITION' ,'<edit setcode>' ,'EVENT_FREE_CHAIN' )
66+
5867 case 'target ' :
59- return (res [0 ],'<add func>' ,base_filter , '<expand effect>' , target_initial , '<add target>' , base_target , '< edit target>' ,'if chkc then return chkc:IsOnField() and s.filter(chkc) end\n if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end\n Duel.Hint(HINT_SELECTMSG,tp,<hint>)\n local g=Duel.SelectTarget(tp,s.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)\n <edit target>' , '<expand effect>' , operation_initial , '<add operation>' , base_operation ,'<edit operation>' ,'local tc=Duel.GetFirstTarget()\n if tc:IsRelateToEffect(e) then\n <edit operation>\n end' ,'<expand effect>' ,'e1:SetProperty(EFFECT_FLAG_CARD_TARGET)\n <expand effect>' )
60-
68+ return (res [0 ],1 , '<add func>' ,base_filter ) + add_target + add_operation + ( '< edit target>' ,'if chkc then return chkc:IsOnField() and s.filter(chkc) end\n if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end\n Duel.Hint(HINT_SELECTMSG,tp,<hint>)\n local g=Duel.SelectTarget(tp,s.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)\n <edit target>' ,'<edit operation>' ,'local tc=Duel.GetFirstTarget()\n if tc:IsRelateToEffect(e) then\n <edit operation>\n end' ,'<expand effect>' ,'e1:SetProperty(EFFECT_FLAG_CARD_TARGET)\n <expand effect>' )
69+
6170 case 'destroy ' :
62- return (res [0 ],'<expand effect>' , target_initial , '<add target>' , base_target , '< edit target>' ,'<edit target>\n Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)' , '<expand effect>' , operation_initial , '<add operation>' , base_operation ,'<edit operation>' ,'Duel.Destroy(tc,REASON_EFFECT)\n <edit operation>' ,'<hint>' ,'HINTMSG_DESTROY' )
63-
71+ return (res [0 ],1 ) + add_target + add_operation + ( '< edit target>' ,'<edit target>\n Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)' ,'<edit operation>' ,'Duel.Destroy(tc,REASON_EFFECT)\n <edit operation>' ,'<hint>' ,'HINTMSG_DESTROY' )
72+
6473 case 'then' :
65- return (res [0 ],'<expand effect>' , operation_initial , '<add operation>' , base_operation , '<edit operation>' ,'if <condition first part effect>\n Duel.BreakEffect()\n <edit operation>\n end' )
66-
74+ return (res [0 ],1 ) + add_operation + ( '<edit operation>' ,'if <condition first part effect>\n Duel.BreakEffect()\n <edit operation>\n end' )
75+
6776 case 'and if you do' :
68- return (res [0 ],'<expand effect>' , operation_initial , '<add operation>' , base_operation , '<edit operation>' ,'if <condition first part effect>\n <edit operation>\n end' )
69-
77+ return (res [0 ],1 ) + add_operation + ( '<edit operation>' ,'if <condition first part effect>\n <edit operation>\n end' )
78+
7079 case 'also' :
71- return (res [0 ],'<expand effect>' , operation_initial , '<add operation>' , base_operation )
72-
80+ return (res [0 ],1 ,) + add_operation
81+
7382 case '(quick effect):' :
74- return (res [0 ],'<edit settype>' ,'EFFECT_TYPE_QUICK_O' ,'<edit setcode>' ,'EVENT_FREE_CHAIN' )
75-
83+ return (res [0 ], 1 ,'<edit settype>' ,'EFFECT_TYPE_QUICK_O' ,'<edit setcode>' ,'EVENT_FREE_CHAIN' )
84+
7685 case 'from your deck to your hand' :
77- return (res [0 ],'<expand effect>' ,'e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)\n <expand effect>' , '<expand effect>' , target_initial , '<add target>' , base_target , '<expand effect>' , operation_initial , '<add operation>' , base_operation , '<edit target>' ,'if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end\n <edit target>\n Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)' ,'<edit operation>' ,'Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)\n local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil)\n if #g>0 then\n Duel.SendtoHand(g,nil,REASON_EFFECT)\n Duel.ConfirmCards(1-tp,g)\n end\n <edit operation>' ,'<add func>' ,base_filter ,'<filter>' ,'c:IsAbleToHand() and <filter>' )
86+ return (res [0 ],1 , '<expand effect>' ,'e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)\n <expand effect>' ) + add_target + add_operation + ( '<edit target>' ,'if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end\n <edit target>\n Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)' ,'<edit operation>' ,'Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)\n local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil)\n if #g>0 then\n Duel.SendtoHand(g,nil,REASON_EFFECT)\n Duel.ConfirmCards(1-tp,g)\n end\n <edit operation>' ,'<add func>' ,base_filter ,'<filter>' ,'c:IsAbleToHand() and <filter>' )
7887
7988 case 'except "' :
80- return (res [0 ],'<filter>' ,'not c:IsCode(id) and <filter>' ,'<add func>' ,'s.listed_names={id}\n <add func>' )
81-
89+ return (res [0 ], 1 ,'<filter>' ,'not c:IsCode(id) and <filter>' ,'<add func>' ,'s.listed_names={id}\n <add func>' )
90+
8291 case 'special summon' :
83- 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>' )
84-
92+ return (res [0 ],1 , '<add func>' ,base_filter ) + add_target + add_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)<<amount> then return end\n Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)\n local g=Duel.SelectMatchingCard(tp,s.filter,tp,<from>,0,1,<amount> ,nil,e,tp)\n if #g>Duel.GetLocationCount(tp,LOCATION_MZONE) then \n Duel.SpecialSummon(g ,0,tp,tp,false,false,POS_FACEUP)\n <edit operation>' )
93+
8594 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 )
95+ return (res [0 ],1 )+ 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>' )
96+
97+ case 'draw' :
98+ return (res [0 ],1 ,'<expand effect>' ,'e1:SetCategory(CATEGORY_DRAW)\n e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)\n <expand effect>' )+ add_target + add_operation + ('<edit target>' ,'if chk==0 then return Duel.IsPlayerCanDraw(tp,<amount>) end\n Duel.SetTargetPlayer(tp)\n Duel.SetTargetParam(<amount>)\n Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2)\n <edit target>' ,'<edit operation>' ,'local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)\n Duel.Draw(p,d,REASON_EFFECT)\n <edit operation>' )
99+
100+ case '1 ' :
101+ return (res [0 ],99 ,'<amount>' ,'1' )
102+ case '2 ' :
103+ return (res [0 ],99 ,'<amount>' ,'2' )
104+ case '3 ' :
105+ return (res [0 ],99 ,'<amount>' ,'3' )
106+ case '4 ' :
107+ return (res [0 ],99 ,'<amount>' ,'4' )
108+ case '5 ' :
109+ return (res [0 ],99 ,'<amount>' ,'5' )
110+ case '6 ' :
111+ return (res [0 ],99 ,'<amount>' ,'6' )
112+ case '7 ' :
113+ return (res [0 ],99 ,'<amount>' ,'7' )
114+ case '8 ' :
115+ return (res [0 ],99 ,'<amount>' ,'8' )
116+ case '9 ' :
117+ return (res [0 ],99 ,'<amount>' ,'9' )
118+
119+ return ("error" , 101 , "out of case switch" , "" )
120+
89121# "return" structured as follow:
90- # (case found, toreplace, replacement, toreplace, replacement,...)
122+ # (case found, amount of allowed replacements, toreplace, replacement, toreplace, replacement,...)
91123# as many replacements as you want (executed from left to right)
92124# put back the replacement tag at the end of each replacement
93125# characters in cases_list that are used by regex must be escaped (see quick effect case)
0 commit comments