--- Add LOCATION_EXTRA and opponent mzone to EFFECT_EXTRA_FUSION_MATERIAL list, remove once core updated
...
...
@@ -2394,6 +2397,7 @@ function FusionSpell.CreateSummonEffect(c,opts)
local stage_x_operation=opts.stage_x_operation 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 post_select_mat_opponent_location=opts.post_select_mat_opponent_location or 0
local gc=opts.gc or function() return nil end
local fusion_spell_matfilter=opts.fusion_spell_matfilter or aux.TRUE
...
...
@@ -2419,6 +2423,7 @@ function FusionSpell.CreateSummonEffect(c,opts)
sumpos,
extra_target,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter
))
...
...
@@ -2435,6 +2440,7 @@ function FusionSpell.CreateSummonEffect(c,opts)
sumpos,
stage_x_operation,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter
))
...
...
@@ -2443,7 +2449,7 @@ function FusionSpell.CreateSummonEffect(c,opts)
end
---@param fusfilter fun(c:Card):boolean filter for the monster to be Fusion Summoned
---@param matfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION 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 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
...
...
@@ -2454,8 +2460,9 @@ end
---@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 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 post_select_mat_opponent_location integer location where to find the materials after 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
---@param fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell
---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell
function FusionSpell.GetSummonTarget(
fusfilter,
matfilter,
...
...
@@ -2469,6 +2476,7 @@ function FusionSpell.GetSummonTarget(
sumpos,
extra_target,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter
)
...
...
@@ -2491,6 +2499,7 @@ function FusionSpell.GetSummonTarget(
additional_fgoalcheck,
sumtype,sumpos,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter)
end,
...
...
@@ -2513,7 +2522,7 @@ function FusionSpell.GetSummonTarget(
end
---@param fusfilter fun(c:Card):boolean filter for the monster to be Fusion Summoned
---@param matfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION 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 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
...
...
@@ -2524,8 +2533,9 @@ end
---@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 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 post_select_mat_opponent_location integer location where to find the materials after 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
---@param fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell
---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell
function FusionSpell.GetSummonOperation(
fusfilter,
matfilter,
...
...
@@ -2539,6 +2549,7 @@ function FusionSpell.GetSummonOperation(
sumpos,
stage_x_operation,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter
)
...
...
@@ -2561,6 +2572,7 @@ function FusionSpell.GetSummonOperation(
additional_fgoalcheck,
sumtype,sumpos,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
gc,
fusion_spell_matfilter)
end,
...
...
@@ -2613,8 +2625,19 @@ function FusionSpell.GetSummonOperation(
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.
--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.
...
...
@@ -2786,7 +2823,7 @@ function FusionSpell.GetSummonOperation(
end
end
---@param pre_select_mat_location integer|(fun(tc:Card,tp:integer):integer) 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 post_select_mat_location integer location where to find the materials after known the materials
---@return integer locations all possible locations of the material
function FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
...
...
@@ -2803,13 +2840,14 @@ end
---@param tc Card the target card to summon
---@param tp integer the triggering player
---@param e Effect the fusion effect
---@param matfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION 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 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 sumtype integer summon type
---@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 fusion_spell_matfilter fun(c:Card,tp:integer):boolean a material must pass this to be legal as material come from fusion spell
---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location
---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell
function FusionSpell.GetMaterialsGroupForTargetCard(
tc,
tp,
...
...
@@ -2820,16 +2858,12 @@ function FusionSpell.GetMaterialsGroupForTargetCard(
post_select_mat_location,
sumtype,
pre_select_mat_opponent_location,
post_select_mat_opponent_location,
fusion_spell_matfilter
)
local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
local mg=FusionSpell.GetFusionMaterial(tp,all_locations)
local calculated_mat_opponent_location=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_opponent_location,post_select_mat_opponent_location)
local opponent_mg=FusionSpell.GetFusionMaterialFromOpponentLocation(tp,calculated_mat_opponent_location)
if #opponent_mg>0 then
mg:Merge(opponent_mg)
...
...
@@ -2848,7 +2882,7 @@ function FusionSpell.GetMaterialsGroupForTargetCard(
local effects=FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map)
if #effects<1 then
return false
end
...
...
@@ -2870,18 +2904,57 @@ function FusionSpell.GetOperationCodeByMaterialLocation(location,mat_operation_c
---@param matfilter fun(c:Card,e:Effect,tp:integer):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 (default LOCATION_HAND|LOCATION_MZONE)
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION 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 (default LOCATION_HAND|LOCATION_MZONE)
---@param post_select_mat_location integer location where to find the materials after 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 post_select_mat_opponent_location integer location where to find the materials before known the materials on opponent location
---@param gc fun(e:Effect):Card|nil
---@param fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell
@@ -2889,7 +2962,7 @@ function FusionSpell.SummonTargetFilter(c,fusfilter,matfilter,e,tp,pre_select_ma
return res
end
---@param matfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion.
---@param gc fun(e:Effect):Card|nil
---@return {[Effect]:Group} effect_targets_map Return a map of different chain material to potiential fusion targets
function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,matfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
...
...
@@ -2914,7 +2987,7 @@ function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,matfilter,add
return chain_material_targets
end
---@param matfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the materials, use it only under very strong limitation like D-Fusion.
---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion.
---@param gc fun(e:Effect):Card|nil
---@return boolean res return whether there is a valid target for any chain material effect
function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,matfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc)
...
...
@@ -3109,27 +3182,23 @@ end
--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 fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell
---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location
---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell
---@param e Effect the fusion effect
---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order
function FusionSpell.GetMaterialEffects(c,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map)
local calculated_mat_opponent_location=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_opponent_location,post_select_mat_opponent_location)
local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location)
--- @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 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 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 fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell
--- @param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location
--- @param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell
--- @param e Effect the fusion effect
--- @param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order
local material_effects=FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map)
if (#material_effects)==1 and material_effects[1]~=true then
--- @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|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE)
--- @param e Effect the fusion effect
function FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(fusion_spell_additional_fgoalcheck_function,tp,tc,pre_select_mat_location,e)