Commit 249c13e0 authored by 未闻皂名's avatar 未闻皂名

2024/10/15 Cost数量动态的选择方式优化

parent 55a34a75
Pipeline #30493 passed with stages
in 9 minutes and 6 seconds
-- Rush Duel 代价 -- Rush Duel 代价
RushDuel = RushDuel or {} RushDuel = RushDuel or {}
-- 内部方法: 获取选择范围
function RushDuel._private_get_select_range(min, max, ...)
if type(min) == "function" then
min = min(...)
end
if type(max) == "function" then
max = max(...)
end
return min, max
end
-- 内部方法: 选择匹配卡片, 执行操作 -- 内部方法: 选择匹配卡片, 执行操作
function RushDuel._private_cost_select_match(hint, filter, s_range, o_range, min, max, except_self, action) function RushDuel._private_cost_select_match(hint, filter, s_range, o_range, min, max, except_self, action)
return function(e, tp, eg, ep, ev, re, r, rp, chk) return function(e, tp, eg, ep, ev, re, r, rp, chk)
...@@ -8,6 +19,7 @@ function RushDuel._private_cost_select_match(hint, filter, s_range, o_range, min ...@@ -8,6 +19,7 @@ function RushDuel._private_cost_select_match(hint, filter, s_range, o_range, min
if except_self then if except_self then
expect = e:GetHandler() expect = e:GetHandler()
end end
local min, max = RushDuel._private_get_select_range(min, max, e, tp, eg, ep, ev, re, r, rp, chk)
if chk == 0 then if chk == 0 then
return Duel.IsExistingMatchingCard(filter, tp, s_range, o_range, min, expect, e, tp, eg, ep, ev, re, r, rp) return Duel.IsExistingMatchingCard(filter, tp, s_range, o_range, min, expect, e, tp, eg, ep, ev, re, r, rp)
end end
...@@ -23,6 +35,7 @@ function RushDuel._private_cost_select_group(hint, filter, check, s_range, o_ran ...@@ -23,6 +35,7 @@ function RushDuel._private_cost_select_group(hint, filter, check, s_range, o_ran
if except_self then if except_self then
expect = e:GetHandler() expect = e:GetHandler()
end end
local min, max = RushDuel._private_get_select_range(min, max, e, tp, eg, ep, ev, re, r, rp, chk)
local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, e, tp, eg, ep, ev, re, r, rp) local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, e, tp, eg, ep, ev, re, r, rp)
if chk == 0 then if chk == 0 then
return g:CheckSubGroup(check, min, max, e, tp, eg, ep, ev, re, r, rp) return g:CheckSubGroup(check, min, max, e, tp, eg, ep, ev, re, r, rp)
...@@ -110,12 +123,14 @@ function RushDuel.CostSendGroupToDeckSort(filter, check, field, min, max, except ...@@ -110,12 +123,14 @@ function RushDuel.CostSendGroupToDeckSort(filter, check, field, min, max, except
return RushDuel._private_cost_select_group(HINTMSG_TODECK, filter, check, field, 0, min, max, except_self, action) return RushDuel._private_cost_select_group(HINTMSG_TODECK, filter, check, field, 0, min, max, except_self, action)
end end
-- 代价: 选择匹配卡片, 返回卡组上面或下面 -- 代价: 选择匹配卡片, 返回卡组上面或下面
function RushDuel.CostSendMatchToDeckTopOrBottom(filter, field, min, max, except_self, top_desc, bottom_desc, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendMatchToDeckTopOrBottom(filter, field, min, max, except_self, top_desc, bottom_desc, hint_selection, confirm, set_label_before, set_object_before, set_label_after,
set_object_after)
local action = RushDuel._private_action_send_deck_top_or_bottom(top_desc, bottom_desc, REASON_COST, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after) local action = RushDuel._private_action_send_deck_top_or_bottom(top_desc, bottom_desc, REASON_COST, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after)
return RushDuel._private_cost_select_match(HINTMSG_TODECK, filter, field, 0, min, max, except_self, action) return RushDuel._private_cost_select_match(HINTMSG_TODECK, filter, field, 0, min, max, except_self, action)
end end
-- 代价: 选择子卡片组, 返回卡组上面或下面 -- 代价: 选择子卡片组, 返回卡组上面或下面
function RushDuel.CostSendGroupToDeckTopOrBottom(filter, check, field, min, max, except_self, top_desc, bottom_desc, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendGroupToDeckTopOrBottom(filter, check, field, min, max, except_self, top_desc, bottom_desc, hint_selection, confirm, set_label_before, set_object_before, set_label_after,
set_object_after)
local action = RushDuel._private_action_send_deck_top_or_bottom(top_desc, bottom_desc, REASON_COST, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after) local action = RushDuel._private_action_send_deck_top_or_bottom(top_desc, bottom_desc, REASON_COST, hint_selection, confirm, set_label_before, set_object_before, set_label_after, set_object_after)
return RushDuel._private_cost_select_group(HINTMSG_TODECK, filter, check, field, 0, min, max, except_self, action) return RushDuel._private_cost_select_group(HINTMSG_TODECK, filter, check, field, 0, min, max, except_self, action)
end end
...@@ -245,7 +260,7 @@ function RushDuel.CostSendOnFieldSubToGrave(filter, check, min, max, except_self ...@@ -245,7 +260,7 @@ function RushDuel.CostSendOnFieldSubToGrave(filter, check, min, max, except_self
end end
-- 代价: 把手卡·场上的卡送去墓地 -- 代价: 把手卡·场上的卡送去墓地
function RushDuel.CostSendHandOrFieldToGrave(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendHandOrFieldToGrave(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after)
return RushDuel.CostSendMatchToGrave(filter, LOCATION_HAND+LOCATION_ONFIELD, min, max, except_self, false, false, set_label_before, set_object_before, set_label_after, set_object_after) return RushDuel.CostSendMatchToGrave(filter, LOCATION_HAND + LOCATION_ONFIELD, min, max, except_self, false, false, set_label_before, set_object_before, set_label_after, set_object_after)
end end
-- 代价: 让怪兽返回卡组 -- 代价: 让怪兽返回卡组
function RushDuel.CostSendMZoneToDeck(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendMZoneToDeck(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after)
...@@ -257,7 +272,8 @@ function RushDuel.CostSendMZoneToDeckBottom(filter, min, max, except_self, set_l ...@@ -257,7 +272,8 @@ function RushDuel.CostSendMZoneToDeckBottom(filter, min, max, except_self, set_l
end end
-- 代价: 让怪兽返回卡组上面或下面 -- 代价: 让怪兽返回卡组上面或下面
function RushDuel.CostSendMZoneToDeckTopOrBottom(filter, min, max, top_desc, bottom_desc, except_self, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendMZoneToDeckTopOrBottom(filter, min, max, top_desc, bottom_desc, except_self, set_label_before, set_object_before, set_label_after, set_object_after)
return RushDuel.CostSendMatchToDeckTopOrBottom(filter, LOCATION_MZONE, min, max, except_self, top_desc, bottom_desc, true, false, set_label_before, set_object_before, set_label_after, set_object_after) return RushDuel.CostSendMatchToDeckTopOrBottom(filter, LOCATION_MZONE, min, max, except_self, top_desc, bottom_desc, true, false, set_label_before, set_object_before, set_label_after,
set_object_after)
end end
-- 代价: 让场上的卡返回卡组 -- 代价: 让场上的卡返回卡组
function RushDuel.CostSendOnFieldToDeck(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendOnFieldToDeck(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after)
...@@ -309,7 +325,8 @@ function RushDuel.CostSendGraveToDeckTopOrBottom(filter, min, max, top_desc, bot ...@@ -309,7 +325,8 @@ function RushDuel.CostSendGraveToDeckTopOrBottom(filter, min, max, top_desc, bot
end end
-- 代价: 让墓地的卡返回卡组上面或下面 (子卡片组) -- 代价: 让墓地的卡返回卡组上面或下面 (子卡片组)
function RushDuel.CostSendGraveSubToDeckTopOrBottom(filter, check, min, max, top_desc, bottom_desc, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendGraveSubToDeckTopOrBottom(filter, check, min, max, top_desc, bottom_desc, set_label_before, set_object_before, set_label_after, set_object_after)
return RushDuel.CostSendGroupToDeckTopOrBottom(filter, check, LOCATION_GRAVE, min, max, false, top_desc, bottom_desc, false, true, set_label_before, set_object_before, set_label_after, set_object_after) return RushDuel.CostSendGroupToDeckTopOrBottom(filter, check, LOCATION_GRAVE, min, max, false, top_desc, bottom_desc, false, true, set_label_before, set_object_before, set_label_after,
set_object_after)
end end
-- 代价: 让怪兽返回手卡 -- 代价: 让怪兽返回手卡
function RushDuel.CostSendMZoneToHand(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after) function RushDuel.CostSendMZoneToHand(filter, min, max, except_self, set_label_before, set_object_before, set_label_after, set_object_after)
......
...@@ -25,15 +25,15 @@ end ...@@ -25,15 +25,15 @@ end
function cm.filter(c) function cm.filter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) return c:IsType(TYPE_SPELL+TYPE_TRAP)
end end
function cm.check(g) function cm.max(e,tp,eg,ep,ev,re,r,rp)
local ct=Duel.GetMatchingGroupCount(cm.filter,0,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) local ct=Duel.GetMatchingGroupCount(cm.filter,0,LOCATION_ONFIELD,LOCATION_ONFIELD,nil)
return g:GetCount()<=ct return math.min(ct,5)
end end
function cm.condition(e,tp,eg,ep,ev,re,r,rp) function cm.condition(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
return RD.IsSummonTurn(c) and c:GetFlagEffect(20109045)~=0 return RD.IsSummonTurn(c) and c:GetFlagEffect(20109045)~=0
end end
cm.cost=RD.CostSendGraveSubToDeckBottom(cm.costfilter,cm.check,1,5,nil,nil,Group.GetCount) cm.cost=RD.CostSendGraveToDeckBottom(cm.costfilter,1,cm.max,nil,nil,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
local g=Duel.GetMatchingGroup(cm.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil) local g=Duel.GetMatchingGroup(cm.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil)
......
...@@ -17,13 +17,11 @@ end ...@@ -17,13 +17,11 @@ end
function cm.costfilter(c) function cm.costfilter(c)
return c:IsFaceup() and c:IsRace(RACE_BEASTWARRIOR) and c:IsAbleToGraveAsCost() return c:IsFaceup() and c:IsRace(RACE_BEASTWARRIOR) and c:IsAbleToGraveAsCost()
end end
function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.max(e,tp,eg,ep,ev,re,r,rp)
local max=Duel.GetMatchingGroupCount(Card.IsDefensePos,tp,0,LOCATION_MZONE,nil) local ct=Duel.GetMatchingGroupCount(Card.IsDefensePos,tp,0,LOCATION_MZONE,nil)
if chk==0 then return max>0 and Duel.IsExistingMatchingCard(cm.costfilter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end return math.min(ct,2)
RD.SelectAndDoAction(HINTMSG_TOGRAVE,cm.costfilter,tp,LOCATION_MZONE,0,1,math.min(max,2),e:GetHandler(),function(g)
e:SetLabel(Duel.SendtoGrave(g,REASON_COST))
end)
end end
cm.cost=RD.CostSendMZoneToGrave(cm.costfilter,1,cm.max,true,nil,nil,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDefensePos,tp,0,LOCATION_MZONE,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDefensePos,tp,0,LOCATION_MZONE,1,nil) end
local ct=e:GetLabel() local ct=e:GetLabel()
......
...@@ -20,16 +20,15 @@ end ...@@ -20,16 +20,15 @@ end
function cm.exfilter(c) function cm.exfilter(c)
return c:IsFaceup() and c:IsType(TYPE_NORMAL) and c:IsRace(RACE_PYRO) return c:IsFaceup() and c:IsType(TYPE_NORMAL) and c:IsRace(RACE_PYRO)
end end
function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.max(e,tp,eg,ep,ev,re,r,rp)
local max=math.min(Duel.GetMatchingGroupCount(cm.filter,tp,LOCATION_GRAVE,0,nil),Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)) local ct1=Duel.GetMatchingGroupCount(cm.filter,tp,LOCATION_GRAVE,0,nil)
if chk==0 then return max>0 and Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,e:GetHandler()) end local ct2=Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) return math.min(ct1,ct2)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,max,nil)
local ct=Duel.SendtoGrave(g,REASON_COST)
e:SetLabel(ct)
end end
cm.cost=RD.CostSendHandToGrave(Card.IsAbleToGraveAsCost,1,cm.max,nil,nil,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_GRAVE,0,1,nil)
and Duel.IsPlayerCanDraw(tp,1) end
local ct=e:GetLabel() local ct=e:GetLabel()
RD.TargetDraw(tp,ct) RD.TargetDraw(tp,ct)
end end
......
...@@ -20,13 +20,11 @@ end ...@@ -20,13 +20,11 @@ end
function cm.desfilter(c) function cm.desfilter(c)
return c:IsFaceup() and RD.IsDefenseBelow(c,1600) return c:IsFaceup() and RD.IsDefenseBelow(c,1600)
end end
function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.max(e,tp,eg,ep,ev,re,r,rp)
if chk==0 then return Duel.IsExistingMatchingCard(cm.costfilter,tp,LOCATION_HAND,0,1,nil) end local ct=Duel.GetMatchingGroupCount(cm.desfilter,tp,0,LOCATION_MZONE,nil)
local max=Duel.GetMatchingGroupCount(cm.desfilter,tp,0,LOCATION_MZONE,nil) return math.min(ct,3)
RD.SelectAndDoAction(HINTMSG_TOGRAVE,cm.costfilter,tp,LOCATION_HAND,0,1,math.min(max,3),nil,function(g)
e:SetLabel(Duel.SendtoGrave(g,REASON_COST))
end)
end end
cm.cost=RD.CostSendHandToGrave(cm.costfilter,1,cm.max,nil,nil,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(cm.desfilter,tp,0,LOCATION_MZONE,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(cm.desfilter,tp,0,LOCATION_MZONE,1,nil) end
local ct=e:GetLabel() local ct=e:GetLabel()
......
...@@ -18,18 +18,18 @@ end ...@@ -18,18 +18,18 @@ end
function cm.costfilter(c,e,tp) function cm.costfilter(c,e,tp)
return not c:IsPublic() and RD.IsDefense(c,0) return not c:IsPublic() and RD.IsDefense(c,0)
end end
function cm.costcheck(g,e,tp)
local ct1=RD.GetMZoneCount(tp,2)
local ct2=Duel.GetMatchingGroupCount(cm.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp)
return g:GetCount()<=math.min(ct1,ct2)
end
function cm.spfilter(c,e,tp) function cm.spfilter(c,e,tp)
return RD.IsDefense(c,0) and RD.IsCanBeSpecialSummoned(c,e,tp,POS_FACEDOWN_DEFENSE) return RD.IsDefense(c,0) and RD.IsCanBeSpecialSummoned(c,e,tp,POS_FACEDOWN_DEFENSE)
end end
function cm.max(e,tp,eg,ep,ev,re,r,rp)
local ct1=RD.GetMZoneCount(tp,2)
local ct2=Duel.GetMatchingGroupCount(cm.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp)
return math.min(ct1,ct2)
end
function cm.condition(e,tp,eg,ep,ev,re,r,rp) function cm.condition(e,tp,eg,ep,ev,re,r,rp)
return RD.IsSummonTurn(e:GetHandler()) return RD.IsSummonTurn(e:GetHandler())
end end
cm.cost=RD.CostShowGroupHand(cm.costfilter,cm.costcheck,1,2,Group.GetCount) cm.cost=RD.CostShowHand(cm.costfilter,1,cm.max,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetMZoneCount(tp)>0 if chk==0 then return Duel.GetMZoneCount(tp)>0
and Duel.IsExistingMatchingCard(cm.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end and Duel.IsExistingMatchingCard(cm.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
......
...@@ -21,15 +21,15 @@ end ...@@ -21,15 +21,15 @@ end
function cm.costfilter(c,e,tp) function cm.costfilter(c,e,tp)
return not c:IsPublic() and c:IsType(TYPE_SPELL) return not c:IsPublic() and c:IsType(TYPE_SPELL)
end end
function cm.costcheck(g,e,tp)
local ct1=RD.GetMZoneCount(tp,2)
local ct2=Duel.GetMatchingGroupCount(cm.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp)
return g:GetCount()<=math.min(ct1,ct2)
end
function cm.spfilter(c,e,tp) function cm.spfilter(c,e,tp)
return c:IsLevelBelow(8) and c:IsAttribute(ATTRIBUTE_WIND) and c:IsRace(RACE_PSYCHO) and RD.IsCanBeSpecialSummoned(c,e,tp,POS_FACEUP) return c:IsLevelBelow(8) and c:IsAttribute(ATTRIBUTE_WIND) and c:IsRace(RACE_PSYCHO) and RD.IsCanBeSpecialSummoned(c,e,tp,POS_FACEUP)
end end
cm.cost=RD.CostShowGroupHand(cm.costfilter,cm.costcheck,1,2,Group.GetCount) function cm.max(e,tp,eg,ep,ev,re,r,rp)
local ct1=RD.GetMZoneCount(tp,2)
local ct2=Duel.GetMatchingGroupCount(cm.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp)
return math.min(ct1,ct2)
end
cm.cost=RD.CostShowHand(cm.costfilter,1,cm.max,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetMZoneCount(tp)>0 if chk==0 then return Duel.GetMZoneCount(tp)>0
and Duel.IsExistingMatchingCard(cm.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end and Duel.IsExistingMatchingCard(cm.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
......
...@@ -22,13 +22,11 @@ end ...@@ -22,13 +22,11 @@ end
function cm.thfilter(c) function cm.thfilter(c)
return c:IsCode(list[1],list[2]) and c:IsAbleToHand() return c:IsCode(list[1],list[2]) and c:IsAbleToHand()
end end
function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.max(e,tp,eg,ep,ev,re,r,rp)
local max=Duel.GetMatchingGroupCount(cm.filter,tp,0,LOCATION_GRAVE,nil) local ct=Duel.GetMatchingGroupCount(cm.filter,tp,0,LOCATION_GRAVE,nil)
if chk==0 then return max>0 and Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_ONFIELD,0,1,nil) end return math.min(ct,2)
RD.SelectAndDoAction(HINTMSG_TOGRAVE,Card.IsAbleToGraveAsCost,tp,LOCATION_ONFIELD,0,1,math.min(max,2),nil,function(g)
e:SetLabel(Duel.SendtoGrave(g,REASON_COST))
end)
end end
cm.cost=RD.CostSendOnFieldToGrave(Card.IsAbleToGraveAsCost,1,cm.max,false,nil,nil,Group.GetCount)
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,0,LOCATION_GRAVE,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(cm.filter,tp,0,LOCATION_GRAVE,1,nil) end
local ct=e:GetLabel() local ct=e:GetLabel()
......
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