Skip to content

Commit 557ba1b

Browse files
authored
Update "Ace of Wand"
- Fixed issues with destruction detection - General script polish
1 parent 05ebf06 commit 557ba1b

File tree

1 file changed

+47
-30
lines changed

1 file changed

+47
-30
lines changed

unofficial/c511001477.lua

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,58 @@
22
--Ace of Wand
33
local s,id=GetID()
44
function s.initial_effect(c)
5-
--Activate
6-
local e1=Effect.CreateEffect(c)
7-
e1:SetCategory(CATEGORY_COIN)
8-
e1:SetType(EFFECT_TYPE_ACTIVATE)
9-
e1:SetCode(EVENT_LEAVE_FIELD)
10-
e1:SetCondition(s.condition)
11-
e1:SetTarget(s.target)
12-
e1:SetOperation(s.activate)
13-
c:RegisterEffect(e1)
5+
--Activate
6+
local e1=Effect.CreateEffect(c)
7+
e1:SetCategory(CATEGORY_COIN+CATEGORY_RECOVER+CATEGORY_DAMAGE)
8+
e1:SetType(EFFECT_TYPE_ACTIVATE)
9+
e1:SetCode(EVENT_LEAVE_FIELD)
10+
e1:SetCondition(s.condition)
11+
e1:SetTarget(s.target)
12+
e1:SetOperation(s.activate)
13+
c:RegisterEffect(e1)
1414
end
1515
s.toss_coin=true
16-
function s.cfilter(c,eg)
17-
local tp=c:GetControler()
18-
return c:IsReason(REASON_DESTROY) and c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
19-
and not eg:IsExists(s.cfilter2,1,nil,tp)
20-
end
21-
function s.cfilter2(c,tp)
22-
return c:IsReason(REASON_DESTROY) and c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
23-
and c:IsControler(1-tp)
16+
function s.confilter(c)
17+
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY|REASON_EFFECT)
2418
end
2519
function s.condition(e,tp,eg,ep,ev,re,r,rp)
26-
return eg:IsExists(s.cfilter,1,nil,eg)
20+
return eg:IsExists(s.confilter,1,nil)
2721
end
2822
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
29-
if chk==0 then return true end
30-
Duel.SetOperationInfo(0,CATEGORY_COIN,nil,0,tp,1)
23+
if chk==0 then return true end
24+
Duel.SetOperationInfo(0,CATEGORY_COIN,nil,0,tp,1)
25+
Duel.SetPossibleOperationInfo(0,CATEGORY_DAMAGE,nil,0,PLAYER_ALL,0)
26+
Duel.SetPossibleOperationInfo(0,CATEGORY_RECOVER,nil,0,PLAYER_ALL,0)
3127
end
3228
function s.activate(e,tp,eg,ep,ev,re,r,rp)
33-
local g=eg:Filter(s.cfilter,nil,eg)
34-
local p=g:GetFirst():GetControler()
35-
local sum=g:GetSum(Card.GetAttack)
36-
local res=Duel.TossCoin(tp,1)
37-
if res==COIN_HEADS then
38-
Duel.Recover(p,sum,REASON_EFFECT)
39-
elseif res==COIN_TAILS then
40-
Duel.Damage(p,sum,REASON_EFFECT)
41-
end
42-
end
29+
local g=eg:Filter(s.confilter,nil)
30+
local pg,og=g:Split(Card.IsPreviousControler,nil,tp)
31+
local psum=0
32+
local osum=0
33+
if #pg>0 then
34+
for tc in pg:Iter() do
35+
psum=psum+tc:GetPreviousAttackOnField()
36+
end
37+
end
38+
if #og>0 then
39+
for tc in og:Iter() do
40+
osum=osum+tc:GetPreviousAttackOnField()
41+
end
42+
end
43+
local res=Duel.TossCoin(tp,1)
44+
if res==COIN_HEADS then
45+
if #pg>0 then
46+
Duel.Recover(tp,psum,REASON_EFFECT)
47+
end
48+
if #og>0 then
49+
Duel.Recover(1-tp,osum,REASON_EFFECT)
50+
end
51+
elseif res==COIN_TAILS then
52+
if #pg>0 then
53+
Duel.Damage(tp,psum,REASON_EFFECT)
54+
end
55+
if #og>0 then
56+
Duel.Damage(1-tp,osum,REASON_EFFECT)
57+
end
58+
end
59+
end

0 commit comments

Comments
 (0)