Skip to content

Commit fa1d945

Browse files
authored
Update c88021907.lua
1 parent cf82a7d commit fa1d945

1 file changed

Lines changed: 41 additions & 38 deletions

File tree

official/c88021907.lua

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,75 @@ function s.initial_effect(c)
66
c:EnableReviveLimit()
77
--Xyz Summon procedure: 3 Level 4 monsters
88
Xyz.AddProcedure(c,nil,4,3)
9-
--Resolve effect(s) based on the number of detached materials
9+
--If a "Mathmech" card(s) you control would be destroyed by card effect, you can detach 1 material from this card instead
1010
local e1=Effect.CreateEffect(c)
11-
e1:SetDescription(aux.Stringid(id,0))
12-
e1:SetCategory(CATEGORY_TOGRAVE)
13-
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
14-
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
15-
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
16-
e1:SetCountLimit(1,id)
17-
e1:SetCondition(function(e) return e:GetHandler():IsXyzSummoned() end)
18-
e1:SetCost(Cost.Detach(1,s.effcostmax,function(e,og) e:SetLabel(#og) end))
19-
e1:SetTarget(s.efftg)
20-
e1:SetOperation(s.effop)
11+
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
12+
e1:SetCode(EFFECT_DESTROY_REPLACE)
13+
e1:SetRange(LOCATION_MZONE)
14+
e1:SetTarget(s.reptg)
15+
e1:SetValue(function(e,c) return s.repfilter(c,e:GetHandlerPlayer()) end)
2116
c:RegisterEffect(e1)
22-
--If a "Mathmech" card(s) you control would be destroyed by card effect, you can detach 1 material from this card instead
17+
--Activate a number of effects to activate equal to the number of materials detached
2318
local e2=Effect.CreateEffect(c)
24-
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
25-
e2:SetCode(EFFECT_DESTROY_REPLACE)
26-
e2:SetRange(LOCATION_MZONE)
27-
e2:SetTarget(s.reptg)
28-
e2:SetValue(function(e,c) return s.repfilter(c,e:GetHandlerPlayer()) end)
19+
e2:SetDescription(aux.Stringid(id,0))
20+
e2:SetCategory(CATEGORY_TOGRAVE)
21+
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
22+
e2:SetProperty(EFFECT_FLAG_DELAY)
23+
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
24+
e2:SetCountLimit(1,id)
25+
e2:SetCondition(function(e) return e:GetHandler():IsXyzSummoned() end)
26+
e2:SetCost(Cost.Detach(1,s.effcostmax,function(e,og) e:SetLabel(#og) end))
27+
e2:SetTarget(s.efftg)
28+
e2:SetOperation(s.effop)
2929
c:RegisterEffect(e2)
3030
end
3131
s.listed_series={SET_MATHMECH}
32+
function s.repfilter(c,tp)
33+
return c:IsSetCard(SET_MATHMECH) and c:IsControler(tp) and c:IsOnField() and c:IsFaceup()
34+
and c:IsReason(REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
35+
end
36+
function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
37+
local c=e:GetHandler()
38+
if chk==0 then return eg:IsExists(s.repfilter,1,nil,tp) and c:CheckRemoveOverlayCard(tp,1,REASON_EFFECT) end
39+
return Duel.SelectEffectYesNo(tp,c,96) and c:RemoveOverlayCard(tp,1,1,REASON_EFFECT)>0
40+
end
3241
function s.effcostmax(e,tp)
3342
local ct=0
34-
if Duel.GetFieldGroupCount(1-tp,LOCATION_HAND,0)>0 then ct=ct+1 end
43+
if Duel.IsExistingMatchingCard(Card.IsAbleToGrave,tp,0,LOCATION_HAND,1,nil) then ct=ct+1 end
3544
if Duel.IsExistingMatchingCard(Card.IsAbleToGrave,tp,0,LOCATION_MZONE,1,nil) then ct=ct+1 end
3645
if Duel.IsExistingMatchingCard(aux.AND(Card.IsSpellTrap,Card.IsAbleToGrave),tp,0,LOCATION_ONFIELD,1,nil) then ct=ct+1 end
3746
return ct
3847
end
3948
function s.efftg(e,tp,eg,ep,ev,re,r,rp,chk)
4049
if chk==0 then return true end
41-
local ct=e:GetLabel()
42-
if ct==0 then return end
43-
local b1=Duel.GetFieldGroupCount(1-tp,LOCATION_HAND,0)>0
50+
local b1=Duel.IsExistingMatchingCard(Card.IsAbleToGrave,tp,0,LOCATION_HAND,1,nil)
4451
local b2=Duel.IsExistingMatchingCard(Card.IsAbleToGrave,tp,0,LOCATION_MZONE,1,nil)
4552
local b3=Duel.IsExistingMatchingCard(aux.AND(Card.IsSpellTrap,Card.IsAbleToGrave),tp,0,LOCATION_ONFIELD,1,nil)
4653
local options={
4754
{b1,aux.Stringid(id,1)},
4855
{b2,aux.Stringid(id,2)},
4956
{b3,aux.Stringid(id,3)}
5057
}
58+
local locations=0
5159
local selection={}
60+
local ct=e:GetLabel()
5261
for i=1,ct do
5362
local op=Duel.SelectEffect(tp,table.unpack(options))
5463
options[op][1]=false
5564
selection[op]=true
56-
local loc=op==1 and LOCATION_HAND or (op==2 and LOCATION_MZONE or LOCATION_SZONE)
57-
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,1-tp,loc)
65+
locations=locations|((op==1 and LOCATION_HAND) or (op==2 and LOCATION_MZONE) or LOCATION_ONFIELD)
5866
end
5967
e:SetLabelObject(selection)
68+
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,ct,1-tp,locations)
6069
end
6170
function s.effop(e,tp,eg,ep,ev,re,r,rp)
71+
local break_chk=false
6272
local selection=e:GetLabelObject()
6373
if selection[1] then
6474
--Send 1 random card from your opponent's hand to the GY
65-
local g=Duel.GetFieldGroup(1-tp,LOCATION_HAND,0)
75+
local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,0,LOCATION_HAND,nil)
6676
if #g>0 then
77+
break_chk=true
6778
local sg=g:RandomSelect(1-tp,1)
6879
Duel.SendtoGrave(sg,REASON_EFFECT)
6980
end
@@ -73,28 +84,20 @@ function s.effop(e,tp,eg,ep,ev,re,r,rp)
7384
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
7485
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToGrave,tp,0,LOCATION_MZONE,1,1,nil)
7586
if #g>0 then
87+
Duel.HintSelection(g)
88+
if break_chk then Duel.BreakEffect() end
89+
break_chk=true
7690
Duel.SendtoGrave(g,REASON_EFFECT)
7791
end
7892
end
7993
if selection[3] then
8094
--Send 1 Spell/Trap your opponent controls to the GY
8195
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
82-
local g=Duel.SelectMatchingCard(tp,aux.AND(Card.IsSpellTrap,Card.IsAbleToGrave),tp,0,LOCATION_SZONE,1,1,nil)
96+
local g=Duel.SelectMatchingCard(tp,aux.AND(Card.IsSpellTrap,Card.IsAbleToGrave),tp,0,LOCATION_ONFIELD,1,1,nil)
8397
if #g>0 then
98+
Duel.HintSelection(g)
99+
if break_chk then Duel.BreakEffect() end
84100
Duel.SendtoGrave(g,REASON_EFFECT)
85101
end
86102
end
87103
end
88-
function s.repfilter(c,tp)
89-
return c:IsFaceup() and c:IsSetCard(SET_MATHMECH)
90-
and c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD)
91-
and c:IsReason(REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
92-
end
93-
function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
94-
local c=e:GetHandler()
95-
if chk==0 then return eg:IsExists(s.repfilter,1,nil,tp) and c:CheckRemoveOverlayCard(tp,1,REASON_EFFECT) end
96-
if Duel.SelectEffectYesNo(tp,c,96) then
97-
c:RemoveOverlayCard(tp,1,1,REASON_EFFECT)
98-
return true
99-
else return false end
100-
end

0 commit comments

Comments
 (0)