|
| 1 | +--幻惑の光 |
| 2 | +--Light of Bewitchment |
| 3 | +--scripted by YoshiDuels |
| 4 | +local s,id=GetID() |
| 5 | +function s.initial_effect(c) |
| 6 | + --Change the attribute for up to 3 of opponent's monsters |
| 7 | + local e1=Effect.CreateEffect(c) |
| 8 | + e1:SetDescription(aux.Stringid(id,0)) |
| 9 | + e1:SetType(EFFECT_TYPE_ACTIVATE) |
| 10 | + e1:SetCode(EVENT_FREE_CHAIN) |
| 11 | + e1:SetCondition(s.condition) |
| 12 | + e1:SetTarget(s.target) |
| 13 | + e1:SetOperation(s.operation) |
| 14 | + c:RegisterEffect(e1) |
| 15 | + aux.GlobalCheck(s,function() |
| 16 | + local ge1=Effect.CreateEffect(c) |
| 17 | + ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) |
| 18 | + ge1:SetCode(EVENT_CHAIN_SOLVED) |
| 19 | + ge1:SetOperation(s.checkop) |
| 20 | + Duel.RegisterEffect(ge1,0) |
| 21 | + end) |
| 22 | +end |
| 23 | +function s.checkop(e,tp,eg,ep,ev,re,r,rp) |
| 24 | + if re:GetHandler():IsCode(160218074) then |
| 25 | + Duel.RegisterFlagEffect(rp,id,RESET_PHASE|PHASE_END,0,1) |
| 26 | + end |
| 27 | +end |
| 28 | +function s.condition(e,tp,eg,ep,ev,re,r,rp) |
| 29 | + return Duel.GetFlagEffect(tp,id)==0 |
| 30 | +end |
| 31 | +function s.cfilter(c,tp) |
| 32 | + return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) |
| 33 | + and Duel.IsExistingMatchingCard(s.cfilter2,tp,0,LOCATION_MZONE,1,nil,c:GetAttribute()) |
| 34 | +end |
| 35 | +function s.cfilter2(c,attr) |
| 36 | + return c:IsFaceup() and not c:IsAttribute(attr) |
| 37 | +end |
| 38 | +function s.target(e,tp,eg,ep,ev,re,r,rp,chk) |
| 39 | + if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_MZONE,0,1,nil,tp) end |
| 40 | +end |
| 41 | +function s.operation(e,tp,eg,ep,ev,re,r,rp) |
| 42 | + local c=e:GetHandler() |
| 43 | + --Requirement |
| 44 | + local g=Duel.GetMatchingGroup(s.cfilter,tp,LOCATION_MZONE,0,nil,tp) |
| 45 | + local available_attributes=g:GetBitwiseOr(function(c) return c:GetAttribute() end) |
| 46 | + local attr=Duel.AnnounceAttribute(tp,1,available_attributes) |
| 47 | + --Effect |
| 48 | + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) |
| 49 | + local g=Duel.SelectMatchingCard(tp,s.cfilter2,tp,0,LOCATION_MZONE,1,1,nil,attr) |
| 50 | + Duel.HintSelection(g) |
| 51 | + local e1=Effect.CreateEffect(c) |
| 52 | + e1:SetType(EFFECT_TYPE_SINGLE) |
| 53 | + e1:SetCode(EFFECT_CHANGE_ATTRIBUTE) |
| 54 | + e1:SetValue(attr) |
| 55 | + e1:SetReset(RESETS_STANDARD_PHASE_END) |
| 56 | + g:GetFirst():RegisterEffect(e1) |
| 57 | + if c:IsSSetable(true) and e:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then |
| 58 | + Duel.BreakEffect() |
| 59 | + c:CancelToGrave() |
| 60 | + Duel.ChangePosition(c,POS_FACEDOWN) |
| 61 | + Duel.RaiseEvent(c,EVENT_SSET,e,REASON_EFFECT,tp,tp,0) |
| 62 | + end |
| 63 | +end |
0 commit comments