Commit ff9b2447 authored by xiaoye's avatar xiaoye

fix

parent f86aa560
......@@ -2,7 +2,7 @@ local cm,m,o=GetID()
function cm.initial_effect(c)
vgd.AbilityAct(c,m,LOCATION_CIRCLE,cm.op1,vgf.cost.CounterBlast(1),nil,nil,1)
vgd.AbilityCont(c, m, LOCATION_CIRCLE, EFFECT_TYPE_SINGLE, EFFECT_UPDATE_ATTACK, 10000, cm.con)
vgd.TriggerCountUp(c,m,1,cm.con2)
vgd.DriveUp(c,m,1,cm.con2)
end
function cm.con(e,c)
local tp=e:GetHandlerPlayer()
......
......@@ -17,7 +17,7 @@ function cm.operation(e,tp,eg,ep,ev,re,r,rp)
local g=vgf.SelectMatchingCard(HINTMSG_CALL,e,tp,cm.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if vgf.Sendto(LOCATION_CIRCLE,g,SUMMON_VALUE_REVOLT,tp,0x20)>0 then
local mg=Duel.GetOperatedGroup()
vgd.TriggerCountUp(c,m,-2,nil,RESET_PHASE+PHASE_END,mg)
vgd.DriveUp(c,m,-2,nil,RESET_PHASE+PHASE_END,mg)
end
end
function cm.condition(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -20,5 +20,5 @@ function cm.operation1(e,tp,eg,ep,ev,re,r,rp)
end
end
function cm.cfilter(c,mc)
return vgf.GetColumnGroup(c):IsContains(mc) and c:IsControler(mc:GetControler()) and c:GetFlagEffect(FLAG_SUPPORT)>0
return Card.GetColumnGroup(c):IsContains(mc) and c:IsControler(mc:GetControler()) and c:GetFlagEffect(FLAG_SUPPORT)>0
end
\ No newline at end of file
......@@ -15,5 +15,5 @@ function cm.con(e,tp,eg,ep,ev,re,r,rp)
return vgf.IsExistingMatchingCard(cm.cfilter,tp,LOCATION_CIRCLE,0,1,nil,e:GetHandler()) and Duel.GetAttacker()==e:GetHandler() and vgf.con.IsR(e)
end
function cm.cfilter(c,mc)
return vgf.GetColumnGroup(c):IsContains(mc) and c:IsControler(mc:GetControler()) and c:GetFlagEffect(FLAG_SUPPORT)>0
return Card.GetColumnGroup(c):IsContains(mc) and c:IsControler(mc:GetControler()) and c:GetFlagEffect(FLAG_SUPPORT)>0
end
\ No newline at end of file
......@@ -35,5 +35,5 @@ function cm.op1(e,tp,eg,ep,ev,re,r,rp)
Duel.ConfirmCards(1-tp,g)
vgf.Sendto(LOCATION_DECK,g,tp,SEQ_DECKTOP,REASON_EFFECT)
end
vgd.TriggerCountUp(c,m,1,nil,RESET_PHASE+PHASE_END)
vgd.DriveUp(c,m,1,nil,RESET_PHASE+PHASE_END)
end
\ No newline at end of file
......@@ -6,7 +6,7 @@ function cm.initial_effect(c)
end
function cm.op(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=vgf.GetColumnGroup(c):FilterSelect(tp,cm.filter,1,1,nil,tp)
local g=Card.GetColumnGroup(c):FilterSelect(tp,cm.filter,1,1,nil,tp)
local atk=2000
if Duel.GetFlagEffectLabel(tp,FLAG_CONDITION)==10102001 then
atk=5000
......
......@@ -9,7 +9,7 @@ end
function cm.op(e,tp,eg,ep,ev,re,r,rp)
local g=vgf.SelectMatchingCard(HINTMSG_OPPO,e,tp,vgf.filter.IsR,tp,0,LOCATION_CIRCLE,1,1,nil)
if g:GetCount()==0 then return end
local sg=vgf.GetColumnGroup(g:GetFirst()):Filter(cm.filter,nil,1-tp)
local sg=Card.GetColumnGroup(g:GetFirst()):Filter(cm.filter,nil,1-tp)
if sg:GetCount()>0 then g:Sub(sg) end
vgf.Sendto(LOCATION_DECK,g,nil,0,REASON_EFFECT)
local og=Duel.GetOperatedGroup()
......
......@@ -9,7 +9,7 @@ function cm.op(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.ChangePosition(c,POS_FACEUP_ATTACK)
vgd.TriggerCountUp(c,m,-1,nil,RESET_PHASE+PHASE_END)
vgd.DriveUp(c,m,-1,nil,RESET_PHASE+PHASE_END)
end
end
function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk)
......
......@@ -22,7 +22,7 @@ end
function cm.op2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) or c:IsFacedown() then e:Reset() return end
local g=vgf.GetColumnGroup(c):Filter(cm.filter,nil,tp)
local g=Card.GetColumnGroup(c):Filter(cm.filter,nil,tp)
vgf.Sendto(LOCATION_DROP,g,REASON_EFFECT)
Duel.Draw(tp,1,REASON_EFFECT)
e:Reset()
......
......@@ -11,5 +11,5 @@ function cm.initial_effect(c)
end
function cm.tg(e,tc)
local c=e:GetHandler()
return vgf.filter.Front(tc) and vgf.GetColumnGroup(c):IsContains(tc) and tc:IsControler(c:GetControler())
return vgf.filter.Front(tc) and Card.GetColumnGroup(c):IsContains(tc) and tc:IsControler(c:GetControler())
end
\ No newline at end of file
......@@ -8,7 +8,7 @@ function cm.op(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=vgf.SelectMatchingCard(HINTMSG_RMONSTER,e,tp,nil,tp,0,LOCATION_V_CIRCLE,1,1,nil)
vgf.Sendto(LOCATION_DROP,g,REASON_EFFECT)
vgd.TriggerCountUp(c, m, 1, nil, RESET_PHASE+PHASE_END)
vgd.DriveUp(c, m, 1, nil, RESET_PHASE+PHASE_END)
end
function cm.checkfilter(c,tp)
return c:IsControler(tp) and c:IsPreviousLocation(LOCATION_CIRCLE)
......
......@@ -15,6 +15,6 @@ function cm.op(e,tp,eg,ep,ev,re,r,rp)
end
end
function cm.filter(c,tp,mc)
local g=vgf.GetColumnGroup(mc)
local g=Card.GetColumnGroup(mc)
return g:GetCount()>0 and g:IsContains(c)
end
\ No newline at end of file
......@@ -316,19 +316,19 @@ function VgD.Register.CardTrigger(c)
e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_MOVE)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCondition(VgD.CardTriggerCondtion('Damage'))
e1:SetOperation(VgD.CardTriggerOperation('Damage'))
e1:SetCondition(VgD.Register.CardTriggerCondtion('Damage'))
e1:SetOperation(VgD.Register.CardTriggerOperation('Damage'))
c:RegisterEffect(e1)
local e2 = e1:Clone()
e2:SetCondition(VgD.CardTriggerCondtion('Normal'))
e2:SetOperation(VgD.CardTriggerOperation('Normal'))
e2:SetCondition(VgD.Register.CardTriggerCondtion('Normal'))
e2:SetOperation(VgD.Register.CardTriggerOperation('Normal'))
c:RegisterEffect(e2)
local e3 = e1:Clone()
e3:SetCondition(VgD.CardTriggerCondtion('EffectDamage'))
e3:SetOperation(VgD.CardTriggerOperation('EffectDamage'))
e3:SetCondition(VgD.Register.CardTriggerCondtion('EffectDamage'))
e3:SetOperation(VgD.Register.CardTriggerOperation('EffectDamage'))
c:RegisterEffect(e3)
end
function VgD.CardTriggerCondtion(chkcon)
function VgD.Register.CardTriggerCondtion(chkcon)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if chkcon == 'EffectDamage' then
......@@ -341,7 +341,7 @@ function VgD.CardTriggerCondtion(chkcon)
return Duel.GetAttacker() and Duel.GetAttacker():GetControler() == cp and c:IsLocation(LOCATION_TRIGGER) and Duel.GetFlagEffect(tp, FLAG_EFFECT_DAMAGE) == 0
end
end
function VgD.CardTriggerOperation(chkop)
function VgD.Register.CardTriggerOperation(chkop)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local _, m = c:GetOriginalCode()
......@@ -873,7 +873,7 @@ function VgD.Register.MonsterBattle(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCondition(function (e, tp, eg, ep, ev, re, r, rp)
local tc = e:GetHandler()
if not tc:IsSkill(SKILL_BOOST) or Duel.GetTurnPlayer() ~= tp or not VgF.GetColumnGroup(Duel.GetAttacker()):IsContains(tc) then return false end
if not tc:IsSkill(SKILL_BOOST) or Duel.GetTurnPlayer() ~= tp or not Card.GetColumnGroup(Duel.GetAttacker()):IsContains(tc) then return false end
return true
end)
e1:SetTarget(function (e, tp, eg, ep, ev, re, r, rp, chk)
......@@ -1661,9 +1661,9 @@ end
---@param reset number|nil 效果的重置条件
---@param hc Card|nil 效果的拥有者, 没有则为 c
---@return Effect|nil 这个效果
function VgD.TriggerCountUp(c, m, num, con, reset, hc)
function VgD.DriveUp(c, m, num, con, reset, hc)
-- check func
if VgF.IllegalFunctionCheck("TriggerCountUp", c).con(con) then return end
if VgF.IllegalFunctionCheck("DriveUp", c).con(con) then return end
-- set param
local cm = _G["c"..(m or c:GetOriginalCode())]
cm.is_has_continuous = cm.is_has_continuous or not reset
......@@ -1679,11 +1679,11 @@ function VgD.TriggerCountUp(c, m, num, con, reset, hc)
e:SetProperty(EFFECT_FLAG_DELAY)
e:SetCondition(condition)
if reset then e:SetReset(RESET_EVENT + RESETS_STANDARD + reset) end
e:SetOperation(VgD.TriggerCountUpOperation(num))
e:SetOperation(VgD.DriveUpOperation(num))
hc:RegisterEffect(e)
return e
end
function VgD.TriggerCountUpOperation(num)
function VgD.DriveUpOperation(num)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local label = c:GetFlagEffectLabel(FLAG_ATTACK_TRIGGER)
......
......@@ -124,51 +124,6 @@ function VgF.GetAvailableLocation(tp, zone)
return z
end
---返回c所在列的所有单位。
---@param c Card 指示某一列的卡
---@return Group 这一列的所有单位
function VgF.GetColumnGroup(c)
local tp = c:GetControler()
local g = Group.CreateGroup()
if c:GetSequence() == 0 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 1)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 3, 4)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 1 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 0)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 3, 4)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 2 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 5)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 2, 5)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 3 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 4)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 0, 1)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 4 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 3)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 0, 1)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 5 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 2)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 2, 5)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
return g
end
---检查并转换 loc 以及 con 用于【起】等模板函数
function VgF.GetLocCondition(loc, con)
local con_exf = VgF.True
......@@ -549,8 +504,7 @@ end
function VgF.Cost.RetireGroup(g)
return function (e, tp, eg, ep, ev, re, r, rp, chk)
g = g or Group.FromCards(e:GetHandler())
local fg = g:Filter(function(c) return c:IsAbleToGraveAsCost() and (c ~= e:GetHandler() or c:IsRelateToEffect(e)) end, nil)
if chk == 0 then return #g == #fg end
if chk == 0 then return g:Every(function(c) return c:IsAbleToGraveAsCost() and (c ~= e:GetHandler() or c:IsRelateToEffect(e)) end, nil) end
VgF.Sendto(LOCATION_DROP, g, REASON_COST)
end
end
......@@ -748,6 +702,51 @@ end
--Card库自定义函数-----------------------------------------------------------------------
---返回c所在列的所有单位。
---@param c Card 指示某一列的卡
---@return Group 这一列的所有单位
function Card.GetColumnGroup(c)
local tp = c:GetControler()
local g = Group.CreateGroup()
if c:GetSequence() == 0 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 1)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 3, 4)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 1 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 0)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 3, 4)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 2 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 5)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 2, 5)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 3 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 4)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 0, 1)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 4 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 3)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 0, 1)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
if c:GetSequence() == 5 then
local sg1 = VgF.GetMatchingGroup(Card.IsSequence, tp, LOCATION_CIRCLE, 0, nil, 2)
local sg2 = VgF.GetMatchingGroup(Card.IsSequence, tp, 0, LOCATION_CIRCLE, nil, 2, 5)
if sg1:GetCount() > 0 then g:Merge(sg1) end
if sg2:GetCount() > 0 then g:Merge(sg2) end
end
return g
end
---判断c是否可以以规则的手段到G区域。
---@param c Card 要判断的卡
---@return boolean 指示c能否去到G区域。
......@@ -798,6 +797,10 @@ function Group.GetCardsFromGroup(g, val)
end
end
---遍历g的每一张卡
---@param g Group 要操作的卡片组
---@param f function 遍历时的回调函数
---@param ... any 额外参数
function Group.ForEach(g, f, ...)
local ext_params = {...}
if #g == 0 then return end
......@@ -807,6 +810,17 @@ function Group.ForEach(g, f, ...)
end
end
---判断g中的不等于except的卡是否均符合函数f
---@param g Group 要操作的卡片组
---@param f function 过滤函数
---@param except Card|Group|nil 不记入的卡
---@param ... any 额外参数
function Group.Every(g, f, except, ...)
local ext_params = {...}
except = VgF.GetValueType(except) == "Card" and Group.FromCards(except) or except
return g:Filter(f, except, table.unpack(ext_params)):GetCount() == g:GetCount() - except:GetCount()
end
function Group.CheckSubGroup(g, f, min, max, ...)
min = min or 1
max = max or #g
......
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