Skip to content

Commit 5b17bbf

Browse files
authored
"Destiny Draw (Skill)" fix
Also take into account gaining LP when keeping track of how much LP a player has lost.
1 parent 7fddbd6 commit 5b17bbf

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

skill/c300201002.lua

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
--Destiny Draw
1+
--Destiny Draw (Skill)
22
local s,id=GetID()
33
function s.initial_effect(c)
4-
--skill
4+
--Activate skill
55
aux.AddPreDrawSkillProcedure(c,1,false,s.flipcon,s.flipop)
66
aux.GlobalCheck(s,function()
77
s[0]=nil
@@ -17,26 +17,23 @@ function s.initial_effect(c)
1717
end
1818
function s.checkop()
1919
for tp=0,1 do
20-
if not s[tp] then s[tp]=Duel.GetLP(tp) end
21-
if s[tp]>Duel.GetLP(tp) then
22-
s[2+tp]=s[2+tp]+(s[tp]-Duel.GetLP(tp))
23-
s[tp]=Duel.GetLP(tp)
20+
local current_lp=Duel.GetLP(tp)
21+
if not s[tp] then s[tp]=current_lp end
22+
if s[tp]>current_lp then
23+
s[2+tp]=s[2+tp]+(s[tp]-current_lp)
24+
s[tp]=current_lp
25+
elseif s[tp]<current_lp then
26+
s[tp]=current_lp
2427
end
2528
end
2629
end
2730
function s.flipcon(e,tp,eg,ep,ev,re,r,rp)
28-
--condition
29-
return Duel.GetCurrentChain()==0 and tp==Duel.GetTurnPlayer() and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0
30-
and Duel.GetDrawCount(tp)>0 and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil)
31+
return Duel.GetCurrentChain()==0 and Duel.IsTurnPlayer(tp) and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0
32+
and Duel.GetDrawCount(tp)>0 and Duel.IsExistingMatchingCard(Card.IsAbleToHand,tp,LOCATION_DECK,0,1,nil)
3133
and s[2+tp]>=2000
3234
end
33-
function s.thfilter(c)
34-
return c:IsAbleToHand()
35-
end
3635
function s.flipop(e,tp,eg,ep,ev,re,r,rp)
37-
--ask if you want to activate the skill or not
3836
if not Duel.SelectYesNo(tp,aux.Stringid(id,0)) then return end
39-
--draw replace
4037
local dt=Duel.GetDrawCount(tp)
4138
if dt~=0 then
4239
_replace_count=0
@@ -53,12 +50,10 @@ function s.flipop(e,tp,eg,ep,ev,re,r,rp)
5350
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
5451
Duel.Hint(HINT_CARD,tp,id)
5552
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
56-
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
57-
if #g~=0 then
58-
if Duel.SendtoHand(g,nil,REASON_EFFECT)~=0 then
59-
Duel.Hint(HINT_SKILL_FLIP,tp,id|(2<<32))
60-
s[2+tp]=0
61-
end
53+
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToHand,tp,LOCATION_DECK,0,1,1,nil)
54+
if #g>0 and Duel.SendtoHand(g,nil,REASON_EFFECT)>0 then
6255
Duel.ConfirmCards(1-tp,g)
56+
Duel.Hint(HINT_SKILL_FLIP,tp,id|(2<<32))
57+
s[2+tp]=0
6358
end
6459
end

0 commit comments

Comments
 (0)