diff --git a/script/c15555120.lua b/script/c15555120.lua new file mode 100644 index 00000000..fff17407 --- /dev/null +++ b/script/c15555120.lua @@ -0,0 +1,59 @@ +--ハイ・スピード・リレベル +function c15555120.initial_effect(c) + --Activate + local e1=Effect.CreateEffect(c) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetProperty(EFFECT_FLAG_CARD_TARGET) + e1:SetCost(c15555120.cost) + e1:SetTarget(c15555120.target) + e1:SetOperation(c15555120.activate) + c:RegisterEffect(e1) +end +function c15555120.cfilter(c,tp) + local lv=c:GetLevel() + return lv>0 and c:IsSetCard(0x2016) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost() + and Duel.IsExistingTarget(c15555120.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,lv) +end +function c15555120.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c15555120.filter(c,lv) + local clv=c:GetLevel() + return c:IsFaceup() and clv>0 and clv~=lv and c:IsType(TYPE_SYNCHRO) +end +function c15555120.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) + if chkc then + local lv=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c15555120.filter(chkc,lv) end + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.IsExistingMatchingCard(c15555120.cfilter,tp,LOCATION_GRAVE,0,1,nil,tp) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,c15555120.cfilter,tp,LOCATION_GRAVE,0,1,1,nil,tp) + Duel.Remove(g,POS_FACEUP,REASON_COST) + local lv=g:GetFirst():GetLevel() + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) + Duel.SelectTarget(tp,c15555120.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,lv) + Duel.SetTargetParam(lv) +end +function c15555120.activate(e,tp,eg,ep,ev,re,r,rp) + local lv=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + local tc=Duel.GetFirstTarget() + if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:GetLevel()~=lv then + local e1=Effect.CreateEffect(e:GetHandler()) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetCode(EFFECT_CHANGE_LEVEL) + e1:SetValue(lv) + e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) + tc:RegisterEffect(e1) + local e2=Effect.CreateEffect(e:GetHandler()) + e2:SetType(EFFECT_TYPE_SINGLE) + e2:SetCode(EFFECT_UPDATE_ATTACK) + e2:SetValue(lv*500) + e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) + tc:RegisterEffect(e2) + end +end diff --git a/script/c25290459.lua b/script/c25290459.lua new file mode 100644 index 00000000..9e941f15 --- /dev/null +++ b/script/c25290459.lua @@ -0,0 +1,56 @@ +--レベルアップ! +function c25290459.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:SetCost(c25290459.cost) + e1:SetTarget(c25290459.target) + e1:SetOperation(c25290459.activate) + c:RegisterEffect(e1) +end +function c25290459.costfilter(c,e,tp) + if not c:IsSetCard(0x41) or not c:IsAbleToGraveAsCost() or not c:IsFaceup() then return false end + local code=c:GetCode() + local class=_G["c"..code] + if class==nil or class.lvupcount==nil then return false end + return Duel.IsExistingMatchingCard(c25290459.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,nil,class,e,tp) +end +function c25290459.spfilter(c,class,e,tp) + local code=c:GetCode() + for i=1,class.lvupcount do + if code==class.lvup[i] then return c:IsCanBeSpecialSummoned(e,0,tp,true,true) end + end + return false +end +function c25290459.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c25290459.target(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.IsExistingMatchingCard(c25290459.costfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) + and Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) + local g=Duel.SelectMatchingCard(tp,c25290459.costfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp) + Duel.SendtoGrave(g,REASON_COST) + local code=g:GetFirst():GetCode() + Duel.SetTargetParam(code) + Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK) +end +function c25290459.activate(e,tp,eg,ep,ev,re,r,rp) + if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end + local code=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + local class=_G["c"..code] + if class==nil or class.lvupcount==nil then return end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) + local g=Duel.SelectMatchingCard(tp,c25290459.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,class,e,tp) + local tc=g:GetFirst() + if tc then + Duel.SpecialSummon(tc,0,tp,tp,true,true,POS_FACEUP) + if tc:GetPreviousLocation()==LOCATION_DECK then Duel.ShuffleDeck(tp) end + end +end diff --git a/script/c41925941.lua b/script/c41925941.lua new file mode 100644 index 00000000..0933137e --- /dev/null +++ b/script/c41925941.lua @@ -0,0 +1,71 @@ +--冥王の咆哮 +function c41925941.initial_effect(c) + --atkdown + local e1=Effect.CreateEffect(c) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCategory(CATEGORY_ATKCHANGE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetHintTiming(TIMING_DAMAGE_STEP) + e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) + e1:SetCondition(c41925941.condition) + e1:SetCost(c41925941.cost) + e1:SetTarget(c41925941.target) + e1:SetOperation(c41925941.operation) + c:RegisterEffect(e1) +end +function c41925941.condition(e,tp,eg,ep,ev,re,r,rp) + local phase=Duel.GetCurrentPhase() + if phase~=PHASE_DAMAGE or Duel.IsDamageCalculated() then return false end + local a=Duel.GetAttacker() + local d=Duel.GetAttackTarget() + if a:IsControler(tp) then + e:SetLabelObject(d) + return a:IsFaceup() and a:IsRace(RACE_FIEND) and a:IsRelateToBattle() + and d and d:IsFaceup() and d:IsRelateToBattle() + elseif d and d:IsControler(tp) then + e:SetLabelObject(a) + return d:IsFaceup() and d:IsRace(RACE_FIEND) and d:IsRelateToBattle() + and a and a:IsFaceup() and a:IsRelateToBattle() + end +end +function c41925941.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c41925941.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) + local tc=e:GetLabelObject() + if chkc then return chkc==tc end + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.CheckLPCost(tp,100) and (bc:IsAttackAbove(100) or bc:IsDefenseAbove(100)) and tc:IsCanBeEffectTarget(e) end + local maxc=Duel.GetLP(tp) + local maxpay=bc:GetAttack() + local def=bc:GetDefense() + if maxpay5000 then maxc=5000 end + maxc=math.floor(maxc/100)*100 + local t={} + for i=1,maxc/100 do + t[i]=i*100 + end + local cost=Duel.AnnounceNumber(tp,table.unpack(t)) + Duel.PayLPCost(tp,cost) + Duel.SetTargetCard(tc) + Duel.SetTargetParam(cost) +end +function c41925941.operation(e,tp,eg,ep,ev,re,r,rp,chk) + local bc=Duel.GetFirstTarget() + local val=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + if not bc or not bc:IsRelateToEffect(e) or not bc:IsControler(1-tp) then return end + local e1=Effect.CreateEffect(e:GetHandler()) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetCode(EFFECT_UPDATE_ATTACK) + e1:SetValue(-val) + e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) + bc:RegisterEffect(e1) + local e2=e1:Clone() + e2:SetCode(EFFECT_UPDATE_DEFENSE) + bc:RegisterEffect(e2) +end diff --git a/script/c49204190.lua b/script/c49204190.lua new file mode 100644 index 00000000..e937761a --- /dev/null +++ b/script/c49204190.lua @@ -0,0 +1,52 @@ +--奇策 +function c49204190.initial_effect(c) + --Activate + local e1=Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_ATKCHANGE) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetHintTiming(TIMING_DAMAGE_STEP) + e1:SetCondition(c49204190.condition) + e1:SetCost(c49204190.cost) + e1:SetTarget(c49204190.target) + e1:SetOperation(c49204190.activate) + c:RegisterEffect(e1) +end +function c49204190.condition(e,tp,eg,ep,ev,re,r,rp) + return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated() +end +function c49204190.cfilter(c) + return c:GetAttack()>0 and c:IsDiscardable() +end +function c49204190.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c49204190.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) + if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.IsExistingMatchingCard(c49204190.cfilter,tp,LOCATION_HAND,0,1,nil) + and Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) + local g=Duel.SelectMatchingCard(tp,c49204190.cfilter,tp,LOCATION_HAND,0,1,1,nil) + local atk=g:GetFirst():GetAttack() + Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) + Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) + Duel.SetTargetParam(atk) +end +function c49204190.activate(e,tp,eg,ep,ev,re,r,rp) + local atk=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + local tc=Duel.GetFirstTarget() + if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then + local e1=Effect.CreateEffect(e:GetHandler()) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetCode(EFFECT_UPDATE_ATTACK) + e1:SetValue(-atk) + e1:SetReset(RESET_EVENT+0x1fe0000) + tc:RegisterEffect(e1) + end +end diff --git a/script/c5052212.lua b/script/c5052212.lua new file mode 100644 index 00000000..9bca4a4c --- /dev/null +++ b/script/c5052212.lua @@ -0,0 +1,53 @@ +--イージーチューニング +function c5052212.initial_effect(c) + --Activate + local e1=Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_ATKCHANGE) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetHintTiming(TIMING_DAMAGE_STEP) + e1:SetCondition(c5052212.condition) + e1:SetCost(c5052212.cost) + e1:SetTarget(c5052212.target) + e1:SetOperation(c5052212.activate) + c:RegisterEffect(e1) +end +function c5052212.condition(e,tp,eg,ep,ev,re,r,rp) + return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated() +end +function c5052212.cfilter(c) + return c:IsType(TYPE_TUNER) and c:IsAbleToRemoveAsCost() +end +function c5052212.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c5052212.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) + if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() end + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.IsExistingMatchingCard(c5052212.cfilter,tp,LOCATION_GRAVE,0,1,nil) + and Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,c5052212.cfilter,tp,LOCATION_GRAVE,0,1,1,nil) + local atk=g:GetFirst():GetAttack() + if atk<0 then atk=0 end + Duel.Remove(g,POS_FACEUP,REASON_COST) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) + Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,nil) + Duel.SetTargetParam(atk) +end +function c5052212.activate(e,tp,eg,ep,ev,re,r,rp) + local atk=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM) + local tc=Duel.GetFirstTarget() + if tc and tc:IsRelateToEffect(e) and tc:IsFaceup() then + local e1=Effect.CreateEffect(e:GetHandler()) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetCode(EFFECT_UPDATE_ATTACK) + e1:SetReset(RESET_EVENT+0x1fe0000) + e1:SetValue(atk) + tc:RegisterEffect(e1) + end +end diff --git a/script/c67196946.lua b/script/c67196946.lua new file mode 100644 index 00000000..534ea481 --- /dev/null +++ b/script/c67196946.lua @@ -0,0 +1,62 @@ +--スター・ブラスト +function c67196946.initial_effect(c) + --activate + local e1=Effect.CreateEffect(c) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetCondition(c67196946.con) + e1:SetCost(c67196946.cost) + e1:SetTarget(c67196946.tg) + e1:SetOperation(c67196946.op) + c:RegisterEffect(e1) +end +function c67196946.con(e,tp,eg,ep,ev,re,r,rp) + return not Duel.IsPlayerAffectedByEffect(tp,EFFECT_LPCOST_CHANGE) +end +function c67196946.filter(c,lv) + return c:GetLevel()>lv +end +function c67196946.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c67196946.tg(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.CheckLPCost(tp,500) and Duel.IsExistingMatchingCard(c67196946.filter,tp,LOCATION_HAND+LOCATION_MZONE,0,1,nil,1) end + local lp=Duel.GetLP(tp) + local g=Duel.GetMatchingGroup(c67196946.filter,tp,LOCATION_HAND+LOCATION_MZONE,0,nil,1) + local tg=g:GetMaxGroup(Card.GetLevel) + local maxlv=tg:GetFirst():GetLevel() + local t={} + local l=1 + while l0 then + Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(67196946,1)) + local sg=g:Select(tp,1,1,nil) + local tc=sg:GetFirst() + if tc:IsLocation(LOCATION_MZONE) then + Duel.HintSelection(sg) + end + Duel.ConfirmCards(1-tp,sg) + if tc:IsLocation(LOCATION_HAND) then Duel.ShuffleHand(tp) end + local e1=Effect.CreateEffect(e:GetHandler()) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetCode(EFFECT_UPDATE_LEVEL) + e1:SetReset(RESET_EVENT+0xfe0000+RESET_PHASE+PHASE_END) + e1:SetValue(-ct) + tc:RegisterEffect(e1) + end +end diff --git a/script/c80161395.lua b/script/c80161395.lua new file mode 100644 index 00000000..49f5c375 --- /dev/null +++ b/script/c80161395.lua @@ -0,0 +1,40 @@ +--神秘の中華なべ +function c80161395.initial_effect(c) + --recover + local e1=Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_RECOVER) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetCost(c80161395.cost) + e1:SetTarget(c80161395.target) + e1:SetOperation(c80161395.activate) + c:RegisterEffect(e1) +end +function c80161395.cost(e,tp,eg,ep,ev,re,r,rp,chk) + e:SetLabel(1) + if chk==0 then return true end +end +function c80161395.target(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + if e:GetLabel()~=1 then return false end + e:SetLabel(0) + return Duel.CheckReleaseGroup(tp,nil,1,nil) end + local sg=Duel.SelectReleaseGroup(tp,nil,1,1,nil) + local tc=sg:GetFirst() + local atk=tc:GetAttack() + local def=tc:GetDefense() + local rec=0 + Duel.Release(tc,REASON_COST) + Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(80161395,0)) + local sel=Duel.SelectOption(tp,aux.Stringid(80161395,1),aux.Stringid(80161395,2)) + if sel==0 then rec=atk + else rec=def end + Duel.SetTargetPlayer(tp) + Duel.SetTargetParam(rec) + Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,rec) +end +function c80161395.activate(e,tp,eg,ep,ev,re,r,rp) + local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) + Duel.Recover(p,d,REASON_EFFECT) +end diff --git a/script/c97997309.lua b/script/c97997309.lua new file mode 100644 index 00000000..ffd24fef --- /dev/null +++ b/script/c97997309.lua @@ -0,0 +1,135 @@ +--ゲーテの魔導書 +function c97997309.initial_effect(c) + --Activate + local e1=Effect.CreateEffect(c) + e1:SetDescription(aux.Stringid(97997309,0)) + e1:SetCategory(CATEGORY_TOHAND) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetHintTiming(0,TIMING_END_PHASE) + e1:SetCountLimit(1,97997309+EFFECT_COUNT_CODE_OATH) + e1:SetCondition(c97997309.condition) + e1:SetCost(c97997309.cost) + e1:SetTarget(c97997309.target1) + e1:SetOperation(c97997309.activate1) + e1:SetLabel(1) + c:RegisterEffect(e1) + local e2=Effect.CreateEffect(c) + e2:SetDescription(aux.Stringid(97997309,1)) + e2:SetCategory(CATEGORY_POSITION) + e2:SetType(EFFECT_TYPE_ACTIVATE) + e2:SetCode(EVENT_FREE_CHAIN) + e2:SetHintTiming(0,0x1c0+TIMING_BATTLE_PHASE) + e2:SetCountLimit(1,97997309+EFFECT_COUNT_CODE_OATH) + e2:SetCondition(c97997309.condition) + e2:SetCost(c97997309.cost) + e2:SetTarget(c97997309.target2) + e2:SetOperation(c97997309.activate2) + e2:SetLabel(2) + c:RegisterEffect(e2) + local e3=Effect.CreateEffect(c) + e3:SetDescription(aux.Stringid(97997309,2)) + e3:SetCategory(CATEGORY_REMOVE) + e3:SetType(EFFECT_TYPE_ACTIVATE) + e3:SetCode(EVENT_FREE_CHAIN) + e3:SetHintTiming(0,0x1e0) + e3:SetCountLimit(1,97997309+EFFECT_COUNT_CODE_OATH) + e3:SetCondition(c97997309.condition) + e3:SetCost(c97997309.cost) + e3:SetTarget(c97997309.target3) + e3:SetOperation(c97997309.activate3) + e3:SetLabel(3) + c:RegisterEffect(e3) +end +c97997309.check=false +function c97997309.cfilter(c) + return c:IsFaceup() and c:IsRace(RACE_SPELLCASTER) +end +function c97997309.rfilter(c) + return c:IsSetCard(0x106e) and c:IsType(TYPE_SPELL) and c:IsAbleToRemoveAsCost() +end +function c97997309.condition(e,tp,eg,ep,ev,re,r,rp) + return Duel.IsExistingMatchingCard(c97997309.cfilter,tp,LOCATION_MZONE,0,1,nil) +end +function c97997309.cost(e,tp,eg,ep,ev,re,r,rp,chk) + c97997309.check=true + if chk==0 then return true end +end +function c97997309.filter1(c) + return c:IsFacedown() and c:IsAbleToHand() +end +function c97997309.target1(e,tp,eg,ep,ev,re,r,rp,chk) + local ct=e:GetLabel() + if chk==0 then + if not c97997309.check then return false end + c97997309.check=false + return Duel.IsExistingMatchingCard(c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,nil) + and Duel.IsExistingMatchingCard(c97997309.filter1,tp,LOCATION_SZONE,LOCATION_SZONE,1,e:GetHandler()) end + Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,ct,nil) + Duel.Remove(g,POS_FACEUP,REASON_EFFECT) + local g=Duel.GetMatchingGroup(c97997309.filter1,tp,LOCATION_SZONE,LOCATION_SZONE,e:GetHandler()) + Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) +end +function c97997309.activate1(e,tp,eg,ep,ev,re,r,rp) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) + local g=Duel.SelectMatchingCard(tp,c97997309.filter1,tp,LOCATION_SZONE,LOCATION_SZONE,1,1,e:GetHandler()) + if g:GetCount()>0 then + Duel.HintSelection(g) + Duel.SendtoHand(g,nil,REASON_EFFECT) + end +end +function c97997309.filter2(c) + return not c:IsPosition(POS_FACEUP_ATTACK) or c:IsCanTurnSet() +end +function c97997309.target2(e,tp,eg,ep,ev,re,r,rp,chk) + local ct=e:GetLabel() + if chk==0 then + if not c97997309.check then return false end + c97997309.check=false + return Duel.IsExistingMatchingCard(c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,nil) + and Duel.IsExistingMatchingCard(c97997309.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end + Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,ct,nil) + Duel.Remove(g,POS_FACEUP,REASON_EFFECT) + local g=Duel.GetMatchingGroup(c97997309.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,nil) + Duel.SetOperationInfo(0,CATEGORY_POSITION,g,1,0,0) +end +function c97997309.activate2(e,tp,eg,ep,ev,re,r,rp) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE) + local g=Duel.SelectMatchingCard(tp,c97997309.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) + local tc=g:GetFirst() + if tc then + Duel.HintSelection(g) + if tc:IsPosition(POS_FACEUP_ATTACK) then + Duel.ChangePosition(tc,POS_FACEDOWN_DEFENSE) + else + local pos=Duel.SelectPosition(tp,tc,POS_FACEUP_ATTACK+POS_FACEDOWN_DEFENSE) + Duel.ChangePosition(tc,pos) + end + end +end +function c97997309.target3(e,tp,eg,ep,ev,re,r,rp,chk) + local ct=e:GetLabel() + if chk==0 then + if not c97997309.check then return false end + c97997309.check=false + return Duel.IsExistingMatchingCard(c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,nil) + and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,nil) end + Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,c97997309.rfilter,tp,LOCATION_GRAVE,0,ct,ct,nil) + Duel.Remove(g,POS_FACEUP,REASON_EFFECT) + local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,nil) + Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) +end +function c97997309.activate3(e,tp,eg,ep,ev,re,r,rp) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) + local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,1,nil) + if g:GetCount()>0 then + Duel.HintSelection(g) + Duel.Remove(g,POS_FACEUP,REASON_EFFECT) + end +end