Commit f5f404e4 authored by 未闻皂名's avatar 未闻皂名

2023/12/27 可选操作的取消功能

parent 9f50e853
Pipeline #24701 passed with stages
in 36 minutes and 38 seconds
...@@ -6,24 +6,31 @@ RushDuel.DisableSpecialSummonConfirm = false ...@@ -6,24 +6,31 @@ RushDuel.DisableSpecialSummonConfirm = false
-- 内部方法: 选择匹配卡片, 执行操作 -- 内部方法: 选择匹配卡片, 执行操作
function RushDuel._private_action_select_match(hint, filter, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...) function RushDuel._private_action_select_match(hint, filter, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...)
if min < 2 or Duel.IsExistingMatchingCard(filter, tp, s_range, o_range, min, expect, ...) then local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, ...)
if g:GetCount() >= min then
Duel.Hint(HINT_SELECTMSG, tp, hint) Duel.Hint(HINT_SELECTMSG, tp, hint)
local g = Duel.SelectMatchingCard(tp, filter, tp, s_range, o_range, min, max, expect, ...) local sg = g:Select(tp, min, max, nil)
if g:GetCount() > 0 then if sg:GetCount() > 0 then
RushDuel.HintOrConfirm(g, hint_selection, confirm, 1 - tp) RushDuel.HintOrConfirm(sg, hint_selection, confirm, 1 - tp)
return action(g, ...) return action(sg, ...)
end end
end end
return 0 return 0
end end
-- 内部方法: 可以选择匹配卡片, 执行操作 -- 内部方法: 可以选择匹配卡片, 执行操作
function RushDuel._private_action_can_select_match(desc, hint, filter, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...) function RushDuel._private_action_can_select_match(desc, hint, filter, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...)
if Duel.IsExistingMatchingCard(filter, tp, s_range, o_range, min, expect, ...) and Duel.SelectYesNo(tp, desc) then local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, ...)
Duel.Hint(HINT_SELECTMSG, tp, hint) if g:GetCount() >= min then
local g = Duel.SelectMatchingCard(tp, filter, tp, s_range, o_range, min, max, expect, ...) ::cancel::
if g:GetCount() > 0 then if Duel.SelectYesNo(tp, desc) then
RushDuel.HintOrConfirm(g, hint_selection, confirm, 1 - tp) Duel.Hint(HINT_SELECTMSG, tp, hint)
return action(g, ...) local sg = RushDuel.SelectGroup(tp, g, min, max)
if sg == nil then
goto cancel
elseif sg:GetCount() > 0 then
RushDuel.HintOrConfirm(sg, hint_selection, confirm, 1 - tp)
return action(sg, ...)
end
end end
end end
return 0 return 0
...@@ -44,12 +51,17 @@ end ...@@ -44,12 +51,17 @@ end
-- 内部方法: 可以选择子卡片组, 执行操作 -- 内部方法: 可以选择子卡片组, 执行操作
function RushDuel._private_action_can_select_group(desc, hint, filter, check, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...) function RushDuel._private_action_can_select_group(desc, hint, filter, check, tp, s_range, o_range, min, max, expect, hint_selection, confirm, action, ...)
local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, ...) local g = Duel.GetMatchingGroup(filter, tp, s_range, o_range, expect, ...)
if g:CheckSubGroup(check, min, max, ...) and Duel.SelectYesNo(tp, desc) then if g:CheckSubGroup(check, min, max, ...) then
Duel.Hint(HINT_SELECTMSG, tp, hint) ::cancel::
local sg = g:SelectSubGroup(tp, check, false, min, max, ...) if Duel.SelectYesNo(tp, desc) then
if sg:GetCount() > 0 then Duel.Hint(HINT_SELECTMSG, tp, hint)
RushDuel.HintOrConfirm(sg, hint_selection, confirm, 1 - tp) local sg = g:SelectSubGroup(tp, check, true, min, max, ...)
return action(sg, ...) if sg == nil then
goto cancel
elseif sg:GetCount() > 0 then
RushDuel.HintOrConfirm(sg, hint_selection, confirm, 1 - tp)
return action(sg, ...)
end
end end
end end
return 0 return 0
...@@ -334,17 +346,22 @@ function RushDuel.RevealDeckTopAndCanSelect(player, count, desc, hint, filter, m ...@@ -334,17 +346,22 @@ function RushDuel.RevealDeckTopAndCanSelect(player, count, desc, hint, filter, m
Duel.ConfirmDecktop(player, count) Duel.ConfirmDecktop(player, count)
local g = Duel.GetDecktopGroup(player, count) local g = Duel.GetDecktopGroup(player, count)
if g:GetCount() > 0 then if g:GetCount() > 0 then
if g:IsExists(filter, min, nil, ...) and Duel.SelectYesNo(player, desc) then local mg = g:Filter(filter, nil, ...)
Duel.Hint(HINT_SELECTMSG, player, hint) if mg:GetCount() >= min then
local sg = g:FilterSelect(player, filter, min, max, nil, ...) ::cancel::
g:Sub(sg) if Duel.SelectYesNo(player, desc) then
return sg, g Duel.Hint(HINT_SELECTMSG, player, hint)
else local sg = RushDuel.SelectGroup(player, mg, min, max)
return Group.CreateGroup(), g if sg == nil then
goto cancel
elseif sg:GetCount() > 0 then
g:Sub(sg)
return sg, g
end
end
end end
else
return g, g
end end
return Group.CreateGroup(), g
end end
-- 操作: 翻开卡组并可以选择卡 (子卡片组) -- 操作: 翻开卡组并可以选择卡 (子卡片组)
function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filter, check, min, max, ...) function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filter, check, min, max, ...)
...@@ -352,17 +369,21 @@ function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filt ...@@ -352,17 +369,21 @@ function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filt
local g = Duel.GetDecktopGroup(player, count) local g = Duel.GetDecktopGroup(player, count)
if g:GetCount() > 0 then if g:GetCount() > 0 then
local mg=g:Filter(filter,nil) local mg=g:Filter(filter,nil)
if mg:CheckSubGroup(check, min, max, ...) and Duel.SelectYesNo(player, desc) then if mg:CheckSubGroup(check, min, max, ...) then
Duel.Hint(HINT_SELECTMSG, player, hint) ::cancel::
local sg = mg:SelectSubGroup(player, check, false, min, max, ...) if Duel.SelectYesNo(player, desc) then
g:Sub(sg) Duel.Hint(HINT_SELECTMSG, player, hint)
return sg, g local sg = mg:SelectSubGroup(player, check, true, min, max, ...)
else if sg == nil then
return Group.CreateGroup(), g goto cancel
elseif sg:GetCount() > 0 then
g:Sub(sg)
return sg, g
end
end
end end
else
return g, g
end end
return Group.CreateGroup(), g
end end
-- 可选操作: 抽卡 -- 可选操作: 抽卡
......
...@@ -123,9 +123,9 @@ function RushDuel.SendToDeckSort(target, sequence, reason, sort_player, target_p ...@@ -123,9 +123,9 @@ function RushDuel.SendToDeckSort(target, sequence, reason, sort_player, target_p
local g = RushDuel.ToMaximunGroup(target) local g = RushDuel.ToMaximunGroup(target)
local ct = 0 local ct = 0
if sequence == SEQ_DECKTOP then if sequence == SEQ_DECKTOP then
ct = aux.PlaceCardsOnDeckTop(sort_player, g, reason) ct = Auxiliary.PlaceCardsOnDeckTop(sort_player, g, reason)
elseif sequence == SEQ_DECKBOTTOM then elseif sequence == SEQ_DECKBOTTOM then
ct = aux.PlaceCardsOnDeckBottom(sort_player, g, reason) ct = Auxiliary.PlaceCardsOnDeckBottom(sort_player, g, reason)
else else
ct = Duel.SendtoDeck(target, nil, sequence, reason) ct = Duel.SendtoDeck(target, nil, sequence, reason)
end end
...@@ -143,3 +143,29 @@ function RushDuel.GetBaseAttackOnTribute(c) ...@@ -143,3 +143,29 @@ function RushDuel.GetBaseAttackOnTribute(c)
end end
return math.max(0, atk) return math.max(0, atk)
end end
-- 让玩家选择卡片组的 min ~ max 张卡,可以取消
function RushDuel.SelectGroup(player, group, min, max)
local sg = Group.CreateGroup()
local finish = (#sg >= min and #sg <= max)
while #sg < max do
local cg = group:Clone()
cg:Sub(sg)
finish = (#sg >= min and #sg <= max)
if #cg == 0 then break end
local cancel = not finish
local tc = cg:SelectUnselect(sg, player, finish, cancel, min, max)
if not tc then break end
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg == max then finish = true end
else
sg:RemoveCard(tc)
end
end
if finish then
return sg
else
return nil
end
end
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