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
-- 内部方法: 选择匹配卡片, 执行操作
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)
local g = Duel.SelectMatchingCard(tp, filter, tp, s_range, o_range, min, max, expect, ...)
if g:GetCount() > 0 then
RushDuel.HintOrConfirm(g, hint_selection, confirm, 1 - tp)
return action(g, ...)
local sg = g:Select(tp, min, max, nil)
if sg:GetCount() > 0 then
RushDuel.HintOrConfirm(sg, hint_selection, confirm, 1 - tp)
return action(sg, ...)
end
end
return 0
end
-- 内部方法: 可以选择匹配卡片, 执行操作
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, ...)
if g:GetCount() >= min then
::cancel::
if Duel.SelectYesNo(tp, desc) then
Duel.Hint(HINT_SELECTMSG, tp, hint)
local g = Duel.SelectMatchingCard(tp, filter, tp, s_range, o_range, min, max, expect, ...)
if g:GetCount() > 0 then
RushDuel.HintOrConfirm(g, hint_selection, confirm, 1 - tp)
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
return 0
......@@ -44,14 +51,19 @@ end
-- 内部方法: 可以选择子卡片组, 执行操作
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, ...)
if g:CheckSubGroup(check, min, max, ...) and Duel.SelectYesNo(tp, desc) then
if g:CheckSubGroup(check, min, max, ...) then
::cancel::
if Duel.SelectYesNo(tp, desc) then
Duel.Hint(HINT_SELECTMSG, tp, hint)
local sg = g:SelectSubGroup(tp, check, false, min, max, ...)
if sg:GetCount() > 0 then
local sg = g:SelectSubGroup(tp, check, true, 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
return 0
end
-- 内部方法: 是否包含公开区域
......@@ -334,17 +346,22 @@ function RushDuel.RevealDeckTopAndCanSelect(player, count, desc, hint, filter, m
Duel.ConfirmDecktop(player, count)
local g = Duel.GetDecktopGroup(player, count)
if g:GetCount() > 0 then
if g:IsExists(filter, min, nil, ...) and Duel.SelectYesNo(player, desc) then
local mg = g:Filter(filter, nil, ...)
if mg:GetCount() >= min then
::cancel::
if Duel.SelectYesNo(player, desc) then
Duel.Hint(HINT_SELECTMSG, player, hint)
local sg = g:FilterSelect(player, filter, min, max, nil, ...)
local sg = RushDuel.SelectGroup(player, mg, min, max)
if sg == nil then
goto cancel
elseif sg:GetCount() > 0 then
g:Sub(sg)
return sg, g
else
return Group.CreateGroup(), g
end
else
return g, g
end
end
end
return Group.CreateGroup(), g
end
-- 操作: 翻开卡组并可以选择卡 (子卡片组)
function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filter, check, min, max, ...)
......@@ -352,17 +369,21 @@ function RushDuel.RevealDeckTopAndCanSelectGroup(player, count, desc, hint, filt
local g = Duel.GetDecktopGroup(player, count)
if g:GetCount() > 0 then
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
::cancel::
if Duel.SelectYesNo(player, desc) then
Duel.Hint(HINT_SELECTMSG, player, hint)
local sg = mg:SelectSubGroup(player, check, false, min, max, ...)
local sg = mg:SelectSubGroup(player, check, true, min, max, ...)
if sg == nil then
goto cancel
elseif sg:GetCount() > 0 then
g:Sub(sg)
return sg, g
else
return Group.CreateGroup(), g
end
else
return g, g
end
end
end
return Group.CreateGroup(), g
end
-- 可选操作: 抽卡
......
......@@ -123,9 +123,9 @@ function RushDuel.SendToDeckSort(target, sequence, reason, sort_player, target_p
local g = RushDuel.ToMaximunGroup(target)
local ct = 0
if sequence == SEQ_DECKTOP then
ct = aux.PlaceCardsOnDeckTop(sort_player, g, reason)
ct = Auxiliary.PlaceCardsOnDeckTop(sort_player, g, reason)
elseif sequence == SEQ_DECKBOTTOM then
ct = aux.PlaceCardsOnDeckBottom(sort_player, g, reason)
ct = Auxiliary.PlaceCardsOnDeckBottom(sort_player, g, reason)
else
ct = Duel.SendtoDeck(target, nil, sequence, reason)
end
......@@ -143,3 +143,29 @@ function RushDuel.GetBaseAttackOnTribute(c)
end
return math.max(0, atk)
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