Commit bc8393dd authored by mercury233's avatar mercury233 Committed by GitHub

fix Union Driver (#1973)

parent c72a6b76
...@@ -75,13 +75,17 @@ function c99249638.recost(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -75,13 +75,17 @@ function c99249638.recost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end end
function c99249638.refilter(c,tc,tp) function c99249638.refilter(c,tc,tp,exclude_modern_count)
return aux.CheckUnionEquip(c,tc) and c:CheckUnionTarget(tc) and c:IsType(TYPE_UNION) return aux.CheckUnionEquip(c,tc,exclude_modern_count) and c:CheckUnionTarget(tc) and c:IsType(TYPE_UNION)
and c:IsLevelBelow(4) and c:CheckUniqueOnField(tp) and not c:IsForbidden() and c:IsLevelBelow(4) and c:CheckUniqueOnField(tp) and not c:IsForbidden()
end end
function c99249638.retg(e,tp,eg,ep,ev,re,r,rp,chk) function c99249638.retg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return c:GetEquipTarget() and Duel.IsExistingMatchingCard(c99249638.refilter,tp,LOCATION_DECK,0,1,nil,c:GetEquipTarget(),tp) end local exct=aux.IsUnionState(e) and 1 or 0
return c:GetEquipTarget()
and Duel.IsExistingMatchingCard(c99249638.refilter,tp,LOCATION_DECK,0,1,nil,c:GetEquipTarget(),tp,exct)
end
local tc=e:GetLabelObject() local tc=e:GetLabelObject()
Duel.SetTargetCard(tc) Duel.SetTargetCard(tc)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,tc,1,0,0) Duel.SetOperationInfo(0,CATEGORY_EQUIP,tc,1,0,0)
...@@ -90,9 +94,9 @@ function c99249638.reop(e,tp,eg,ep,ev,re,r,rp) ...@@ -90,9 +94,9 @@ function c99249638.reop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,c99249638.refilter,tp,LOCATION_DECK,0,1,1,nil,tc,tp) local g=Duel.SelectMatchingCard(tp,c99249638.refilter,tp,LOCATION_DECK,0,1,1,nil,tc,tp,nil)
local ec=g:GetFirst() local ec=g:GetFirst()
if ec and aux.CheckUnionEquip(ec,tc) and Duel.Equip(tp,ec,tc) then if ec and Duel.Equip(tp,ec,tc) then
aux.SetUnionState(ec) aux.SetUnionState(ec)
end end
end end
......
...@@ -278,10 +278,12 @@ function Auxiliary.SetUnionState(c) ...@@ -278,10 +278,12 @@ function Auxiliary.SetUnionState(c)
c:RegisterEffect(e2) c:RegisterEffect(e2)
end end
end end
function Auxiliary.CheckUnionEquip(uc,tc) --uc: the union monster to be equipped, tc: the target monster
ct1,ct2=tc:GetUnionCount() function Auxiliary.CheckUnionEquip(uc,tc,exclude_modern_count)
if uc.old_union then return ct1==0 local modern_count,old_count=tc:GetUnionCount()
else return ct2==0 end if exclude_modern_count then modern_count=modern_count-exclude_modern_count end
if uc.old_union then return modern_count==0
else return old_count==0 end
end end
--EFFECT_DESTROY_SUBSTITUTE filter for modern union monsters --EFFECT_DESTROY_SUBSTITUTE filter for modern union monsters
function Auxiliary.UnionReplaceFilter(e,re,r,rp) function Auxiliary.UnionReplaceFilter(e,re,r,rp)
......
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