-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathc51124303.lua
More file actions
159 lines (159 loc) · 5.63 KB
/
Copy pathc51124303.lua
File metadata and controls
159 lines (159 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
--影霊衣の万華鏡
function c51124303.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,51124303)
e1:SetTarget(c51124303.target)
e1:SetOperation(c51124303.activate)
c:RegisterEffect(e1)
--search
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c51124303.thcon)
e2:SetCost(c51124303.thcost)
e2:SetTarget(c51124303.thtg)
e2:SetOperation(c51124303.thop)
c:RegisterEffect(e2)
end
function c51124303.spfilter(c,e,tp,mc)
local mg=Group.FromCards(mc)
return c:IsSetCard(0xb4) and bit.band(c:GetType(),0x81)==0x81 and (not c.ritual_mat_filter or c.ritual_mat_filter(mc,tp)) and (not c.ritual_mat_group_check or c.ritual_mat_group_check(mg,tp))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true)
and mc:IsCanBeRitualMaterial(c)
end
function c51124303.rfilter(c,mc)
local mlv=mc:GetRitualLevel(c)
if mlv==mc:GetLevel() then return false end
local lv=c:GetLevel()
return lv==bit.band(mlv,0xffff) or lv==bit.rshift(mlv,16)
end
function c51124303.filter(c,e,tp)
local sg=Duel.GetMatchingGroup(c51124303.spfilter,tp,LOCATION_HAND,0,c,e,tp,c)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if c:IsLocation(LOCATION_MZONE) then ft=ft+1 end
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
return sg:IsExists(c51124303.rfilter,1,nil,c) or sg:CheckWithSumEqual(Card.GetLevel,c:GetLevel(),1,ft)
end
function c51124303.mfilter(c)
return c:GetLevel()>0 and c:IsAbleToGrave()
end
function c51124303.mzfilter(c,tp)
return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp) and c:GetSequence()<5
end
function c51124303.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<0 then return false end
local mg=Duel.GetRitualMaterial(tp)
if ft>0 then
local mg2=Duel.GetMatchingGroup(c51124303.mfilter,tp,LOCATION_EXTRA,0,nil)
mg:Merge(mg2)
else
mg=mg:Filter(c51124303.mzfilter,nil,tp)
end
return mg:IsExists(c51124303.filter,1,nil,e,tp)
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c51124303.RitualCheck(g,lv)
return g:GetSum(Card.GetLevel)==lv
end
function c51124303.RitualCheckAdditional(lv)
return function(g)
return g:GetSum(Card.GetLevel)<=lv
end
end
function c51124303.activate(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<0 then return end
::cancel::
local mg=Duel.GetRitualMaterial(tp)
if ft>0 then
local mg2=Duel.GetMatchingGroup(c51124303.mfilter,tp,LOCATION_EXTRA,0,nil)
mg:Merge(mg2)
else
mg=mg:Filter(c51124303.mzfilter,nil,tp)
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat=mg:FilterSelect(tp,c51124303.filter,1,1,nil,e,tp)
local mc=mat:GetFirst()
if not mc then return end
local sg=Duel.GetMatchingGroup(c51124303.spfilter,tp,LOCATION_HAND,0,mc,e,tp,mc)
if mc:IsLocation(LOCATION_MZONE) then ft=ft+1 end
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
local b1=sg:IsExists(c51124303.rfilter,1,nil,mc)
local b2=sg:CheckWithSumEqual(Card.GetLevel,mc:GetLevel(),1,ft)
if b1 and (not b2 or Duel.SelectYesNo(tp,aux.Stringid(51124303,0))) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tc=sg:Filter(c51124303.rfilter,nil,mc):SelectUnselect(nil,tp,false,true,1,1)
if not tc then goto cancel end
tc:SetMaterial(mat)
if not mc:IsLocation(LOCATION_EXTRA) then
Duel.ReleaseRitualMaterial(mat)
else
Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL)
end
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP)
tc:CompleteProcedure()
else
local lv=mc:GetLevel()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
aux.GCheckAdditional=c51124303.RitualCheckAdditional(lv)
local tg=sg:SelectSubGroup(tp,c51124303.RitualCheck,true,1,ft,lv)
aux.GCheckAdditional=nil
if not tg then goto cancel end
local tc=tg:GetFirst()
while tc do
tc:SetMaterial(mat)
tc=tg:GetNext()
end
if not mc:IsLocation(LOCATION_EXTRA) then
Duel.ReleaseRitualMaterial(mat)
else
Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL)
end
Duel.BreakEffect()
tc=tg:GetFirst()
while tc do
Duel.SpecialSummonStep(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP)
tc:CompleteProcedure()
tc=tg:GetNext()
end
Duel.SpecialSummonComplete()
end
end
function c51124303.thcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0
end
function c51124303.cfilter(c)
return c:IsSetCard(0xb4) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
end
function c51124303.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost()
and Duel.IsExistingMatchingCard(c51124303.cfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c51124303.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
g:AddCard(e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function c51124303.thfilter(c)
return c:IsSetCard(0xb4) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
end
function c51124303.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c51124303.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c51124303.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c51124303.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end