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)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c99249638.refilter(c,tc,tp)
return aux.CheckUnionEquip(c,tc) and c:CheckUnionTarget(tc) and c:IsType(TYPE_UNION)
function c99249638.refilter(c,tc,tp,exclude_modern_count)
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()
end
function c99249638.retg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
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()
Duel.SetTargetCard(tc)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,tc,1,0,0)
......@@ -90,9 +94,9 @@ function c99249638.reop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then
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()
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)
end
end
......
......@@ -278,10 +278,12 @@ function Auxiliary.SetUnionState(c)
c:RegisterEffect(e2)
end
end
function Auxiliary.CheckUnionEquip(uc,tc)
ct1,ct2=tc:GetUnionCount()
if uc.old_union then return ct1==0
else return ct2==0 end
--uc: the union monster to be equipped, tc: the target monster
function Auxiliary.CheckUnionEquip(uc,tc,exclude_modern_count)
local modern_count,old_count=tc:GetUnionCount()
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
--EFFECT_DESTROY_SUBSTITUTE filter for modern union monsters
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