Commit 2b0a3558 authored by Vury Leo's avatar Vury Leo

use named parameter style

parent ab526506
...@@ -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,nil,nil,LOCATION_ONFIELD) local e1=FusionSpell.CreateSummonEffect(c,{pre_select_mat_location=LOCATION_ONFIELD})
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)
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
local s,id,o=GetID() local s,id,o=GetID()
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
FusionSpell.RegisterSummonEffect(c,s.fusfilter,nil,nil,nil,nil,nil,nil,nil,nil,nil,s.stage_x_operation) FusionSpell.RegisterSummonEffect(c,{
fusfilter=s.fusfilter,
stage_x_operation=s.stage_x_operation
})
end end
---@param c Card ---@param c Card
......
...@@ -23,6 +23,7 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -23,6 +23,7 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0) e1:SetTargetRange(1,0)
e1:SetReset(RESET_PHASE+PHASE_END) e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetCountLimit(1)
e1:SetTarget(s.chain_target) e1:SetTarget(s.chain_target)
e1:SetOperation(s.chain_operation) e1:SetOperation(s.chain_operation)
e1:SetValue(aux.FilterBoolFunction(Card.IsRace,RACE_MACHINE)) e1:SetValue(aux.FilterBoolFunction(Card.IsRace,RACE_MACHINE))
...@@ -40,5 +41,4 @@ function s.chain_operation(e,te,tp,tc,mat,sumtype,sumpos) ...@@ -40,5 +41,4 @@ function s.chain_operation(e,te,tp,tc,mat,sumtype,sumpos)
Duel.Remove(mat,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.Remove(mat,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect() Duel.BreakEffect()
Duel.SpecialSummonStep(tc,sumtype,tp,tp,false,false,sumpos) Duel.SpecialSummonStep(tc,sumtype,tp,tp,false,false,sumpos)
e:Reset()
end end
\ No newline at end of file
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
local s,id=GetID() local s,id=GetID()
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
local e1=FusionSpell.CreateSummonEffect(c,s.fusfilter,nil,s.pre_select_mat_location,nil,nil,s.fcheck,s.gcheck) local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter,
pre_select_mat_location=s.pre_select_mat_location,
additional_fcheck=s.fcheck,
additional_gcheck=s.gcheck
})
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_DECKDES) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_DECKDES)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
c:RegisterEffect(e1) c:RegisterEffect(e1)
......
...@@ -1991,7 +1991,45 @@ end ...@@ -1991,7 +1991,45 @@ end
FusionSpell = {} FusionSpell = {}
---@alias FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION fun(tc:Card,tp:integer):integer ---@alias FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION fun(tc:Card,tp:integer):integer
---@alias FUSION_FCHECK_FUNCTION fun(tp:integer,mg:Group,fc:Card,all_mg:Group):boolean ---@alias FUSION_FGCHECK_FUNCTION fun(tp:integer,mg:Group,fc:Card,all_mg:Group):boolean
--- @class FusionEffectParams
--- @field fusfilter? fun(c:Card):boolean
--- Optional filter to restrict which Fusion Monsters can be summoned.
--- @field matfilter? fun(c:Card):boolean
--- Optional filter for valid Fusion Materials.
--- Use only under strong constraints (e.g., D-Fusion effects).
--- @field pre_select_mat_location? integer|fun():integer
--- Location(s) to look for materials before knowing which ones will be used.
--- Defaults to `LOCATION_HAND | LOCATION_MZONE`.
--- @field mat_operation_code_map? {[integer]:FUSION_OPERATION_CODE}[]
--- List of operations to perform on materials based on location.
--- Defaults to:
--- ```lua
--- {
--- { [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH },
--- { [0xff] = FusionSpell.FUSION_OPERATION_GRAVE }
--- }
--- ```
--- @field post_select_mat_location? integer|nil
--- Location(s) to look for materials after they've been selected.
--- @field additional_fcheck? FUSION_FGCHECK_FUNCTION
--- 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
--- The location to summon Fusion Monsters from. Defaults to `LOCATION_EXTRA`.
--- @field sumtype? integer
--- The summon type to perform. Defaults to `SUMMON_TYPE_FUSION`.
--- @field sumpos? integer
--- The position to summon the monster in. Defaults to `POS_FACEUP`.
--- @field stage_x_operation? FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
--- Optional callback executed at key stages of the summon process.
--- Example stage: `FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE`.
--- @field extra_target? fun(e:Effect, tp:integer, eg:Group, ep:integer, ev:integer, re:Effect, r:integer, rp:integer, chk:integer):nil
--- Optional extra targeting logic (e.g., to show hints or manage chains).
--- @field pre_select_mat_opponent_location? integer|fun():integer
--- Opponent-side locations to search for materials before they are selected.
--- Add LOCATION_EXTRA to EFFECT_EXTRA_FUSION_MATERIAL list, remove once core updated --- Add LOCATION_EXTRA to EFFECT_EXTRA_FUSION_MATERIAL list, remove once core updated
...@@ -2004,63 +2042,87 @@ function FusionSpell.GetFusionMaterial(tp,locations) ...@@ -2004,63 +2042,87 @@ function FusionSpell.GetFusionMaterial(tp,locations)
return res return res
end end
---@param c Card card that uses the effect --- Get possible materials from opponent locations, must be face-up
---@param fusfilter (fun(c:Card):boolean)? filter for the monster to be Fusion Summoned function FusionSpell.GetFusionMaterialFromOpponentLocation(tp,locations)
---@param matfilter (fun(c:Card):boolean)? filter for the materials, use it only under very strong limitation like D-Fusion. return Duel.GetMatchingGroup(Card.IsFaceup,tp,0,locations,nil)
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION? location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE)
---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[]? operation code to do for the materials, it will be check in order (default [{ LOCATION_GRAVE: FUSION_OPERATION_BANISH}, { 0xff: FUSION_OPERATION_GRAVE}])
---@param post_select_mat_location integer? location where to find the materials after known the materials (default nil)
---@param additional_fcheck function? function to check the final 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 fuslocation integer? location where to summon fusion monsters from (default LOCATION_EXTRA), use it on Clock Lizard
---@param sumtype integer? summon type (default SUMMON_TYPE_FUSION)
---@param sumpos integer? summon position (default POS_FACEUP)
---@param stage_x_operation function? callback function when special summon is in progress. will be called with different stage name
function FusionSpell.RegisterSummonEffect(c,fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,stage_x_operation)
local e1=FusionSpell.CreateSummonEffect(c,fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,stage_x_operation)
Card.RegisterEffect(c,e1)
return e1
end end
---@param c Card card that uses the effect --- Registers a Fusion Summon effect to a card.
---@param fusfilter (fun(c:Card):boolean)? filter for the monster to be Fusion Summoned --- @param c Card -- The card to register the effect to.
---@param matfilter (fun(c:Card):boolean)? filter for the materials, use it only under very strong limitation like D-Fusion. --- @param opts FusionEffectParams
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION? location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_ONFIELD) --- @return Effect -- The registered effect object.
---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[]? operation code to do for the materials, it will be check in order (default [{ LOCATION_GRAVE: FUSION_OPERATION_BANISH}, { 0xff: FUSION_OPERATION_GRAVE}]) function FusionSpell.RegisterSummonEffect(c,opts)
---@param post_select_mat_location integer? location where to find the materials after known the materials (default nil) local e1 = FusionSpell.CreateSummonEffect(c,opts)
---@param additional_fcheck function? function to check the final material group fits the requirement Card.RegisterEffect(c, e1)
---@param additional_gcheck function? function to check the part of potiential material group fits the requirement to improve performance return e1
---@param fuslocation integer? location where to summon fusion monsters from (default LOCATION_EXTRA), use it on Clock Lizard end
---@param sumtype integer? summon type (default SUMMON_TYPE_FUSION)
---@param sumpos integer? summon position (default POS_FACEUP) --- Creates and returns a Fusion Summon effect, attached to the specified card.
---@param stage_x_operation function? callback function when special summon is in progress. will be called with different stage name --- Accepts a table of named parameters to configure the effect behavior.
---@param extra_target function? extra target function to add opration info etc ---
function FusionSpell.CreateSummonEffect(c,fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,stage_x_operation,extra_target) --- @param opts? FusionEffectParams Named options table.
matfilter=matfilter or aux.TRUE --- @return Effect The created and configured `Effect` object.
pre_select_mat_location=pre_select_mat_location or LOCATION_HAND|LOCATION_ONFIELD function FusionSpell.CreateSummonEffect(c,opts)
mat_operation_code_map=mat_operation_code_map or {} opts=opts or {}
-- add last fallback, banish grave, grave others local fusfilter=opts.fusfilter
table.insert(mat_operation_code_map,{[LOCATION_GRAVE]=FusionSpell.FUSION_OPERATION_BANISH}) local matfilter=opts.matfilter or aux.TRUE
table.insert(mat_operation_code_map,{[0xff]=FusionSpell.FUSION_OPERATION_GRAVE}) local pre_select_mat_location=opts.pre_select_mat_location or (LOCATION_HAND | LOCATION_MZONE)
local mat_operation_code_map=opts.mat_operation_code_map or {}
fuslocation=fuslocation or LOCATION_EXTRA local post_select_mat_location=opts.post_select_mat_location
sumtype=sumtype or SUMMON_TYPE_FUSION local additional_fcheck=opts.additional_fcheck
sumpos=sumpos or POS_FACEUP local additional_gcheck=opts.additional_gcheck
stage_x_operation=stage_x_operation or aux.TRUE local fuslocation=opts.fuslocation or LOCATION_EXTRA
local sumtype=opts.sumtype or SUMMON_TYPE_FUSION
local e1=Effect.CreateEffect(c) local sumpos=opts.sumpos or POS_FACEUP
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) local stage_x_operation=opts.stage_x_operation or aux.TRUE
e1:SetType(EFFECT_TYPE_ACTIVATE) local extra_target=opts.extra_target
e1:SetCode(EVENT_FREE_CHAIN) local pre_select_mat_opponent_location=opts.pre_select_mat_opponent_location
e1:SetTarget(FusionSpell.GetSummonTarget(fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos))
e1:SetOperation(FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,stage_x_operation)) -- Ensure material operation fallbacks are present
table.insert(mat_operation_code_map,{ [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH })
table.insert(mat_operation_code_map,{ [0xff] = FusionSpell.FUSION_OPERATION_GRAVE })
-- Build and return the effect
local e1 = Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(FusionSpell.GetSummonTarget(
fusfilter,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
additional_fcheck,
additional_gcheck,
fuslocation,
sumtype,
sumpos,
extra_target,
pre_select_mat_opponent_location
))
e1:SetOperation(FusionSpell.GetSummonOperation(
fusfilter,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
additional_fcheck,
additional_gcheck,
fuslocation,
sumtype,
sumpos,
stage_x_operation,
pre_select_mat_opponent_location
))
return e1 return e1
end end
---@param fusfilter fun(c:Card):boolean? filter for the monster to be Fusion Summoned ---@param fusfilter fun(c:Card):boolean? filter for the monster to be Fusion Summoned
---@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|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 function? function to check the final 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_gcheck function? function to check the part of potiential material group fits the requirement to improve performance
...@@ -2068,10 +2130,23 @@ end ...@@ -2068,10 +2130,23 @@ end
---@param sumtype integer? summon type ---@param sumtype integer? summon type
---@param sumpos integer? summon position ---@param sumpos integer? summon position
---@param extra_target function? extra target function to add opration info etc ---@param extra_target function? extra target function to add opration info etc
function FusionSpell.GetSummonTarget(fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,extra_target) ---@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.GetSummonTarget(
fusfilter,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
additional_fcheck,
additional_gcheck,
fuslocation,
sumtype,
sumpos,
extra_target,
pre_select_mat_opponent_location)
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
local sg=Duel.IsExistingMatchingCard(FusionSpell.SummonTargetFilter,tp,fuslocation,0,1,nil,fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos) local sg=Duel.IsExistingMatchingCard(FusionSpell.SummonTargetFilter,tp,fuslocation,0,1,nil,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)
if sg==true then if sg==true then
return true return true
end end
...@@ -2086,7 +2161,7 @@ function FusionSpell.GetSummonTarget(fusfilter,matfilter,pre_select_mat_location ...@@ -2086,7 +2161,7 @@ function FusionSpell.GetSummonTarget(fusfilter,matfilter,pre_select_mat_location
end end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,fuslocation) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,fuslocation)
if extra_target~=nil then if extra_target~=nil then
extra_target() extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
end end
end end
end end
...@@ -2099,13 +2174,25 @@ end ...@@ -2099,13 +2174,25 @@ end
---@param additional_fcheck function? function to check the final material group fits the requirement ---@param additional_fcheck function? function to check the final 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_gcheck function? function to check the part of potiential material group fits the requirement to improve performance
---@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
function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,additional_gcheck,fuslocation,sumtype,sumpos,stage_x_operation) ---@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.GetSummonOperation(
fusfilter,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
additional_fcheck,
additional_gcheck,
fuslocation,
sumtype,
sumpos,
stage_x_operation,
pre_select_mat_opponent_location)
return function(e,tp,eg,ep,ev,re,r,rp) return function(e,tp,eg,ep,ev,re,r,rp)
local sg=Duel.GetMatchingGroup(FusionSpell.SummonTargetFilter,tp,fuslocation,0,nil,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)
local sg=Duel.GetMatchingGroup(FusionSpell.SummonTargetFilter,tp,fuslocation,0,nil,fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos)
--- 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
...@@ -2150,7 +2237,15 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat ...@@ -2150,7 +2237,15 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat
end end
if fusion_effect==e then if fusion_effect==e then
--- use fusion spell effect --- use fusion spell effect
local mg=FusionSpell.GetMaterialsGroupForTargetCard(tc,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location) local mg=FusionSpell.GetMaterialsGroupForTargetCard(
tc,
tp,
e,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
pre_select_mat_opponent_location)
if additional_fcheck~=nil then if additional_fcheck~=nil then
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c)
end end
...@@ -2169,7 +2264,7 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat ...@@ -2169,7 +2264,7 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
end end
end end
assert(tc~=nil) assert(tc~=nil)
assert(fusion_effect~=nil) assert(fusion_effect~=nil)
...@@ -2231,9 +2326,14 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat ...@@ -2231,9 +2326,14 @@ function FusionSpell.GetSummonOperation(fusfilter,matfilter,pre_select_mat_locat
else else
--- fusion with chain material --- fusion with chain material
fusion_effect:GetOperation()(e,e,tp,tc,materials,sumtype,sumpos) fusion_effect:GetOperation()(e,e,tp,tc,materials,sumtype,sumpos)
--- use the chain material effect, reset if exhaused
fusion_effect:UseCountLimit(tp)
if fusion_effect:CheckCountLimit(tp)==false then
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)
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)
...@@ -2262,9 +2362,29 @@ end ...@@ -2262,9 +2362,29 @@ 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|function location where to find the materials before known the materials
function FusionSpell.GetMaterialsGroupForTargetCard(tc,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_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(
tc,
tp,
e,
matfilter,
pre_select_mat_location,
mat_operation_code_map,
post_select_mat_location,
pre_select_mat_opponent_location)
local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location) local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
local mg=FusionSpell.GetFusionMaterial(tp,all_locations) local mg=FusionSpell.GetFusionMaterial(tp,all_locations)
if pre_select_mat_opponent_location~=nil then
if type(pre_select_mat_opponent_location)=="function" then
pre_select_mat_opponent_location=pre_select_mat_opponent_location(tc,tp)
end
local opponent_mg=FusionSpell.GetFusionMaterialFromOpponentLocation(tp,pre_select_mat_opponent_location)
if #opponent_mg>0 then
mg:Merge(opponent_mg)
end
end
-- filter by the strong material filter, target card can not be fusion material of itself -- filter by the strong material filter, target card can not be fusion material of itself
mg=mg:Filter(matfilter,tc) mg=mg:Filter(matfilter,tc)
--- filter out card can not be affected by effect --- filter out card can not be affected by effect
...@@ -2312,12 +2432,13 @@ end ...@@ -2312,12 +2432,13 @@ 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)
function FusionSpell.SummonTargetFilter(c,fusfilter,matfilter,e,tp,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,additional_fcheck,sumtype,sumpos) ---@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)
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
local mg=FusionSpell.GetMaterialsGroupForTargetCard(c,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location) local mg=FusionSpell.GetMaterialsGroupForTargetCard(c,tp,e,matfilter,pre_select_mat_location,mat_operation_code_map,post_select_mat_location,pre_select_mat_opponent_location)
if additional_fcheck~=nil then if additional_fcheck~=nil then
aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c) aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction(additional_fcheck,tp,c)
end end
...@@ -2337,7 +2458,7 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,additional_fc ...@@ -2337,7 +2458,7 @@ 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,aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,sumtype,sumpos)
if #ce_sg>0 then if #ce_sg>0 then
chain_material_targets[ce]=ce_sg chain_material_targets[ce]=ce_sg
end end
...@@ -2356,7 +2477,7 @@ function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,additiona ...@@ -2356,7 +2477,7 @@ 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,aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,sumtype,sumpos)
if res==true then if res==true then
return res return res
end end
...@@ -2510,7 +2631,7 @@ end ...@@ -2510,7 +2631,7 @@ 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.
---@return (true|Effect)[] ---@return (true|Effect)[]
function FusionSpell.GetMaterialEffects(c,summon_card,matlocation,materials) function FusionSpell.GetMaterialEffects(c,summon_card,matlocation,materials)
local res={} local res={}
if c:IsLocation(matlocation) then if c:IsLocation(matlocation) then
...@@ -2577,7 +2698,7 @@ function FusionSpell.MultiMaterialEffectPrompt(effects,tp,e) ...@@ -2577,7 +2698,7 @@ function FusionSpell.MultiMaterialEffectPrompt(effects,tp,e)
end 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
--- @param fusion_spell_additional_fcheck_function FUSION_FCHECK_FUNCTION --- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION
function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additional_fcheck_function,tp,tc) function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additional_fcheck_function,tp,tc)
return (function(f_tp,mg,fc) return (function(f_tp,mg,fc)
local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc) local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc)
...@@ -2586,7 +2707,7 @@ function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additio ...@@ -2586,7 +2707,7 @@ function FusionSpell.GetFusionSpellFCheckAdditionalFunction(fusion_spell_additio
end end
--- all material must come from chain material, only pass all and pass to the gcheck of fusion spell --- all material must come from chain material, only pass all and pass to the gcheck of fusion spell
--- @param fusion_spell_additional_fcheck_function FUSION_FCHECK_FUNCTION --- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION
function FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fcheck_function,tp,c) function FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fcheck_function,tp,c)
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)
......
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