Skip to content

Commit f6868ca

Browse files
authored
optimize "Sky Striker Alternative - Lemnis Gate"
avoid taking too much time to compute combinations when there are a lot of candidate cards * infer the spell count by subtracting the monster count from the subgroup count, instead of looping through the cards again * stop looking for more candidate subgroups if the remaining spell count can never match the current monster count (or vice-versa) * limit the max number of cards that can be selected to be twice whichever is lower between the monster count and the spell count in the full group (which are pre-computed outside the rescon)
1 parent ef77149 commit f6868ca

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

pre-release/c101301069.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,24 @@ function s.tdfilter(c,e)
3535
return ((c:IsSetCard(SET_SKY_STRIKER_ACE) and c:IsMonster()) or (c:IsSetCard(SET_SKY_STRIKER) and c:IsSpell()))
3636
and c:IsAbleToDeck() and c:IsCanBeEffectTarget(e)
3737
end
38-
function s.rescon(sg,e,tp,mg)
39-
return sg:FilterCount(Card.IsMonster,nil)==sg:FilterCount(Card.IsSpell,nil)
38+
function s.rescon(full_mct,full_sct)
39+
return function(sg,e,tp,mg)
40+
local mct=sg:FilterCount(Card.IsMonster,nil)
41+
local sct=#sg-mct
42+
if mct==sct then return true end
43+
local rem_mct=full_mct-mct
44+
local rem_sct=full_sct-sct
45+
return false,mct>sct and rem_sct<(mct-sct) or rem_mct<(sct-mct)
46+
end
4047
end
4148
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
4249
if chkc then return false end
4350
local g=Duel.GetMatchingGroup(s.tdfilter,tp,LOCATION_GRAVE,0,nil,e)
44-
local ct=#g
45-
if chk==0 then return ct>1 and aux.SelectUnselectGroup(g,e,tp,2,2,s.rescon,0) end
46-
local tg=aux.SelectUnselectGroup(g,e,tp,2,ct,s.rescon,1,tp,HINTMSG_TODECK,s.rescon)
51+
local full_mct=g:FilterCount(Card.IsMonster,nil)
52+
local full_sct=#g-full_mct
53+
local rescon=s.rescon(full_mct,full_sct)
54+
if chk==0 then return full_mct>0 and full_sct>0 and aux.SelectUnselectGroup(g,e,tp,2,2,rescon,0) end
55+
local tg=aux.SelectUnselectGroup(g,e,tp,2,math.min(full_mct,full_sct)*2,rescon,1,tp,HINTMSG_TODECK,rescon)
4756
Duel.SetTargetCard(tg)
4857
Duel.SetOperationInfo(0,CATEGORY_TODECK,tg,#tg,tp,0)
4958
Duel.SetPossibleOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_ONFIELD)
@@ -83,4 +92,4 @@ function s.spop(e,tp,eg,ep,ev,re,r,rp)
8392
if sc then
8493
Duel.LinkSummon(tp,sc)
8594
end
86-
end
95+
end

0 commit comments

Comments
 (0)