Commit 369ddafe authored by Vury Leo's avatar Vury Leo Committed by Huangnan

update cdb and add 多層融合 捕食植物トリアンティス 召喚魔術 影依 to new fusion

parent 2bac247d
...@@ -5,7 +5,7 @@ function s.initial_effect(c) ...@@ -5,7 +5,7 @@ function s.initial_effect(c)
c:EnableReviveLimit() c:EnableReviveLimit()
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),2) aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),2)
--fusion --fusion
local e1=FusionSpell.CreateSummonEffect(c,{pre_select_mat_location=LOCATION_ONFIELD}) local e1=FusionSpell.CreateSummonEffect(c,{pre_select_mat_location=LOCATION_MZONE})
e1:SetDescription(aux.Stringid(id,0)) e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_IGNITION) e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE) e1:SetRange(LOCATION_MZONE)
......
--捕食植物トリアンティス
local s,id,o=GetID()
function s.initial_effect(c)
--pendulum summon
aux.EnablePendulumAttribute(c)
-- if you Fusion Summon a DARK Fusion Monster, you can also use cards in your Pendulum Zones as monsters on the field, as material for its Fusion Summon.
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,2))
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL)
e1:SetRange(LOCATION_PZONE)
e1:SetTargetRange(LOCATION_PZONE,0)
e1:SetValue(s.mtval)
e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_INHERIT end)
-- as of 2025 May, there is no card can add LOCATION_MZONE base on material group. So we can just check pre_select_mat_location.
e1:SetLabel(0,LOCATION_MZONE) --- only avaliable when pre_select_mat_location contains LOCATION_MZONE, 1st number is limitaion of count materials, set 0 as infinity
c:RegisterEffect(e1)
--counter
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_COUNTER)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BE_MATERIAL)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCondition(s.ctcon)
e2:SetTarget(s.cttg)
e2:SetOperation(s.ctop)
c:RegisterEffect(e2)
end
function s.mtval(e,c)
return c and c:IsAttribute(ATTRIBUTE_DARK) and c:IsControler(e:GetHandlerPlayer())
end
function s.ctcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsLocation(LOCATION_GRAVE+LOCATION_EXTRA) and r==REASON_FUSION
end
function s.cttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)>0
and Duel.IsExistingMatchingCard(Card.IsCanAddCounter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,0x1041,1) end
end
function s.ctop(e,tp,eg,ep,ev,re,r,rp)
local ct=Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)
local g=Duel.GetMatchingGroup(Card.IsCanAddCounter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,0x1041,1)
if ct>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_COUNTER)
local sg=g:Select(tp,1,ct,nil)
local sc=sg:GetFirst()
while sc do
if sc:AddCounter(0x1041,1) and sc:GetLevel()>1 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_LEVEL)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetCondition(s.lvcon)
e1:SetValue(1)
sc:RegisterEffect(e1)
end
sc=sg:GetNext()
end
end
end
function s.lvcon(e)
return e:GetHandler():GetCounter(0x1041)>0
end
\ No newline at end of file
--エルシャドール・アノマリリス
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_WATER) end, true)
--splimit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--spsummon limit
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetTargetRange(1,1)
e3:SetTarget(s.sumlimit)
c:RegisterEffect(e3)
--tohand
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,0))
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e4:SetTarget(s.thtg)
e4:SetOperation(s.thop)
c:RegisterEffect(e4)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.sumlimit(e,c,sump,sumtype,sumpos,targetp,se)
return se:IsActiveType(TYPE_SPELL+TYPE_TRAP) and se:IsHasType(EFFECT_TYPE_ACTIONS)
and c:IsLocation(LOCATION_GRAVE+LOCATION_HAND) and c:IsType(TYPE_MONSTER)
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
--エルシャドール・ネフィリム
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_LIGHT) end, true)
--cannot spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--tograve
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,0))
e3:SetCategory(CATEGORY_TOGRAVE)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e3:SetTarget(s.tgtg)
e3:SetOperation(s.tgop)
c:RegisterEffect(e3)
--destroy
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_DESTROY)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_BATTLE_START)
e4:SetCondition(s.descon)
e4:SetTarget(s.destg)
e4:SetOperation(s.desop)
c:RegisterEffect(e4)
--tohand
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(id,2))
e5:SetCategory(CATEGORY_TOHAND)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e5:SetTarget(s.thtg)
e5:SetOperation(s.thop)
c:RegisterEffect(e5)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.tgfilter(c)
return c:IsSetCard(0x9d) and c:IsAbleToGrave()
end
function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.tgfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function s.tgop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,s.tgfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
function s.descon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local bc=c:GetBattleTarget()
return bc and bc:IsSummonType(SUMMON_TYPE_SPECIAL)
end
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler():GetBattleTarget(),1,0,0)
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local bc=e:GetHandler():GetBattleTarget()
if bc:IsRelateToBattle() then
Duel.Destroy(bc,REASON_EFFECT)
end
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
--影依の偽典
local s,id,o=GetID()
function s.initial_effect(c)
--activate
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_ACTIVATE)
e0:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e0)
--fusion summon
local e1=FusionSpell.CreateSummonEffect(c,{
fuslimit=s.fuslimit,
pre_select_mat_location=LOCATION_MZONE|LOCATION_GRAVE,
mat_operation_code_map={
{ [LOCATION_REMOVED] = FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff] = FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target
})
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_REMOVE+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_SZONE)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e1:SetCountLimit(1,id)
e1:SetCondition(s.condition)
c:RegisterEffect(e1)
end
function s.fuslimit(c)
return c:IsSetCard(0x9d)
end
function s.filter3(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove()
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
end
function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
return true
end
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_ONFIELD+LOCATION_GRAVE)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,0,1-tp,LOCATION_MZONE)
end
---@type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
function s.stage_x_operation(e,tc,tp,stage)
if stage==FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetDescription(aux.Stringid(id,1))
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
e1:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1,true)
local attr=tc:GetAttribute()
if tc:IsFaceup() and Duel.IsExistingMatchingCard(s.tgfilter,tp,0,LOCATION_MZONE,1,nil,attr)
and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then
Duel.BreakEffect()
local g=Duel.SelectMatchingCard(tp,s.tgfilter,tp,0,LOCATION_MZONE,1,1,nil,attr)
Duel.HintSelection(g)
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
end
function s.tgfilter(c,attr)
return c:IsFaceup() and c:IsAttribute(attr) and c:IsAbleToGrave()
end
...@@ -85,6 +85,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp) ...@@ -85,6 +85,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL) e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL)
e1:SetCountLimit(1) e1:SetCountLimit(1)
e1:SetDescription(aux.Stringid(id,3))
e1:SetTargetRange(LOCATION_GRAVE,0) e1:SetTargetRange(LOCATION_GRAVE,0)
e1:SetTarget(function(_,c) return c:IsAbleToRemove() and c:IsType(TYPE_MONSTER) end) e1:SetTarget(function(_,c) return c:IsAbleToRemove() and c:IsType(TYPE_MONSTER) end)
e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_BANISH end) e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_BANISH end)
...@@ -94,36 +95,3 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp) ...@@ -94,36 +95,3 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp)
end end
end end
end end
-- --月光舞踏会
-- local s,id=GetID()
-- function s.initial_effect(c)
-- --Activate
-- local e1=Effect.CreateEffect(c)
-- e1:SetType(EFFECT_TYPE_ACTIVATE)
-- e1:SetCode(EVENT_FREE_CHAIN)
-- c:RegisterEffect(e1)
-- --fake one, activate to get extra materials
-- local e2=Effect.CreateEffect(c)
-- e2:SetDescription(aux.Stringid(id,0))
-- e2:SetType(EFFECT_TYPE_IGNITION)
-- e2:SetRange(LOCATION_SZONE)
-- e2:SetOperation(s.op)
-- c:RegisterEffect(e2)
-- end
-- function s.op(e,tp,eg,ep,ev,re,r,rp)
-- --Once this turn, if you Fusion Summon a "Lunalight" monster, you can also banish monsters from your grave as material
-- local c=e:GetHandler()
-- local e1=Effect.CreateEffect(c)
-- e1:SetType(EFFECT_TYPE_FIELD)
-- e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL)
-- e1:SetCountLimit(1)
-- e1:SetTargetRange(LOCATION_GRAVE,0)
-- e1:SetTarget(function(e,c) return c:IsAbleToRemove() and c:IsType(TYPE_MONSTER) end)
-- e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_BANISH end)
-- e1:SetValue(function(e,c) return c and c:IsSetCard(0xdf) and c:IsControler(e:GetHandlerPlayer()) end)
-- e1:SetReset(RESET_PHASE|PHASE_END)
-- Duel.RegisterEffect(e1,tp)
-- end
--影依融合
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=FusionSpell.CreateSummonEffect(c,{
fuslimit=s.fuslimit,
pre_select_mat_location=s.pre_select_mat_location,
})
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_DECKDES)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
c:RegisterEffect(e1)
end
function s.fuslimit(c)
return c:IsSetCard(0x9d)
end
---@type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION
function s.pre_select_mat_location(tc,tp)
local res=LOCATION_HAND|LOCATION_MZONE
if Duel.IsExistingMatchingCard(s.cfilter,tp,0,LOCATION_MZONE,1,nil) then
res=res|LOCATION_DECK
end
return res
end
function s.cfilter(c)
return c:IsSummonLocation(LOCATION_EXTRA)
end
...@@ -3,8 +3,8 @@ local s,id,o=GetID() ...@@ -3,8 +3,8 @@ local s,id,o=GetID()
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
local e1=FusionSpell.CreateSummonEffect(c,{ local e1=FusionSpell.CreateSummonEffect(c,{
pre_select_mat_location=LOCATION_ONFIELD, pre_select_mat_location=LOCATION_MZONE,
pre_select_mat_opponent_location=LOCATION_ONFIELD, pre_select_mat_opponent_location=LOCATION_MZONE,
extra_target=s.extra_target extra_target=s.extra_target
}) })
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
......
--エルシャドール・エグリスタ
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_FIRE) end, true)
--cannot spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--disable spsummon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,0))
e3:SetCategory(CATEGORY_DISABLE_SUMMON+CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_SPSUMMON)
e3:SetCountLimit(1,id)
e3:SetCondition(s.condition)
e3:SetTarget(s.target)
e3:SetOperation(s.operation)
c:RegisterEffect(e3)
--tohand
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e4:SetTarget(s.thtg)
e4:SetOperation(s.thop)
c:RegisterEffect(e4)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return tp~=ep and Duel.GetCurrentChain()==0
end
function s.filter(c)
return c:IsSetCard(0x9d)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_HAND,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_DISABLE_SUMMON,eg,eg:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,eg:GetCount(),0,0)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateSummon(eg)
Duel.Destroy(eg,REASON_EFFECT)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_HAND,0,1,1,nil)
if g:GetCount()>0 then
Duel.BreakEffect()
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
--エルシャドール・アプカローネ
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFunRep(c,s.ffilter,2,true)
--cannot spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--disable
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,0))
e3:SetCategory(CATEGORY_DISABLE)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetCountLimit(1,id)
e3:SetTarget(s.distg)
e3:SetOperation(s.disop)
c:RegisterEffect(e3)
--indes battle
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e4:SetValue(1)
c:RegisterEffect(e4)
--to hand
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(id,1))
e5:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND+CATEGORY_HANDES)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetProperty(EFFECT_FLAG_DELAY)
e5:SetCountLimit(1,50907447)
e5:SetTarget(s.thtg)
e5:SetOperation(s.thop)
c:RegisterEffect(e5)
end
function s.ffilter(c,fc,sub,mg,sg)
return c:IsFusionSetCard(0x9d) and (not sg or not sg:IsExists(Card.IsFusionAttribute,1,c,c:GetFusionAttribute()))
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.distg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and aux.NegateAnyFilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(aux.NegateAnyFilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISABLE)
Duel.SelectTarget(tp,aux.NegateAnyFilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
end
function s.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsCanBeDisabledByEffect(e,false) then
Duel.NegateRelatedChain(tc,RESET_TURN_SET)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetValue(RESET_TURN_SET)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2)
if tc:IsType(TYPE_TRAPMONSTER) then
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
e3:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e3)
end
end
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil)
if g:GetCount()>0 and Duel.SendtoHand(g,nil,REASON_EFFECT)~=0 then
Duel.ConfirmCards(1-tp,g)
if g:GetFirst():IsLocation(LOCATION_HAND) and Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)>0 then
Duel.BreakEffect()
Duel.ShuffleHand(tp)
Duel.DiscardHand(tp,aux.TRUE,1,1,REASON_EFFECT+REASON_DISCARD,nil)
end
end
end
...@@ -55,7 +55,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp) ...@@ -55,7 +55,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp)
e1:SetValue(s.fuslimit) e1:SetValue(s.fuslimit)
e1:SetReset(RESET_PHASE+PHASE_END) e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp) Duel.RegisterEffect(e1,tp)
--Can also banish monsters from your GY as material once when you Fusion Summon this turn -- Can also banish monsters from your GY as material once when you Fusion Summon this turn
local e2=Effect.CreateEffect(e:GetHandler()) local e2=Effect.CreateEffect(e:GetHandler())
e2:SetDescription(aux.Stringid(id,2)) e2:SetDescription(aux.Stringid(id,2))
e2:SetType(EFFECT_TYPE_FIELD) e2:SetType(EFFECT_TYPE_FIELD)
...@@ -64,7 +64,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp) ...@@ -64,7 +64,7 @@ function s.thop(e,tp,eg,ep,ev,re,r,rp)
e2:SetCountLimit(1) e2:SetCountLimit(1)
e2:SetTarget(s.mttg) e2:SetTarget(s.mttg)
e2:SetOperation(function() return FusionSpell.FUSION_OPERATION_BANISH end) e2:SetOperation(function() return FusionSpell.FUSION_OPERATION_BANISH end)
e2:SetValue(1) e2:SetValue(function(fusion_effect,c) return c and c:IsControler(fusion_effect:GetHandlerPlayer()) end)
e2:SetReset(RESET_PHASE+PHASE_END) e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp) Duel.RegisterEffect(e2,tp)
end end
......
...@@ -2,121 +2,65 @@ ...@@ -2,121 +2,65 @@
local s,id,o=GetID() local s,id,o=GetID()
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
local e1=Effect.CreateEffect(c) local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter,
additional_fcheck=s.additional_fcheck,
additional_fgoalcheck=s.additional_fgoalcheck,
pre_select_mat_location=LOCATION_HAND|LOCATION_MZONE|LOCATION_EXTRA,
mat_operation_code_map={
{ [LOCATION_EXTRA|LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH },
{ [0xff] = FusionSpell.FUSION_OPERATION_GRAVE }
},
stage_x_operation=s.stage_x_operation
})
e1:SetDescription(aux.Stringid(id,0)) e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
s.fusion_effect=true
function s.fcheck1(ct) function s.fusfilter(c)
return function(tp,sg,fc) --- fusion monster must have maximium mertial number >= 3, material_count = {min,max} in metatable
if ct>0 and sg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)>ct then local mt=getmetatable(c)
return false if mt~=nil then
end local material_count=mt.material_count
return true if material_count~=nil and #material_count>=2 then
end if material_count[2]<3 then
end return false
function s.fcheck2(tp,sg,fc)
return sg:GetCount()>=3
end
function s.filter0(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove()
end
function s.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e)
local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)
if ct>0 then
local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_EXTRA,0,nil)
if mg2:GetCount()>0 then
mg:Merge(mg2)
end
end
aux.FCheckAdditional=s.fcheck1(ct)
aux.FGoalCheckAdditional=s.fcheck2
local res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg,nil,chkf)
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end end
end end
return res
end end
return true
end end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp ---@type FUSION_FGCHECK_FUNCTION
local mg1=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e) function s.additional_fcheck(tp,mg,fc,all_mg)
local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE) --- material from extra deck by this fusion spell can not exceed monster opponent controls
if ct>0 then local count_from_extra=mg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)
local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_EXTRA,0,nil) local monster_count_of_opponet=Duel.GetMatchingGroupCount(aux.TRUE,tp,0,LOCATION_MZONE,nil)
if mg2:GetCount()>0 then if count_from_extra>monster_count_of_opponet then
mg1:Merge(mg2) return false
end
end end
aux.FCheckAdditional=s.fcheck1(ct) return true
aux.FGoalCheckAdditional=s.fcheck2 end
local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil ---@type FUSION_FGCHECK_FUNCTION
local sg2=nil function s.additional_fgoalcheck(tp,mg,fc,all_mg)
local ce=Duel.GetChainMaterial(tp) return all_mg:GetCount()>=3
if ce~=nil then end
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp) ---@type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
local mf=ce:GetValue() function s.stage_x_operation(e,tc,tp,stage,mg_fuison_spell,mg_all)
sg2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf) if stage==FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE then
end local exmat=mg_fuison_spell:Filter(Card.IsPreviousLocation,nil,LOCATION_EXTRA)
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if tc then
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or ce and not Duel.SelectYesNo(tp,ce:GetDescription())) then
aux.FCheckAdditional=s.fcheck1(ct)
aux.FGoalCheckAdditional=s.fcheck2
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
tc:SetMaterial(mat1)
local rg=mat1:Filter(Card.IsLocation,nil,LOCATION_EXTRA)
mat1:Sub(rg)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.Remove(rg,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummonStep(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
elseif ce then
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
local exmat=tc:GetMaterial():Filter(Card.IsPreviousLocation,nil,LOCATION_EXTRA)
if #exmat>0 then if #exmat>0 then
local dam=exmat:GetSum(Card.GetAttack) local dam=exmat:GetSum(Card.GetAttack)
local lp=Duel.GetLP(tp) if dam>0 then
if lp>=dam then local lp=Duel.GetLP(tp)
Duel.SetLP(tp,lp-dam) if lp>=dam then
else Duel.SetLP(tp,lp-dam)
Duel.SetLP(tp,0) else
Duel.SetLP(tp,0)
end
end end
end end
Duel.SpecialSummonComplete()
tc:CompleteProcedure()
end end
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
end end
--魂写しの同化
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_CONTINUOUS_TARGET)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)
--Equip limit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_EQUIP_LIMIT)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetValue(s.eqlimit)
c:RegisterEffect(e2)
--spsummon
local e3=FusionSpell.CreateSummonEffect(c,{
fuslimit=s.fuslimit,
gc=s.gc
})
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_SZONE)
e3:SetCountLimit(1,id)
c:RegisterEffect(e3)
end
function s.eqlimit(e,c)
return c:IsSetCard(0x9d)
end
function s.filter(c)
return c:IsFaceup() and c:IsSetCard(0x9d)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATTRIBUTE)
local att=Duel.AnnounceAttribute(tp,1,ATTRIBUTE_ALL&~g:GetFirst():GetAttribute())
e:SetLabel(att)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Equip(tp,c,tc)
local att=e:GetLabel()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_EQUIP)
e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
e1:SetValue(att)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
c:RegisterEffect(e1)
c:SetHint(CHINT_ATTRIBUTE,att)
end
end
function s.fuslimit(c)
return c:IsSetCard(0x9d)
end
--- @param e Effect the fusion effect
function s.gc(e)
return e:GetHandler():GetEquipTarget()
end
--神の写し身との接触
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=FusionSpell.CreateSummonEffect(c,{
fuslimit=s.fuslimit,
})
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
c:RegisterEffect(e1)
end
function s.fuslimit(c)
return c:IsSetCard(0x9d)
end
...@@ -7,7 +7,7 @@ function s.initial_effect(c) ...@@ -7,7 +7,7 @@ function s.initial_effect(c)
--spsummon --spsummon
local e1=FusionSpell.CreateSummonEffect(c,{ local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter, fusfilter=s.fusfilter,
pre_select_mat_location=LOCATION_GRAVE|LOCATION_ONFIELD|LOCATION_REMOVED, pre_select_mat_location=LOCATION_GRAVE|LOCATION_MZONE|LOCATION_REMOVED,
mat_operation_code_map={ mat_operation_code_map={
{ [LOCATION_DECK] = FusionSpell.FUSION_OPERATION_GRAVE }, { [LOCATION_DECK] = FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff] = FusionSpell.FUSION_OPERATION_SHUFFLE } { [0xff] = FusionSpell.FUSION_OPERATION_SHUFFLE }
......
--エルシャドール・ウェンディゴ
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_WIND) end, true)
--cannot spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--indes
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,0))
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetRange(LOCATION_MZONE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetCountLimit(1,id)
e3:SetTarget(s.indtg)
e3:SetOperation(s.indop)
c:RegisterEffect(e3)
--tohand
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e4:SetTarget(s.thtg)
e4:SetOperation(s.thop)
c:RegisterEffect(e4)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.indtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) end
if chk==0 then return Duel.IsExistingTarget(nil,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,nil,tp,LOCATION_MZONE,0,1,1,nil)
end
function s.indop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(s.indval)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
function s.indval(e,c)
return c:IsSummonType(SUMMON_TYPE_SPECIAL)
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
--召喚魔術
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=FusionSpell.CreateSummonEffect(c,{
pre_select_mat_location=s.pre_select_mat_location,
pre_select_mat_opponent_location=s.pre_select_mat_opponent_location,
mat_operation_code_map={
{ [LOCATION_GRAVE|LOCATION_ONFIELD] = FusionSpell.FUSION_OPERATION_BANISH },
{ [0xff] = FusionSpell.FUSION_OPERATION_GRAVE }
},
extra_target=s.extra_target
})
e1:SetDescription(aux.Stringid(id,0))
c:RegisterEffect(e1)
--to deck
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TODECK+CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,id)
e2:SetTarget(s.tdtg)
e2:SetOperation(s.tdop)
c:RegisterEffect(e2)
end
---@type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION
function s.pre_select_mat_location(tc,tp)
local res=LOCATION_HAND
if tc:IsSetCard(0xf4) then
res=res|LOCATION_MZONE|LOCATION_GRAVE
end
return res
end
---@type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION
function s.pre_select_mat_opponent_location(tc,tp)
local res=0
if tc:IsSetCard(0xf4) then
res=res|LOCATION_GRAVE
end
return res
end
function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
return true
end
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,0,LOCATION_MZONE+LOCATION_GRAVE)
end
function s.thfilter(c)
return c:IsFaceup() and c:IsCode(86120751) and c:IsAbleToHand()
end
function s.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return e:GetHandler():IsAbleToDeck()
and Duel.IsExistingTarget(s.thfilter,tp,LOCATION_REMOVED,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_REMOVED,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.tdop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0 and tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
--エルシャドール・シェキナーガ
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_EARTH) end, true)
--cannot spsummon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,0))
e3:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,id)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e3:SetCode(EVENT_CHAINING)
e3:SetCondition(s.discon)
e3:SetTarget(s.distg)
e3:SetOperation(s.disop)
c:RegisterEffect(e3)
--tohand
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_TOHAND)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e4:SetTarget(s.thtg)
e4:SetOperation(s.thop)
c:RegisterEffect(e4)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.discon(e,tp,eg,ep,ev,re,r,rp)
if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then return false end
local loc=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_LOCATION)
return loc==LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER)
and re:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL)
and Duel.IsChainNegatable(ev)
end
function s.filter(c)
return c:IsSetCard(0x9d)
end
function s.distg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_HAND,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
end
end
function s.disop(e,tp,eg,ep,ev,re,r,rp)
if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg,REASON_EFFECT)>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_HAND,0,1,1,nil)
if g:GetCount()>0 then
Duel.BreakEffect()
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
...@@ -36,7 +36,7 @@ function s.initial_effect(c) ...@@ -36,7 +36,7 @@ function s.initial_effect(c)
e4:SetTarget(function(_,mc) return mc:IsFaceup() and mc:IsType(TYPE_MONSTER) end) e4:SetTarget(function(_,mc) return mc:IsFaceup() and mc:IsType(TYPE_MONSTER) end)
e4:SetCost(s.extra_material_cost) e4:SetCost(s.extra_material_cost)
e4:SetOperation(function() return FusionSpell.FUSION_OPERATION_INHERIT end) e4:SetOperation(function() return FusionSpell.FUSION_OPERATION_INHERIT end)
e4:SetValue(function(fusion_effect,tc) return tc and tc:IsSetCard(0x9d) and c:IsControler(fusion_effect:GetHandlerPlayer()) end) e4:SetValue(function(fusion_effect,tc) return tc and tc:IsSetCard(0x9d) and tc:IsControler(fusion_effect:GetHandlerPlayer()) end)
e4:SetLabel(1) --- at most 1 material per fusion effect e4:SetLabel(1) --- at most 1 material per fusion effect
c:RegisterEffect(e4) c:RegisterEffect(e4)
end end
......
...@@ -25,6 +25,7 @@ end ...@@ -25,6 +25,7 @@ end
function s.fusop(e,tp,eg,ep,ev,re,r,rp) function s.fusop(e,tp,eg,ep,ev,re,r,rp)
--Once this turn, if you Fusion Summon an "Amazoness" Fusion Monster this turn, you can also send 1 "Amazoness" monster from your Extra Deck to the GY as material. --Once this turn, if you Fusion Summon an "Amazoness" Fusion Monster this turn, you can also send 1 "Amazoness" monster from your Extra Deck to the GY as material.
local e1=Effect.CreateEffect(e:GetHandler()) local e1=Effect.CreateEffect(e:GetHandler())
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL) e1:SetCode(EFFECT_EXTRA_FUSION_MATERIAL)
e1:SetCountLimit(1) e1:SetCountLimit(1)
......
--シャドール・ネフィリム
local s,id,o=GetID()
function s.initial_effect(c)
c:EnableReviveLimit()
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_FLIP),2,2)
--fusion summon
local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter
})
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,id)
c:RegisterEffect(e1)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,id+o)
e2:SetTarget(s.sptg2)
e2:SetOperation(s.spop2)
c:RegisterEffect(e2)
end
function s.fusfilter(c)
return c:IsSetCard(0x9d)
end
function s.cfilter(c,tp)
return (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and c:IsSetCard(0x9d) and c:IsAbleToGrave() and Duel.GetMZoneCount(tp,c)>0
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,nil,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local tg=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,nil,tp)
local c=e:GetHandler()
local tc=tg:GetFirst()
if tc and Duel.SendtoGrave(tc,REASON_EFFECT)~=0 and tc:IsLocation(LOCATION_GRAVE)
and c:IsRelateToEffect(e) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
...@@ -20,7 +20,7 @@ end ...@@ -20,7 +20,7 @@ end
---@type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION ---@type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION
function s.pre_select_mat_location(tc,tp) function s.pre_select_mat_location(tc,tp)
local res=LOCATION_HAND|LOCATION_ONFIELD local res=LOCATION_HAND|LOCATION_MZONE
if Duel.IsExistingMatchingCard(s.cfilter,tp,0,LOCATION_MZONE,1,nil) then if Duel.IsExistingMatchingCard(s.cfilter,tp,0,LOCATION_MZONE,1,nil) then
res=res|LOCATION_DECK|LOCATION_EXTRA res=res|LOCATION_DECK|LOCATION_EXTRA
end end
......
--エルシャドール・ミドラーシュ
local s,id,o=GetID()
function s.initial_effect(c)
Duel.EnableGlobalFlag(GLOBALFLAG_SPSUMMON_COUNT)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,function (mc) return mc:IsFusionSetCard(0x9d) end, function (mc) return aux.FShaddollFilter2(mc,ATTRIBUTE_DARK) end, true)
--splimit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetCode(EFFECT_SPSUMMON_CONDITION)
e2:SetRange(LOCATION_EXTRA)
e2:SetValue(s.splimit)
c:RegisterEffect(e2)
--indes
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e3:SetRange(LOCATION_MZONE)
e3:SetValue(aux.indoval)
c:RegisterEffect(e3)
--spsummon count limit
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD)
e4:SetCode(EFFECT_SPSUMMON_COUNT_LIMIT)
e4:SetRange(LOCATION_MZONE)
e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e4:SetTargetRange(1,1)
e4:SetValue(1)
c:RegisterEffect(e4)
--tohand
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(id,0))
e5:SetCategory(CATEGORY_TOHAND)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e5:SetTarget(s.thtg)
e5:SetOperation(s.thop)
c:RegisterEffect(e5)
end
function s.splimit(e,se,sp,st)
return bit.band(st,SUMMON_TYPE_FUSION)==SUMMON_TYPE_FUSION
end
function s.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
\ No newline at end of file
...@@ -1356,96 +1356,10 @@ end ...@@ -1356,96 +1356,10 @@ end
function Auxiliary.AddFusionProcCode2FunRep(c,code1,code2,f,minc,maxc,sub,insf) function Auxiliary.AddFusionProcCode2FunRep(c,code1,code2,f,minc,maxc,sub,insf)
Auxiliary.AddFusionProcMixRep(c,sub,insf,f,minc,maxc,code1,code2) Auxiliary.AddFusionProcMixRep(c,sub,insf,f,minc,maxc,code1,code2)
end end
---Fusion monster, Shaddoll materials ---Fusion monster, Shaddoll materials can use 影依の原核
---@param c Card
---@param attr integer
function Auxiliary.AddFusionProcShaddoll(c,attr)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_FUSION_MATERIAL)
e1:SetCondition(Auxiliary.FShaddollCondition(attr))
e1:SetOperation(Auxiliary.FShaddollOperation(attr))
c:RegisterEffect(e1)
end
function Auxiliary.FShaddollFilter(c,fc,attr)
return (Auxiliary.FShaddollFilter1(c) or Auxiliary.FShaddollFilter2(c,attr)) and FusionSpell.IsCanBeFusionMaterial(c,fc) and not c:IsHasEffect(6205579)
end
function Auxiliary.FShaddollExFilter(c,fc,attr,fe)
return c:IsFaceup() and not c:IsImmuneToEffect(fe) and Auxiliary.FShaddollFilter(c,fc,attr)
end
function Auxiliary.FShaddollFilter1(c)
return c:IsFusionSetCard(0x9d)
end
function Auxiliary.FShaddollFilter2(c,attr) function Auxiliary.FShaddollFilter2(c,attr)
return c:IsFusionAttribute(attr) or c:IsHasEffect(4904633) return c:IsFusionAttribute(attr) or c:IsHasEffect(4904633)
end end
function Auxiliary.FShaddollSpFilter1(c,fc,tp,mg,exg,attr,chkf)
return mg:IsExists(Auxiliary.FShaddollSpFilter2,1,c,fc,tp,c,attr,chkf)
or (exg and exg:IsExists(Auxiliary.FShaddollSpFilter2,1,c,fc,tp,c,attr,chkf))
end
function Auxiliary.FShaddollSpFilter2(c,fc,tp,mc,attr,chkf)
local sg=Group.FromCards(c,mc)
if sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end
if not Auxiliary.MustMaterialCheck(sg,tp,EFFECT_MUST_BE_FMATERIAL) then return false end
if Auxiliary.FCheckAdditional and not Auxiliary.FCheckAdditional(tp,sg,fc)
or Auxiliary.FGoalCheckAdditional and not Auxiliary.FGoalCheckAdditional(tp,sg,fc) then return false end
return ((Auxiliary.FShaddollFilter1(c) and Auxiliary.FShaddollFilter2(mc,attr))
or (Auxiliary.FShaddollFilter2(c,attr) and Auxiliary.FShaddollFilter1(mc)))
and (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0)
end
function Auxiliary.FShaddollCondition(attr)
return function(e,g,gc,chkf)
if g==nil then return Auxiliary.MustMaterialCheck(nil,e:GetHandlerPlayer(),EFFECT_MUST_BE_FMATERIAL) end
local c=e:GetHandler()
local mg=g:Filter(Auxiliary.FShaddollFilter,nil,c,attr)
local tp=e:GetHandlerPlayer()
local fc=Duel.GetFieldCard(tp,LOCATION_FZONE,0)
local exg=nil
if fc and fc:IsHasEffect(81788994) and fc:IsCanRemoveCounter(tp,0x16,3,REASON_EFFECT) then
local fe=fc:IsHasEffect(81788994)
exg=Duel.GetMatchingGroup(Auxiliary.FShaddollExFilter,tp,0,LOCATION_MZONE,mg,c,attr,fe)
end
if gc then
if not mg:IsContains(gc) then return false end
return Auxiliary.FShaddollSpFilter1(gc,c,tp,mg,exg,attr,chkf)
end
return mg:IsExists(Auxiliary.FShaddollSpFilter1,1,nil,c,tp,mg,exg,attr,chkf)
end
end
function Auxiliary.FShaddollOperation(attr)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkf)
local c=e:GetHandler()
local mg=eg:Filter(Auxiliary.FShaddollFilter,nil,c,attr)
local fc=Duel.GetFieldCard(tp,LOCATION_FZONE,0)
local exg=nil
if fc and fc:IsHasEffect(81788994) and fc:IsCanRemoveCounter(tp,0x16,3,REASON_EFFECT) then
local fe=fc:IsHasEffect(81788994)
exg=Duel.GetMatchingGroup(Auxiliary.FShaddollExFilter,tp,0,LOCATION_MZONE,mg,c,attr,fe)
end
local g=nil
if gc then
g=Group.FromCards(gc)
mg:RemoveCard(gc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
g=mg:FilterSelect(tp,Auxiliary.FShaddollSpFilter1,1,1,nil,c,tp,mg,exg,attr,chkf)
mg:Sub(g)
end
if exg and exg:IsExists(Auxiliary.FShaddollSpFilter2,1,nil,c,tp,g:GetFirst(),attr,chkf)
and (mg:GetCount()==0 or (exg:GetCount()>0 and Duel.SelectYesNo(tp,Auxiliary.Stringid(81788994,0)))) then
fc:RemoveCounter(tp,0x16,3,REASON_EFFECT)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg=exg:FilterSelect(tp,Auxiliary.FShaddollSpFilter2,1,1,nil,c,tp,g:GetFirst(),attr,chkf)
g:Merge(sg)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg=mg:FilterSelect(tp,Auxiliary.FShaddollSpFilter2,1,1,nil,c,tp,g:GetFirst(),attr,chkf)
g:Merge(sg)
end
Duel.SetFusionMaterial(g)
end
end
--Fusion Summon Effect --Fusion Summon Effect
function Auxiliary.FMaterialFilter(c,e,tp) function Auxiliary.FMaterialFilter(c,e,tp)
...@@ -2361,7 +2275,7 @@ FusionSpell = {} ...@@ -2361,7 +2275,7 @@ FusionSpell = {}
--- Defaults to `LOCATION_HAND | LOCATION_MZONE`. --- Defaults to `LOCATION_HAND | LOCATION_MZONE`.
--- @field mat_operation_code_map? {[integer]:FUSION_OPERATION_CODE}[] --- @field mat_operation_code_map? {[integer]:FUSION_OPERATION_CODE}[]
--- List of operations to perform on materials based on location. --- List of operations to perform on materials based on location.
--- Defaults to: --- Defaults to:
--- ```lua --- ```lua
--- { --- {
--- { [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH }, --- { [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH },
...@@ -2371,9 +2285,9 @@ FusionSpell = {} ...@@ -2371,9 +2285,9 @@ FusionSpell = {}
--- @field post_select_mat_location? integer --- @field post_select_mat_location? integer
--- Location(s) to look for materials after they've been selected. --- Location(s) to look for materials after they've been selected.
--- @field additional_fcheck? FUSION_FGCHECK_FUNCTION --- @field additional_fcheck? FUSION_FGCHECK_FUNCTION
--- Optional quick check to validate the selected material group.
--- @field additional_fgoalcheck? FUSION_FGCHECK_FUNCTION
--- Optional final check to validate the selected material group. --- Optional final check to validate the selected material group.
--- @field additional_gcheck? FUSION_FGCHECK_FUNCTION
--- Optional quick check to validate partial material groups (for performance).
--- @field fuslocation? integer --- @field fuslocation? integer
--- The location to summon Fusion Monsters from. Defaults to `LOCATION_EXTRA`. --- The location to summon Fusion Monsters from. Defaults to `LOCATION_EXTRA`.
--- @field sumtype? integer --- @field sumtype? integer
...@@ -2387,6 +2301,8 @@ FusionSpell = {} ...@@ -2387,6 +2301,8 @@ FusionSpell = {}
--- Optional extra targeting logic (e.g., to show hints or manage chains). --- Optional extra targeting logic (e.g., to show hints or manage chains).
--- @field pre_select_mat_opponent_location? integer|fun():integer --- @field pre_select_mat_opponent_location? integer|fun():integer
--- Opponent-side locations to search for materials before they are selected. --- Opponent-side locations to search for materials before they are selected.
--- @field gc? fun(e:Effect):Card|nil
--- Function that returns a card that must be included in the fusion materials
...@@ -2456,13 +2372,14 @@ function FusionSpell.CreateSummonEffect(c,opts) ...@@ -2456,13 +2372,14 @@ function FusionSpell.CreateSummonEffect(c,opts)
local mat_operation_code_map=opts.mat_operation_code_map or {} local mat_operation_code_map=opts.mat_operation_code_map or {}
local post_select_mat_location=opts.post_select_mat_location local post_select_mat_location=opts.post_select_mat_location
local additional_fcheck=opts.additional_fcheck or aux.TRUE local additional_fcheck=opts.additional_fcheck or aux.TRUE
local additional_gcheck=opts.additional_gcheck or aux.TRUE local additional_fgoalcheck=opts.additional_fgoalcheck or aux.TRUE
local fuslocation=opts.fuslocation or LOCATION_EXTRA local fuslocation=opts.fuslocation or LOCATION_EXTRA
local sumtype=opts.sumtype or SUMMON_TYPE_FUSION local sumtype=opts.sumtype or SUMMON_TYPE_FUSION
local sumpos=opts.sumpos or POS_FACEUP local sumpos=opts.sumpos or POS_FACEUP
local stage_x_operation=opts.stage_x_operation or aux.TRUE local stage_x_operation=opts.stage_x_operation or aux.TRUE
local extra_target=opts.extra_target or aux.TRUE local extra_target=opts.extra_target or aux.TRUE
local pre_select_mat_opponent_location=opts.pre_select_mat_opponent_location or 0 local pre_select_mat_opponent_location=opts.pre_select_mat_opponent_location or 0
local gc=opts.gc or function() return nil end
-- Ensure material operation fallbacks are present -- Ensure material operation fallbacks are present
table.insert(mat_operation_code_map,{ [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH }) table.insert(mat_operation_code_map,{ [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH })
...@@ -2480,12 +2397,13 @@ function FusionSpell.CreateSummonEffect(c,opts) ...@@ -2480,12 +2397,13 @@ function FusionSpell.CreateSummonEffect(c,opts)
mat_operation_code_map, mat_operation_code_map,
post_select_mat_location, post_select_mat_location,
additional_fcheck, additional_fcheck,
additional_gcheck, additional_fgoalcheck,
fuslocation, fuslocation,
sumtype, sumtype,
sumpos, sumpos,
extra_target, extra_target,
pre_select_mat_opponent_location pre_select_mat_opponent_location,
gc
)) ))
e1:SetOperation(FusionSpell.GetSummonOperation( e1:SetOperation(FusionSpell.GetSummonOperation(
fusfilter, fusfilter,
...@@ -2494,12 +2412,13 @@ function FusionSpell.CreateSummonEffect(c,opts) ...@@ -2494,12 +2412,13 @@ function FusionSpell.CreateSummonEffect(c,opts)
mat_operation_code_map, mat_operation_code_map,
post_select_mat_location, post_select_mat_location,
additional_fcheck, additional_fcheck,
additional_gcheck, additional_fgoalcheck,
fuslocation, fuslocation,
sumtype, sumtype,
sumpos, sumpos,
stage_x_operation, stage_x_operation,
pre_select_mat_opponent_location pre_select_mat_opponent_location,
gc
)) ))
return e1 return e1
...@@ -2510,13 +2429,14 @@ end ...@@ -2510,13 +2429,14 @@ end
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials ---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order ---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order
---@param post_select_mat_location integer? location where to find the materials after known the materials ---@param post_select_mat_location integer? location where to find the materials after known the materials
---@param additional_fcheck FUSION_FGCHECK_FUNCTION function to check the final material group fits the requirement ---@param additional_fcheck FUSION_FGCHECK_FUNCTION function to check the partial material group fits the requirement
---@param additional_gcheck FUSION_FGCHECK_FUNCTION function to check the part of potiential material group fits the requirement to improve performance ---@param additional_fgoalcheck FUSION_FGCHECK_FUNCTION function to check the final material group fits the requirement
---@param fuslocation integer location where to summon fusion monsters from (default LOCATION_EXTRA), use it on Clock Lizard ---@param fuslocation integer location where to summon fusion monsters from (default LOCATION_EXTRA), use it on Clock Lizard
---@param sumtype integer summon type ---@param sumtype integer summon type
---@param sumpos integer summon position ---@param sumpos integer summon position
---@param extra_target fun(e:Effect, tp:integer, eg:Group, ep:integer, ev:integer, re:Effect, r:integer, rp:integer, chk:integer):nil extra target function to add opration info etc ---@param extra_target fun(e:Effect, tp:integer, eg:Group, ep:integer, ev:integer, re:Effect, r:integer, rp:integer, chk:integer):nil extra target function to add opration info etc
---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
---@param gc fun(e:Effect):Card|nil Function that returns a card that must be included in the fusion materials
function FusionSpell.GetSummonTarget( function FusionSpell.GetSummonTarget(
fusfilter, fusfilter,
matfilter, matfilter,
...@@ -2524,12 +2444,14 @@ function FusionSpell.GetSummonTarget( ...@@ -2524,12 +2444,14 @@ function FusionSpell.GetSummonTarget(
mat_operation_code_map, mat_operation_code_map,
post_select_mat_location, post_select_mat_location,
additional_fcheck, additional_fcheck,
additional_gcheck, additional_fgoalcheck,
fuslocation, fuslocation,
sumtype, sumtype,
sumpos, sumpos,
extra_target, extra_target,
pre_select_mat_opponent_location) pre_select_mat_opponent_location,
gc
)
return function(e,tp,eg,ep,ev,re,r,rp,chk) return function(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then if chk==0 then
if extra_target(e,tp,eg,ep,ev,re,r,rp,chk)==false then if extra_target(e,tp,eg,ep,ev,re,r,rp,chk)==false then
...@@ -2538,13 +2460,13 @@ function FusionSpell.GetSummonTarget( ...@@ -2538,13 +2460,13 @@ function FusionSpell.GetSummonTarget(
local sg=Duel.IsExistingMatchingCard( local sg=Duel.IsExistingMatchingCard(
FusionSpell.SummonTargetFilter,tp,fuslocation,0,1,nil, FusionSpell.SummonTargetFilter,tp,fuslocation,0,1,nil,
--- FusionSpell.SummonTargetFilter param --- FusionSpell.SummonTargetFilter param
fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos,pre_select_mat_opponent_location) fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,pre_select_mat_opponent_location,gc)
if sg==true then if sg==true then
return true return true
end end
-- --- check for chain material targets -- --- check for chain material targets
if sumtype&SUMMON_TYPE_FUSION~=0 then if sumtype&SUMMON_TYPE_FUSION~=0 then
local ce_sg=FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,fuslocation,sumtype,sumpos) local ce_sg=FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
if ce_sg==true then if ce_sg==true then
return true return true
end end
...@@ -2561,13 +2483,14 @@ end ...@@ -2561,13 +2483,14 @@ end
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials ---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order ---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order
---@param post_select_mat_location integer? location where to find the materials after known the materials ---@param post_select_mat_location integer? location where to find the materials after known the materials
---@param additional_fcheck function function to check the final material group fits the requirement ---@param additional_fcheck FUSION_FGCHECK_FUNCTION function to check the partial material group fits the requirement
---@param additional_gcheck function function to check the part of potiential material group fits the requirement to improve performance ---@param additional_fgoalcheck FUSION_FGCHECK_FUNCTION function to check the final material group fits the requirement
---@param fuslocation integer location where to summon fusion monsters from, use it on Clock Lizard ---@param fuslocation integer location where to summon fusion monsters from, use it on Clock Lizard
---@param sumtype integer summon type ---@param sumtype integer summon type
---@param sumpos integer summon position ---@param sumpos integer summon position
---@param stage_x_operation function callback function when special summon is in progress. will be called with different stage name ---@param stage_x_operation function callback function when special summon is in progress. will be called with different stage name
---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
---@param gc fun(e:Effect):Card|nil Function that returns a card that must be included in the fusion materials
function FusionSpell.GetSummonOperation( function FusionSpell.GetSummonOperation(
fusfilter, fusfilter,
matfilter, matfilter,
...@@ -2575,22 +2498,24 @@ function FusionSpell.GetSummonOperation( ...@@ -2575,22 +2498,24 @@ function FusionSpell.GetSummonOperation(
mat_operation_code_map, mat_operation_code_map,
post_select_mat_location, post_select_mat_location,
additional_fcheck, additional_fcheck,
additional_gcheck, additional_fgoalcheck,
fuslocation, fuslocation,
sumtype, sumtype,
sumpos, sumpos,
stage_x_operation, stage_x_operation,
pre_select_mat_opponent_location) pre_select_mat_opponent_location,
gc
)
return function(e,tp,eg,ep,ev,re,r,rp) return function(e,tp,eg,ep,ev,re,r,rp)
local sg=Duel.GetMatchingGroup( local sg=Duel.GetMatchingGroup(
FusionSpell.SummonTargetFilter,tp,fuslocation,0,nil, FusionSpell.SummonTargetFilter,tp,fuslocation,0,nil,
--- FusionSpell.SummonTargetFilter param --- FusionSpell.SummonTargetFilter param
fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos,pre_select_mat_opponent_location) fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,pre_select_mat_opponent_location,gc)
--- check for chain material targets --- check for chain material targets
local ce_sgs={} local ce_sgs={}
local can_chain_material=false local can_chain_material=false
if sumtype&SUMMON_TYPE_FUSION~=0 then if sumtype&SUMMON_TYPE_FUSION~=0 then
ce_sgs=FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,fuslocation,sumtype,sumpos) ce_sgs=FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
--- if there's any chain material effect has valid target --- if there's any chain material effect has valid target
for _ in pairs(ce_sgs) do for _ in pairs(ce_sgs) do
can_chain_material=true can_chain_material=true
...@@ -2641,8 +2566,10 @@ function FusionSpell.GetSummonOperation( ...@@ -2641,8 +2566,10 @@ function FusionSpell.GetSummonOperation(
sumtype, sumtype,
pre_select_mat_opponent_location) pre_select_mat_opponent_location)
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)
materials=Duel.SelectFusionMaterial(tp,tc,mg,nil,tp) aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(additional_fgoalcheck,tp,tc,pre_select_mat_location)
materials=Duel.SelectFusionMaterial(tp,tc,mg,gc(e),tp)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
else else
--- use chain material effect --- use chain material effect
---@type function ---@type function
...@@ -2650,8 +2577,10 @@ function FusionSpell.GetSummonOperation( ...@@ -2650,8 +2577,10 @@ function FusionSpell.GetSummonOperation(
local chain_mg=chain_material_filter(fusion_effect,e,tp) local chain_mg=chain_material_filter(fusion_effect,e,tp)
assert(#chain_mg>0, "we are trying to apply a chain material, but it has no possible material") assert(#chain_mg>0, "we are trying to apply a chain material, but it has no possible material")
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck)
materials=Duel.SelectFusionMaterial(tp,tc,chain_mg) aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(additional_fgoalcheck)
materials=Duel.SelectFusionMaterial(tp,tc,chain_mg,gc(e),tp)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
end end
end end
...@@ -2659,23 +2588,25 @@ function FusionSpell.GetSummonOperation( ...@@ -2659,23 +2588,25 @@ function FusionSpell.GetSummonOperation(
assert(fusion_effect~=nil) assert(fusion_effect~=nil)
if #materials>0 then if #materials>0 then
local materials_from_spell_card=Group.CreateGroup()
if fusion_effect==e then if fusion_effect==e then
--- fusion with fusion spell --- fusion with fusion spell
tc:SetMaterial(materials) tc:SetMaterial(materials)
local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
---@type {[Effect]:true} ---@type {[Effect]:true}
local applied_extra_effects={} local applied_extra_effects={}
---@type {[FUSION_OPERATION_FUNCTION]:Group} ---@type {[FUSION_OPERATION_FUNCTION]:Group}
local material_grouped_by_op={} local material_grouped_by_op={}
local materials_with_one_material_effect=materials:Filter(function(mc) return (#FusionSpell.GetMaterialEffects(mc,tp,tc,all_locations,pre_select_mat_opponent_location))==1 end,nil)
local materials_with_one_material_effect=materials:Filter(function(mc) return (#FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location))==1 end,nil)
for material in aux.Next(materials_with_one_material_effect) do for material in aux.Next(materials_with_one_material_effect) do
--For material that can be material only by 1 effect, either fusion spell or extra material effect, do the operation on it. --For material that can be material only by 1 effect, either fusion spell or extra material effect, do the operation on it.
local fusion_operation=nil local fusion_operation=nil
local material_effect=FusionSpell.GetMaterialEffects(material,tp,tc,all_locations,pre_select_mat_opponent_location)[1] local material_effect=FusionSpell.GetMaterialEffects(material,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)[1]
if material_effect==true then if material_effect==true then
local fusion_operation_code=FusionSpell.GetOperationCodeByMaterialLocation(material:GetLocation(),mat_operation_code_map) local fusion_operation_code=FusionSpell.GetOperationCodeByMaterialLocation(material:GetLocation(),mat_operation_code_map)
fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code) fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code)
materials_from_spell_card:AddCard(material)
else else
-- extra material effects -- extra material effects
--- pay the operation cost, only valid in 影牢の呪縛 as of 2025 May --- pay the operation cost, only valid in 影牢の呪縛 as of 2025 May
...@@ -2692,7 +2623,7 @@ function FusionSpell.GetSummonOperation( ...@@ -2692,7 +2623,7 @@ function FusionSpell.GetSummonOperation(
material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup() material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup()
material_grouped_by_op[fusion_operation]:AddCard(material) material_grouped_by_op[fusion_operation]:AddCard(material)
end end
local materials_with_two_material_effect=materials:Filter(function(mc) return (#FusionSpell.GetMaterialEffects(mc,tp,tc,all_locations,pre_select_mat_opponent_location))==2 end,nil) local materials_with_two_material_effect=materials:Filter(function(mc) return (#FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location))==2 end,nil)
assert(#materials_with_one_material_effect+#materials_with_two_material_effect==#materials, "We can not have one material have zero/3+ material effect yet") assert(#materials_with_one_material_effect+#materials_with_two_material_effect==#materials, "We can not have one material have zero/3+ material effect yet")
--For material that can be material by multiple effect, ask user which to apply. --For material that can be material by multiple effect, ask user which to apply.
--As of 2025 May, if a material could be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption. --As of 2025 May, if a material could be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption.
...@@ -2701,7 +2632,7 @@ function FusionSpell.GetSummonOperation( ...@@ -2701,7 +2632,7 @@ function FusionSpell.GetSummonOperation(
---@type {[Effect]:Group} ---@type {[Effect]:Group}
local material_grouped_by_extra_material_effect={} local material_grouped_by_extra_material_effect={}
for material in aux.Next(materials_with_two_material_effect) do for material in aux.Next(materials_with_two_material_effect) do
local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc) local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc,pre_select_mat_location)
assert(material_effect~=nil, "We can not have a material w/o extra material effect when it has 2 options") assert(material_effect~=nil, "We can not have a material w/o extra material effect when it has 2 options")
material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup() material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup()
material_grouped_by_extra_material_effect[material_effect]:AddCard(material) material_grouped_by_extra_material_effect[material_effect]:AddCard(material)
...@@ -2710,8 +2641,12 @@ function FusionSpell.GetSummonOperation( ...@@ -2710,8 +2641,12 @@ function FusionSpell.GetSummonOperation(
---For each group, let user select the material that apply the extra material effect. ---For each group, let user select the material that apply the extra material effect.
for material_effect,grouped_materials in pairs(material_grouped_by_extra_material_effect) do for material_effect,grouped_materials in pairs(material_grouped_by_extra_material_effect) do
Duel.Hint(HINT_SELECTMSG,tp,material_effect:GetDescription()) Duel.Hint(HINT_SELECTMSG,tp,material_effect:GetDescription())
local extra_material_limit=#grouped_materials
--- in case of アマゾネスの秘術 or 影牢の呪縛, limit the maximuim number to choose --- in case of アマゾネスの秘術 or 影牢の呪縛, limit the maximuim number to choose
local extra_material_limit=material_effect:GetLabel() or #grouped_materials local material_effect_material_count_limit=({material_effect:GetLabel()})[1]
if material_effect_material_count_limit~= 0 then
extra_material_limit=material_effect_material_count_limit
end
local materials_to_apply=grouped_materials:Select(tp,0,extra_material_limit,nil) local materials_to_apply=grouped_materials:Select(tp,0,extra_material_limit,nil)
local rest_materials=grouped_materials-materials_to_apply local rest_materials=grouped_materials-materials_to_apply
if #rest_materials>0 then if #rest_materials>0 then
...@@ -2720,6 +2655,7 @@ function FusionSpell.GetSummonOperation( ...@@ -2720,6 +2655,7 @@ function FusionSpell.GetSummonOperation(
local fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code) local fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code)
material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup() material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup()
material_grouped_by_op[fusion_operation]:AddCard(material) material_grouped_by_op[fusion_operation]:AddCard(material)
materials_from_spell_card:AddCard(material)
end end
end end
if #materials_to_apply>0 then if #materials_to_apply>0 then
...@@ -2763,13 +2699,13 @@ function FusionSpell.GetSummonOperation( ...@@ -2763,13 +2699,13 @@ function FusionSpell.GetSummonOperation(
fusion_effect:Reset() fusion_effect:Reset()
end end
end end
end
stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE) stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE,materials_from_spell_card,materials)
Duel.SpecialSummonComplete() Duel.SpecialSummonComplete()
stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_PROCEDURE_COMPLETE) stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_PROCEDURE_COMPLETE,materials_from_spell_card,materials)
tc:CompleteProcedure() tc:CompleteProcedure()
stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH) stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH,materials_from_spell_card,materials)
end
end end
stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_ALL_OPERATION_FINISH) stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_ALL_OPERATION_FINISH)
end end
...@@ -2779,21 +2715,20 @@ end ...@@ -2779,21 +2715,20 @@ end
---@return integer locations all possible locations of the material ---@return integer locations all possible locations of the material
function FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location) function FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
local all_locations=0 local all_locations=0
if pre_select_mat_location~=nil then if type(pre_select_mat_location)=="function" then
if type(pre_select_mat_location)=="function" then all_locations=all_locations|pre_select_mat_location(tc,tp)
all_locations=all_locations|pre_select_mat_location(tc,tp) else
else all_locations=all_locations|pre_select_mat_location
all_locations=all_locations|pre_select_mat_location
end
end end
if post_select_mat_location~=nil then if post_select_mat_location~=nil then
all_locations=all_locations|post_select_mat_location all_locations=all_locations|post_select_mat_location
end end
return all_locations return all_locations
end end
---@param matfilter fun(c:Card):boolean filter for the materials, use it only under very strong limitation like D-Fusion. ---@param matfilter fun(c:Card):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param pre_select_mat_location integer|function location where to find the materials before known the materials ---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
function FusionSpell.GetMaterialsGroupForTargetCard( function FusionSpell.GetMaterialsGroupForTargetCard(
tc, tc,
...@@ -2838,7 +2773,7 @@ function FusionSpell.GetMaterialsGroupForTargetCard( ...@@ -2838,7 +2773,7 @@ function FusionSpell.GetMaterialsGroupForTargetCard(
can_be_fusion_spell_material=filter_by_operation(mc,tp,e) can_be_fusion_spell_material=filter_by_operation(mc,tp,e)
end end
local can_be_extra_material=false local can_be_extra_material=false
local extra_effect=FusionSpell.GetExtraMaterialEffect(mc,tp,tc) local extra_effect=FusionSpell.GetExtraMaterialEffect(mc,tp,tc,pre_select_mat_location)
if extra_effect~=nil then if extra_effect~=nil then
---@type FUSION_OPERATION_CODE ---@type FUSION_OPERATION_CODE
local operation_code=FusionSpell.FUSION_OPERATION_INHERIT local operation_code=FusionSpell.FUSION_OPERATION_INHERIT
...@@ -2870,21 +2805,25 @@ end ...@@ -2870,21 +2805,25 @@ end
---@param fusfilter fun(c:Card,tp:integer):boolean ---@param fusfilter fun(c:Card,tp:integer):boolean
---@param matfilter fun(c:Card,tp:integer):boolean ---@param matfilter fun(c:Card,tp:integer):boolean
---@param pre_select_mat_location integer|function location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE) ---@param pre_select_mat_location integer|function location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE)
---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION? location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
function FusionSpell.SummonTargetFilter(c,fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos,pre_select_mat_opponent_location) ---@param gc fun(e:Effect):Card|nil
function FusionSpell.SummonTargetFilter(c,fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,pre_select_mat_opponent_location,gc)
local res=c:IsType(TYPE_FUSION) and fusfilter(c,tp) and c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos) local res=c:IsType(TYPE_FUSION) and fusfilter(c,tp) and c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos)
if res==false then if res==false then
return false return false
end end
local mg=FusionSpell.GetMaterialsGroupForTargetCard(c,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,sumtype,pre_select_mat_opponent_location) local mg=FusionSpell.GetMaterialsGroupForTargetCard(c,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,sumtype,pre_select_mat_opponent_location)
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)
res=c:CheckFusionMaterial(mg,nil,tp) aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(additional_fgoalcheck,tp,c,pre_select_mat_location)
res=c:CheckFusionMaterial(mg,gc(e),tp)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
return res return res
end end
---@return {[Effect]:Group} effect_targets_map Return a map of different chain material to potiential fusion targets ---@return {[Effect]:Group} effect_targets_map Return a map of different chain material to potiential fusion targets
function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,fuslocation,sumtype,sumpos) ---@param gc fun(e:Effect):Card|nil
function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)} local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)}
---@type {[Effect]:Group} ---@type {[Effect]:Group}
local chain_material_targets={} local chain_material_targets={}
...@@ -2894,7 +2833,9 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fc ...@@ -2894,7 +2833,9 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fc
local chain_mg=chain_material_filter(ce,e,tp) local chain_mg=chain_material_filter(ce,e,tp)
if #chain_mg>0 then if #chain_mg>0 then
local ce_fusfilter=ce:GetValue() local ce_fusfilter=ce:GetValue()
local ce_sg=Duel.GetMatchingGroup(FusionSpell.ChainMaterialSummonTargetFilter,tp,fuslocation,0,nil,aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,sumtype,sumpos) local ce_sg=Duel.GetMatchingGroup(FusionSpell.ChainMaterialSummonTargetFilter,tp,fuslocation,0,nil,
---FusionSpell.ChainMaterialSummonTargetFilter params
aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc)
if #ce_sg>0 then if #ce_sg>0 then
chain_material_targets[ce]=ce_sg chain_material_targets[ce]=ce_sg
end end
...@@ -2904,7 +2845,8 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fc ...@@ -2904,7 +2845,8 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fc
end end
---@return boolean res return whether there is a valid target for any chain material effect ---@return boolean res return whether there is a valid target for any chain material effect
function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,fuslocation,sumtype,sumpos) ---@param gc fun(e:Effect):Card|nil
function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)} local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)}
---@type {[Effect]:Group} ---@type {[Effect]:Group}
for _,ce in ipairs(chain_material_effects) do for _,ce in ipairs(chain_material_effects) do
...@@ -2913,7 +2855,9 @@ function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additiona ...@@ -2913,7 +2855,9 @@ function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additiona
local chain_mg=chain_material_filter(ce,e,tp) local chain_mg=chain_material_filter(ce,e,tp)
if #chain_mg>0 then if #chain_mg>0 then
local ce_fusfilter=ce:GetValue() local ce_fusfilter=ce:GetValue()
local res=Duel.IsExistingMatchingCard(FusionSpell.ChainMaterialSummonTargetFilter,tp,fuslocation,0,1,nil,aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,sumtype,sumpos) local res=Duel.IsExistingMatchingCard(FusionSpell.ChainMaterialSummonTargetFilter,tp,fuslocation,0,1,nil,
---FusionSpell.ChainMaterialSummonTargetFilter params
aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc)
if res==true then if res==true then
return res return res
end end
...@@ -2923,15 +2867,18 @@ function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additiona ...@@ -2923,15 +2867,18 @@ function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additiona
end end
---@param c Card ---@param c Card
---@param gc fun(e:Effect):Card|nil
---@return boolean result Whether c could be fusion summoned by this chain material effect ---@return boolean result Whether c could be fusion summoned by this chain material effect
function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additional_fcheck,sumtype,sumpos) function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc)
local res=c:IsType(TYPE_FUSION) and (not fusfilter or fusfilter(c,tp)) and c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos) local res=c:IsType(TYPE_FUSION) and (not fusfilter or fusfilter(c,tp)) and c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos)
if res==false then if res==false then
return false return false
end end
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck)
res=c:CheckFusionMaterial(mg,nil,tp) aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(additional_fgoalcheck)
res=c:CheckFusionMaterial(mg,gc(e),tp)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
return res return res
end end
...@@ -2970,7 +2917,7 @@ function FusionSpell.GetFusionOperationByCode(code,matlocation,fusion_spell_oper ...@@ -2970,7 +2917,7 @@ function FusionSpell.GetFusionOperationByCode(code,matlocation,fusion_spell_oper
elseif code==FusionSpell.FUSION_OPERATION_INHERIT then elseif code==FusionSpell.FUSION_OPERATION_INHERIT then
if matlocation==nil or fusion_spell_operation_code_map==nil then if matlocation==nil or fusion_spell_operation_code_map==nil then
-- we are in trouble -- we are in trouble
assert(false, "we have a material that inhreits, but operation can be inhreited") assert(false, "we have a material that inhreits, but no operation to inhreit from")
return FusionSpell.GraveMaterial return FusionSpell.GraveMaterial
end end
return FusionSpell.GetFusionOperationByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map)) return FusionSpell.GetFusionOperationByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map))
...@@ -2994,7 +2941,7 @@ function FusionSpell.GetFusionFilterByCode(code,matlocation,fusion_spell_operati ...@@ -2994,7 +2941,7 @@ function FusionSpell.GetFusionFilterByCode(code,matlocation,fusion_spell_operati
elseif code==FusionSpell.FUSION_OPERATION_INHERIT then elseif code==FusionSpell.FUSION_OPERATION_INHERIT then
if matlocation==nil or fusion_spell_operation_code_map==nil then if matlocation==nil or fusion_spell_operation_code_map==nil then
-- we are in trouble -- we are in trouble
assert(false, "we have a material that inhreits, but operation can be inhreited") assert(false, "we have a material that inhreits, but no operation to inhreit from")
return FusionSpell.GraveMaterialFilter return FusionSpell.GraveMaterialFilter
end end
return FusionSpell.GetFusionFilterByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map)) return FusionSpell.GetFusionFilterByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map))
...@@ -3067,28 +3014,26 @@ end ...@@ -3067,28 +3014,26 @@ end
--Returns a list of effect, if element is the EFFECT_EXTRA_FUSION_MATERIAL, stands for it can be included by that extra material effect. --Returns a list of effect, if element is the EFFECT_EXTRA_FUSION_MATERIAL, stands for it can be included by that extra material effect.
--if element is true, stands for it can be included by the fusion effect itself. --if element is true, stands for it can be included by the fusion effect itself.
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
---@return (true|Effect)[] ---@return (true|Effect)[]
function FusionSpell.GetMaterialEffects(c,tp,summon_card,matlocation,pre_select_mat_opponent_location) function FusionSpell.GetMaterialEffects(c,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)
local res={} local res={}
local calculated_mat_opponent_location=0 local calculated_mat_opponent_location=0
if type(pre_select_mat_opponent_location)=="function" then if type(pre_select_mat_opponent_location)=="function" then
calculated_mat_opponent_location=pre_select_mat_opponent_location(summon_card,tp) calculated_mat_opponent_location=pre_select_mat_opponent_location(tc,tp)
else else
calculated_mat_opponent_location=pre_select_mat_opponent_location calculated_mat_opponent_location=pre_select_mat_opponent_location
end end
if c:IsControler(tp) and c:IsLocation(matlocation) then local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
if c:IsControler(tp) and c:IsLocation(all_locations) then
table.insert(res,true) table.insert(res,true)
elseif c:IsControler(1-tp) and c:IsLocation(calculated_mat_opponent_location) then elseif c:IsControler(1-tp) and c:IsLocation(calculated_mat_opponent_location) then
table.insert(res,true) table.insert(res,true)
end end
local extra_effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)} local extra_effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)}
for _,eff in ipairs(extra_effs) do for _,eff in ipairs(extra_effs) do
if not summon_card then if FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(eff,c,tp,tc,pre_select_mat_location) then
table.insert(res,eff)
end
local val=eff:GetValue()
if (type(val)=="function" and val(eff,summon_card)) or val==1 then
table.insert(res,eff) table.insert(res,eff)
end end
end end
...@@ -3097,24 +3042,51 @@ end ...@@ -3097,24 +3042,51 @@ end
--Returns the 1st EFFECT_EXTRA_FUSION_MATERIAL is applied on Card c. --Returns the 1st EFFECT_EXTRA_FUSION_MATERIAL is applied on Card c.
--If summon_card is provided, it will filter on whether the effect's value function applies to that card. --If summon_card is provided, it will filter on whether the effect's value function applies to that card.
---@param c Card the material card card ---@param c Card the material card
---@param tp integer the player ---@param tp integer the player
---@param summon_card Card the target card ---@param tc Card the target card
function FusionSpell.GetExtraMaterialEffect(c,tp,summon_card) ---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
function FusionSpell.GetExtraMaterialEffect(c,tp,tc,pre_select_mat_location)
local effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)} local effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)}
for _,eff in ipairs(effs) do for _,eff in ipairs(effs) do
if eff:CheckCountLimit(tp)==true then if FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(eff,c,tp,tc,pre_select_mat_location) then
if summon_card==nil then return eff
return eff
end
local val=eff:GetValue()
if (type(val)=="function" and val(eff,summon_card)) or val==1 then
return eff
end
end end
end end
end end
---@param extra_material_effect Effect the extra material effect
---@param mc Card the material card
---@param tp integer the player
---@param tc Card the target card
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
---@return boolean result whether the extra material effect can apply
function FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(extra_material_effect,mc,tp,tc,pre_select_mat_location)
if type(pre_select_mat_location)=="function" then
pre_select_mat_location=pre_select_mat_location(tc,tp)
end
--- can not use if count limit exhausted
if extra_material_effect:CheckCountLimit(tp)==false then
return false
end
--- 1st element of label is material count limit, 2nd is location requirement
local labels={extra_material_effect:GetLabel()}
if #labels>=2 then
local location_requirement=labels[2]
if pre_select_mat_location&location_requirement==0 then
return false
end
end
if tc==nil then
return true
end
local val=extra_material_effect:GetValue()
if (type(val)=="function" and val(extra_material_effect,tc)) or val==1 then
return true
end
return false
end
-- when a target card can be summoned by multiple effect, ask for which to apply. -- when a target card can be summoned by multiple effect, ask for which to apply.
---@return Effect ---@return Effect
function FusionSpell.MultiFusionEffectPrompt(effects,tp) function FusionSpell.MultiFusionEffectPrompt(effects,tp)
...@@ -3144,20 +3116,20 @@ end ...@@ -3144,20 +3116,20 @@ end
--- filter out materials that does not necessary come from fusion spell and pass to the gcheck of fusion spell --- filter out materials that does not necessary come from fusion spell and pass to the gcheck of fusion spell
--- for each extra material effect, check the maximuim size is not exceeded. --- for each extra material effect, check the maximuim size is not exceeded.
--As of 2025 May, if a material could be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption. --- As of 2025 May, if a material could (but not forced) be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption.
-- If we have Aiラブ融合 + 影牢の呪縛 or 多層融合 + アマゾネスの秘術 in same archetype, is code would fail in some scenario. --- If we have Aiラブ融合 + 影牢の呪縛 or 多層融合 + アマゾネスの秘術 in same archetype, is code would fail in some scenario.
---@param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION ---@param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION
---@param tp integer ---@param tp integer
---@param tc Card ---@param tc Card
---@param pre_select_mat_location integer|function location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE) ---@param pre_select_mat_location integer|function location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE)
---@param post_select_mat_location integer? ---@param post_select_mat_location integer?
---@param pre_select_mat_opponent_location (integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION)? location where to find the materials before known the materials on opponent location ---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location
function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additional_fcheck_function,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location) function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additional_fcheck_function,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)
---@param mg Group ---@param mg Group
return (function(f_tp,mg,fc) return (function(f_tp,mg,fc)
--- filter out materials that can only be added by extra material effects, and check the count limit --- filter out materials that can only be added by extra material effects, and check the count limit
local mandartory_extra_mg=mg:Filter(function (mc) local mandartory_extra_mg=mg:Filter(function (mc)
local material_effects=FusionSpell.GetMaterialEffects(mc,tp,tc,FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location),pre_select_mat_opponent_location) local material_effects=FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location)
if (#material_effects)==1 and material_effects[1]~=true then if (#material_effects)==1 and material_effects[1]~=true then
return true return true
end end
...@@ -3167,28 +3139,50 @@ function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additio ...@@ -3167,28 +3139,50 @@ function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additio
---@type {[Effect]:Group} ---@type {[Effect]:Group}
local material_grouped_by_extra_material_effect={} local material_grouped_by_extra_material_effect={}
for material in aux.Next(mandartory_extra_mg) do for material in aux.Next(mandartory_extra_mg) do
local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc) local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc,pre_select_mat_location)
material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup() material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup()
material_grouped_by_extra_material_effect[material_effect]:AddCard(material) material_grouped_by_extra_material_effect[material_effect]:AddCard(material)
end end
--- check count limit for each effect --- check count limit for each effect
for extra_material_effect,materials in pairs(material_grouped_by_extra_material_effect) do for extra_material_effect,materials in pairs(material_grouped_by_extra_material_effect) do
if extra_material_effect:GetLabel()~=nil then local labels={extra_material_effect:GetLabel()}
if #materials>extra_material_effect:GetLabel() then --- first element of label is the material count limit
return false if labels~=nil and #labels>0 and labels[1]>0 and #materials>labels[1] then
end return false
end end
end end
local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc) local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc,pre_select_mat_location)
return fusion_spell_additional_fcheck_function(f_tp,mg-extra_mg,fc,mg) return fusion_spell_additional_fcheck_function(f_tp,mg-extra_mg,fc,mg)
end) end)
end end
--- all material must come from chain material, only pass all material group to the gcheck of fusion spell
--- filter out materials that does not necessary come from fusion spell and pass to the gcheck of fusion spell
---@param fusion_spell_additional_fgoalcheck_function FUSION_FGCHECK_FUNCTION
---@param tp integer
---@param tc Card
---@param pre_select_mat_location integer|function location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE)
function FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(fusion_spell_additional_fgoalcheck_function,tp,tc,pre_select_mat_location)
---@param mg Group
return (function(f_tp,mg,fc)
local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc,pre_select_mat_location)
return fusion_spell_additional_fgoalcheck_function(f_tp,mg-extra_mg,fc,mg)
end)
end
--- all material must come from chain material, only pass all material group to the fcheck of fusion spell
--- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION --- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION
function FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fcheck_function) function FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fcheck_function)
return (function(f_tp,mg,fc) return (function(f_tp,mg,fc)
return fusion_spell_additional_fcheck_function(f_tp,Group.CreateGroup(),fc,mg) return fusion_spell_additional_fcheck_function(f_tp,Group.CreateGroup(),fc,mg)
end) end)
end end
--- all material must come from chain material, only pass all material group to the gcheck of fusion spell
--- @param fusion_spell_additional_fgoalcheck_function FUSION_FGCHECK_FUNCTION
function FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fgoalcheck_function)
return (function(f_tp,mg,fc)
return fusion_spell_additional_fgoalcheck_function(f_tp,Group.CreateGroup(),fc,mg)
end)
end
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment