--CONDITIONS ----------------------------------------------------------------------- --Event Group (eg) Check Condition function Auxiliary.EventGroupCond(f,min,max,exc) if not min then min=1 end return function(e,tp,eg,ep,ev,re,r,rp) local exc=(not exc) and nil or e:GetHandler() return eg:IsExists(f,min,exc,e,tp,eg,ep,ev,re,r,rp) and (not max or not eg:IsExists(f,max,exc,e,tp,eg,ep,ev,re,r,rp)) end end function Auxiliary.ExactEventGroupCond(f,ct,exc) if not ct then ct=1 end return function(e,tp,eg,ep,ev,re,r,rp) local exc=(not exc) and nil or e:GetHandler() return eg:FilterCount(f,exc,e,tp,eg,ep,ev,re,r,rp)==ct end end --Turn/Phase Conditions function Auxiliary.DrawPhaseCond(tp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsDrawPhase(tp) end end function Auxiliary.StandbyPhaseCond(tp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsStandbyPhase(tp) end end function Auxiliary.MainPhaseCond(tp,ct) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsMainPhase(tp,ct) end end function Auxiliary.StartOfBattlePhaseCond(tp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsStartOfBattlePhase(tp) end end function Auxiliary.BattlePhaseCond(tp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsBattlePhase(tp) end end function Auxiliary.MainOrBattlePhaseCond(tp,ct,bp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil if not bp then bp=tp end return Duel.IsMainPhase(tp,ct) or Duel.IsBattlePhase(bp) end end function Auxiliary.EndPhaseCond(tp) return function(e,p) local tp = (tp==0) and p or (tp==1) and 1-p or nil return Duel.IsEndPhase(tp) end end function Auxiliary.ExceptOnDamageStep() return Auxiliary.ExceptOnDamageCalc() end function Auxiliary.ExceptOnDamageCalc() return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated() end function Auxiliary.TurnPlayerCond(tp) return function(e,p) if not p then p=e:GetHandlerPlayer() end local tp = (not tp or tp==0) and p or 1-p return Duel.GetTurnPlayer()==tp end end --Location Group Check Conditions function Auxiliary.LocationGroupCond(f,loc1,loc2,min,max,exc) if not loc1 then loc1=LOCATION_ONFIELD end if not loc2 then loc2=loc1 end if not min then min=1 end return function(e,tp,eg,ep,ev,re,r,rp) if not tp then tp=e:GetHandlerPlayer() end local exc=(exc) and e:GetHandler() or nil local ct=Duel.GetMatchingGroupCount(f,tp,loc1,loc2,exc,e,tp,eg,ep,ev,re,r,rp) return ct>=min and (not max or ct<=max) end end function Auxiliary.ExactLocationGroupCond(f,loc1,loc2,ct0,exc) if not loc1 then loc1=LOCATION_ONFIELD end if not loc2 then loc2=loc1 end if not ct then ct=1 end return function(e,tp,eg,ep,ev,re,r,rp) if not tp then tp=e:GetHandlerPlayer() end local exc=(not exc) and nil or e:GetHandler() local ct=Duel.GetMatchingGroupCount(f,tp,loc1,loc2,exc,e,tp,eg,ep,ev,re,r,rp) return ct==ct0 end end function Auxiliary.CompareLocationGroupCond(res,f,loc,exc) if not f then f=aux.TRUE end if not loc then loc=LOCATION_MZONE end return function(e,tp,eg,ep,ev,re,r,rp) if not tp then tp=e:GetHandlerPlayer() end local res = (res and res==1) and 1-tp or tp local exc=(exc) and e:GetHandler() or nil local ct1=Duel.GetMatchingGroupCount(f,tp,loc,0,exc,e,tp,eg,ep,ev,re,r,rp) local ct2=Duel.GetMatchingGroupCount(f,tp,0,loc,exc,e,tp,eg,ep,ev,re,r,rp) local winner if ct1>ct2 then winner=tp elseif ct10 end --Link Related function Auxiliary.ThisCardPointsToCond(f,min) if not f then f=aux.TRUE end min=min and min or 1 return function(e) local tp=e:GetHandlerPlayer() return e:GetHandler():GetLinkedGroup():IsExists(f,min,nil,e,tp) end end