Skip to content

Commit 9326ed1

Browse files
authored
Add files via upload
added a few models
1 parent 2a0097f commit 9326ed1

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

Scripthesaurus.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
cases_list = '''
44
once per turn:|
55
" once per turn|
6+
can only be activated once per turn|
7+
can only be used once per turn|
68
target |
79
destroy |
810
then|
@@ -12,15 +14,21 @@
1214
from your deck to your hand|
1315
except "|
1416
special summon|
15-
'''
17+
you cannot special summon for the rest of this turn, except|
18+
'''
1619
# next, add a bunch of FROMs
1720
cases_list = str(cases_list.replace('\n', ''))
1821

1922
# a few templates used in many cases
2023
base_target = 'function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)\n <edit target>\nend'
2124
target_initial = 'e1:SetTarget(s.target)\n <expand effect>'
25+
add_target = ('<expand effect>',target_initial,'<add condition>',base_target)
2226
base_operation = 'function s.operation(e,tp,eg,ep,ev,re,r,rp)\n <edit operation>\nend'
2327
operation_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>\nend'
30+
condition_initial = 'e1:SetCondition(s.condition)\n <expand effect>'
31+
add_condition = ('<expand effect>',condition_initial,'<add condition>',base_condition)
2432
base_filter = 'function s.filter(c)\n return <filter>\nend\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>\nend\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

Comments
 (0)