Commit d186385f authored by xiaoye's avatar xiaoye

fix 魔合成

parent 879f9867
...@@ -881,10 +881,7 @@ function VgD.MixCost(cost) ...@@ -881,10 +881,7 @@ function VgD.MixCost(cost)
if bc then if bc then
VgF.Sendto(LOCATION_LOCK,bc,POS_FACEUP,REASON_COST) VgF.Sendto(LOCATION_LOCK,bc,POS_FACEUP,REASON_COST)
e:SetLabelObject(bc) e:SetLabelObject(bc)
local bce = bc:GetActivateEffect() VgD.MixCostOperation(c,bc,tp)
if VgF.GetValueType(cost)=="function" and bce and bce:GetCost() then VgD.MixCostOperation(c,bc,e,tp)
elseif VgF.GetValueType(cost)=="function" then cost(e,tp,eg,ep,ev,re,r,rp)
elseif bce and bce:GetCost() then bce:GetCost()(e,tp,eg,ep,ev,re,r,rp,chk) end
end end
else else
if VgF.GetValueType(cost)=="function" then cost(e,tp,eg,ep,ev,re,r,rp) end if VgF.GetValueType(cost)=="function" then cost(e,tp,eg,ep,ev,re,r,rp) end
...@@ -893,8 +890,7 @@ function VgD.MixCost(cost) ...@@ -893,8 +890,7 @@ function VgD.MixCost(cost)
end end
function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk) function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk)
if Duel.IsPlayerAffectedByEffect(tp,AFFECT_CODE_MIX_DIFFERENT_NAME) and c:IsCode(mc:GetCode()) then return false end if Duel.IsPlayerAffectedByEffect(tp,AFFECT_CODE_MIX_DIFFERENT_NAME) and c:IsCode(mc:GetCode()) then return false end
local ce = c:GetActivateEffect() --得到需要支付的费用(从哪来,几张卡,什么卡)
if not ce or (ce:GetCost() and not ce:GetCost()(e,tp,eg,ep,ev,re,r,rp,0)) then return false end
local cfrom, cval, cfilter, mcfrom, mcval, mcfilter local cfrom, cval, cfilter, mcfrom, mcval, mcfilter
table.copy(cfrom,c.cos_from) table.copy(cfrom,c.cos_from)
table.copy(cval,c.cos_val) table.copy(cval,c.cos_val)
...@@ -902,6 +898,7 @@ function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk) ...@@ -902,6 +898,7 @@ function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk)
table.copy(mcfrom,mc.cos_from) table.copy(mcfrom,mc.cos_from)
table.copy(mcval,mc.cos_val) table.copy(mcval,mc.cos_val)
table.copy(mcfilter,mc.cos_filter) table.copy(mcfilter,mc.cos_filter)
--如果都有费用要付,则合成费用
if #cfrom>0 and #mcfrom>0 then if #cfrom>0 and #mcfrom>0 then
for cv=1,#cfrom do for cv=1,#cfrom do
local c_cost_from=VgF.ShiftLocationFromString(cfrom[cv]) local c_cost_from=VgF.ShiftLocationFromString(cfrom[cv])
...@@ -913,32 +910,70 @@ function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk) ...@@ -913,32 +910,70 @@ function VgD.MixCostFilter(c,e,tp,eg,ep,ev,re,r,rp,mc,chk)
local c_cos_val=cval[cv] local c_cos_val=cval[cv]
if VgF.GetValueType(mc_cos_val)~="number" then mc_cos_val=0 end if VgF.GetValueType(mc_cos_val)~="number" then mc_cos_val=0 end
if VgF.GetValueType(c_cos_val)~="number" then c_cos_val=0 end if VgF.GetValueType(c_cos_val)~="number" then c_cos_val=0 end
if mc_cost_from==LOCATION_OVERLAY and Duel.IsPlayerAffectedByEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX) then mc_cos_val,c_cos_val=0,0 end local both_cos_val=mc_cos_val+c_cos_val
--判断其他减少费用的效果
if mc_cost_from==LOCATION_OVERLAY and Duel.GetFlagEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX)>0 then mc_cos_val,c_cos_val,both_cos_val=0,0,0 end
local mcg=VgF.GetMatchingGroup(mcfilter[mcv],tp,mc_cost_from,0,c,e,tp) local mcg=VgF.GetMatchingGroup(mcfilter[mcv],tp,mc_cost_from,0,c,e,tp)
local cg=VgF.GetMatchingGroup(cfilter[cv],tp,c_cost_from,0,mc,e,tp) local cg=VgF.GetMatchingGroup(cfilter[cv],tp,c_cost_from,0,mc,e,tp)
if mcg:GetCount()<mc_cos_val or cg:GetCount()<c_cos_val then return false end local a=mcg:GetCount()<mc_cos_val
local b=cg:GetCount()<c_cos_val
if mc_cost_from==LOCATION_DAMAGE and Duel.GetFlagEffect(tp,10402010)>0 then
local c_10402010=Duel.GetFlagEffectLabel(tp,10402010)
if both_cos_val>c_10402010 then both_cos_val=both_cos_val-c_10402010
else both_cos_val=0
end
if a then
if mc_cos_val-mcg:GetCount()<=c_10402010 then
a=false
c_10402010=c_10402010-(mc_cos_val-mcg:GetCount())
end
end
if b then
if c_cos_val-cg:GetCount()<=c_10402010 then
b=false
c_10402010=c_10402010-(c_cos_val-cg:GetCount())
end
end
end
--判断是否足够支付费用
if a or b then return false end
mcg:Merge(cg) mcg:Merge(cg)
if mcg:GetCount()<mc_cos_val+c_cos_val then return false end if mcg:GetCount()<both_cos_val then return false end
pos=mcv pos=mcv
end end
end end
--如果合成了,则删去已合成的内容
if pos>0 then if pos>0 then
table.remove(mcfrom,pos) table.remove(mcfrom,pos)
table.remove(mcval,pos) table.remove(mcval,pos)
table.remove(mcfilter,pos) table.remove(mcfilter,pos)
--如果没有合成,则在原费用上操作
else else
local c_cos_val=cval[cv] local c_cos_val=cval[cv]
if VgF.GetValueType(c_cos_val)~="number" then c_cos_val=0 end if VgF.GetValueType(c_cos_val)~="number" then c_cos_val=0 end
if c_cost_from==LOCATION_OVERLAY and Duel.IsPlayerAffectedByEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX) then c_cos_val=0 end --判断其他减少费用的效果
if c_cost_from==LOCATION_OVERLAY and Duel.GetFlagEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX)>0 then c_cos_val=0 end
if c_cost_from==LOCATION_DAMAGE and Duel.GetFlagEffect(tp,10402010)>0 then
local c_10402010=Duel.GetFlagEffectLabel(tp,10402010)
if c_cos_val>c_10402010 then c_cos_val=c_cos_val-c_10402010
else c_cos_val=0
end
end
local cg=VgF.GetMatchingGroup(cfilter[cv],tp,c_cost_from,0,mc,e,tp) local cg=VgF.GetMatchingGroup(cfilter[cv],tp,c_cost_from,0,mc,e,tp)
if cg:GetCount()<c_cos_val then return false end if cg:GetCount()<c_cos_val then return false end
end end
end end
elseif #mcfrom>0 and not chk then return false --如果本体需要支付而合成的卡不需要支付
elseif #mcfrom>0 then
--/如果本体不需要支付而合成的卡需要支付/都不需要支付
--均可返回true
else return true
end end
return VgF.LvCondition(c) return VgF.LvCondition(c)
end end
function VgD.MixCostOperation(c,bc,e,tp) function VgD.MixCostOperation(c,bc,tp)
--得到需要支付的费用(从哪来,到哪去,最少几张卡,最多几张卡,什么卡)
local cfrom, cto, cval, cval_max, cfilter, bcfrom, bcto, bcval, bcval_max, bcfilter local cfrom, cto, cval, cval_max, cfilter, bcfrom, bcto, bcval, bcval_max, bcfilter
table.copy(cfrom,c.cos_from) table.copy(cfrom,c.cos_from)
table.copy(cto,c.cos_to) table.copy(cto,c.cos_to)
...@@ -959,31 +994,66 @@ function VgD.MixCostOperation(c,bc,e,tp) ...@@ -959,31 +994,66 @@ function VgD.MixCostOperation(c,bc,e,tp)
local g_val_c_max={} local g_val_c_max={}
local g_val_bc_max={} local g_val_bc_max={}
local except_group=Group.FromCards(c,bc) local except_group=Group.FromCards(c,bc)
for bcv=1,#bcfrom do --在这里合成
local bc_cost_from=VgF.ShiftLocationFromString(bcfrom[bcv]) if #bcfrom>0 and #cfrom>0 then
local pos=0 for bcv=1,#bcfrom do
for cv=1,#cfrom do local bc_cost_from=VgF.ShiftLocationFromString(bcfrom[bcv])
local c_cost_from=VgF.ShiftLocationFromString(cfrom[cv]) local pos=0
if bc_cost_from==c_cost_from and VgF.ShiftLocationFromString(cto[cv])==VgF.ShiftLocationFromString(bcto[bcv]) then for cv=1,#cfrom do
pos=bcv local c_cost_from=VgF.ShiftLocationFromString(cfrom[cv])
table.insert(g_from,cfrom[cv]) if bc_cost_from==c_cost_from and VgF.ShiftLocationFromString(cto[cv])==VgF.ShiftLocationFromString(bcto[bcv]) then
table.insert(g_to,cto[cv]) pos=bcv
table.insert(g_filter_c,cfilter[cv]) table.insert(g_from,cfrom[cv])
table.insert(g_to,cto[cv])
table.insert(g_filter_c,cfilter[cv])
table.insert(g_filter_bc,bcfilter[bcv])
if VgF.GetValueType(cval[cv])=="number" then table.insert(g_val_c,cval[cv]) else table.insert(g_val_c,0) end
if VgF.GetValueType(bcval[bcv])=="number" then table.insert(g_val_bc,bcval[bcv]) else table.insert(g_val_bc,0) end
if VgF.GetValueType(cval_max[cv])=="number" then table.insert(g_val_c_max,cval_max[cv]) else table.insert(g_val_c_max,0) end
if VgF.GetValueType(bcval_max[bcv])=="number" then table.insert(g_val_bc_max,bcval_max[bcv]) else table.insert(g_val_bc_max,0) end
end
end
if pos>0 then
table.remove(bcfrom,pos)
table.remove(bcto,pos)
table.remove(bcval,pos)
table.remove(bcval_max,pos)
table.remove(bcfilter,pos)
else
table.insert(g_from,bcfrom[bcv])
table.insert(g_to,bcto[bcv])
table.insert(g_filter_c,VgF.False())
table.insert(g_filter_bc,bcfilter[bcv]) table.insert(g_filter_bc,bcfilter[bcv])
table.insert(g_val_c,cval[cv]) table.insert(g_val_c,0)
table.insert(g_val_bc,bcval[bcv]) if VgF.GetValueType(bcval[bcv])=="number" then table.insert(g_val_bc,bcval[bcv]) else table.insert(g_val_bc,0) end
table.insert(g_val_c_max,cval_max[cv]) table.insert(g_val_c_max,0)
table.insert(g_val_bc_max,bcval_max[bcv]) if VgF.GetValueType(bcval_max[bcv])=="number" then table.insert(g_val_bc_max,bcval_max[bcv]) else table.insert(g_val_bc_max,0) end
end end
end end
if pos>0 then elseif #bcfrom>0 then
table.remove(bcfrom,pos) for bcv=1,#bcfrom do
table.remove(bcto,pos) table.insert(g_from,bcfrom[bcv])
table.remove(bcval,pos) table.insert(g_to,bcto[bcv])
table.remove(bcval_max,pos) table.insert(g_filter_c,VgF.False())
table.remove(bcfilter,pos) table.insert(g_filter_bc,bcfilter[bcv])
table.insert(g_val_c,0)
if VgF.GetValueType(bcval[bcv])=="number" then table.insert(g_val_bc,bcval[bcv]) else table.insert(g_val_bc,0) end
table.insert(g_val_c_max,0)
if VgF.GetValueType(bcval_max[bcv])=="number" then table.insert(g_val_bc_max,bcval_max[bcv]) else table.insert(g_val_bc_max,0) end
end
elseif #cfrom>0 then
for cv=1,#cfrom do
table.insert(g_from,cfrom[cv])
table.insert(g_to,cto[cv])
table.insert(g_filter_c,cfilter[cv])
table.insert(g_filter_bc,VgF.False())
if VgF.GetValueType(cval[cv])=="number" then table.insert(g_val_c,cval[cv]) else table.insert(g_val_c,0) end
table.insert(g_val_bc,0)
if VgF.GetValueType(cval_max[cv])=="number" then table.insert(g_val_c_max,cval_max[cv]) else table.insert(g_val_c_max,0) end
table.insert(g_val_bc_max,0)
end end
end end
--开始支付合成完的费用
for i=1,#g_from do for i=1,#g_from do
local tg_from=VgF.ShiftLocationFromString(g_from[i]) local tg_from=VgF.ShiftLocationFromString(g_from[i])
local tg_to=VgF.ShiftLocationFromString(g_to[i]) local tg_to=VgF.ShiftLocationFromString(g_to[i])
...@@ -996,7 +1066,38 @@ function VgD.MixCostOperation(c,bc,e,tp) ...@@ -996,7 +1066,38 @@ function VgD.MixCostOperation(c,bc,e,tp)
local tg_val_bc_max=g_val_bc_max[i] local tg_val_bc_max=g_val_bc_max[i]
local hintmsg=HINTMSG_SELECT local hintmsg=HINTMSG_SELECT
local ext_params={} local ext_params={}
if tg_from==LOCATION_OVERLAY and Duel.IsPlayerAffectedByEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX) and Duel.SelectYesNo(tp,VgF.Stringid(10401023,1)) then tg_val_c,tg_val_bc=0,0 end if tg_val_c_max<tg_val_c then tg_val_c_max=tg_val_c end
if tg_val_bc_max<tg_val_bc then tg_val_bc_max=tg_val_bc end
--判断其他减少费用的效果
--继承的少女 亨德莉娜
if tg_from==LOCATION_OVERLAY and Duel.GetFlagEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX)>0 then
if tg:GetCount()<tg_val_c+tg_val_bc or tg:FilterCount(tg_filter_c,nil)<tg_val_c or tg:FilterCount(tg_filter_bc,nil)<tg_val_bc then
Duel.ResetFlagEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX)
goto continue
elseif Duel.SelectYesNo(tp,VgF.Stringid(10401023,1)) then
Duel.ResetFlagEffect(tp,AFFECT_CODE_OVERLAY_COST_FREE_WHEN_MIX)
goto continue
end
end
--鬼首狩灵
if tg_from==LOCATION_DAMAGE and Duel.GetFlagEffect(tp,10402010)>0 then
local c_10402010=Duel.GetFlagEffectLabel(tp,10402010)
local filter_count_c=tg:FilterCount(tg_filter_c,nil)
local filter_count_bc=tg:FilterCount(tg_filter_bc,nil)
if filter_count_c<tg_val_c and tg_val_c-filter_count_c<=c_10402010 then
c_10402010=c_10402010-(tg_val_c-filter_count_c)
tg_val_c=filter_count_c
end
if filter_count_bc<tg_val_bc and tg_val_bc-filter_count_bc<=c_10402010 then
c_10402010=c_10402010-(tg_val_bc-filter_count_bc)
tg_val_bc=filter_count_bc
end
if filter_count_c<tg_val_c or filter_count_bc<tg_val_bc then
Debug.Message("There is a value error in mixing costs")
goto continue
else Duel.ResetFlagEffect(tp,10402010)
end
end
if tg:GetCount()<tg_val_c+tg_val_bc then goto continue end if tg:GetCount()<tg_val_c+tg_val_bc then goto continue end
if VgF.GetValueType(tg_to)=="number" then if VgF.GetValueType(tg_to)=="number" then
if tg_to==LOCATION_DROP then if tg_to==LOCATION_DROP then
......
...@@ -75,6 +75,11 @@ end ...@@ -75,6 +75,11 @@ end
function VgF.True() function VgF.True()
return true return true
end end
---一个总是返回false的函数。
---@return false
function VgF.False()
return false
end
---返回g中的“下一张卡”。第一次调用会返回第一张卡。没有下一张卡会返回nil。 ---返回g中的“下一张卡”。第一次调用会返回第一张卡。没有下一张卡会返回nil。
---@param g Group 要遍历的卡片组 ---@param g Group 要遍历的卡片组
---@return function 指示返回的卡的函数 ---@return function 指示返回的卡的函数
......
local cm,m,o=GetID() local cm,m,o=GetID()
function cm.initial_effect(c) function cm.initial_effect(c)
vgf.VgCard(c) vgf.VgCard(c)
vgd.EffectTypeContinuousChangeAttack(c,m,EFFECT_TYPE_SINGLE,5000,cm.con)
vgd.GlobalCheckEffect(c,m,EVENT_CHAINING,cm.checkcon)
vgd.EffectTypeTrigger(c,m,nil,EFFECT_TYPE_SINGLE,EVENT_SPSUMMON_SUCCESS,cm.operation,nil,vgf.RSummonCondition)
end end
function cm.checkcon(e,tp,eg,ep,ev,re,r,rp)
return re:IsHasType(EFFECT_TYPE_ACTIVATE) and rp==tp
end
function cm.con(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFlagEffect(tp,m)>0 and vgf.RMonsterCondition(e)
end
function cm.operation(e,tp,eg,ep,ev,re,r,rp)
local ct=Duel.GetFlagEffectLabel(tp,m)
if vgf.GetValueType(ct)=="number" then
ct=ct+1
Duel.ResetFlagEffect(tp,m)
Duel.RegisterFlagEffect(tp,m,RESET_PHASE+PHASE_END,0,1,ct)
else Duel.RegisterFlagEffect(tp,m,RESET_PHASE+PHASE_END,0,1,1) end
end
\ No newline at end of file
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