name: Penalty
card_text: When your opponent has 4 cards in their hand: Activate 1 of these effects.
  ● Your opponent cannot draw during their next Draw Phase.
  ● Your opponent cannot activate Spell/Trap Cards this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetHintTiming(0, TIMING_TOHAND)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) == 4
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	e:SetLabel(op)
  	Duel.SetTargetPlayer(1 - tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if e:GetLabel() == 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetCode(EFFECT_CANNOT_DRAW)
  		if Duel.GetTurnPlayer() == p and Duel.GetCurrentPhase() == PHASE_DRAW then
  			e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN, 2)
  			e1:SetLabel(Duel.GetTurnCount())
  		else
  			e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN)
  			e1:SetLabel(0)
  		end
  		e1:SetCondition(s.skipcon)
  		Duel.RegisterEffect(e1, p)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_DRAW_COUNT)
  		e2:SetValue(0)
  		Duel.RegisterEffect(e2, p)
  	else
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  		e1:SetTargetRange(1, 0)
  		e1:SetValue(s.aclimit)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, p)
  	end
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel() and Duel.GetCurrentPhase() == PHASE_DRAW
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE)
  end
  
  
source_text: Penalty
  When your opponent has 4 cards in their hand: Activate 1 of these effects.
  ● Your opponent cannot draw during their next Draw Phase.
  ● Your opponent cannot activate Spell/Trap Cards this turn.
target_text: -- Penalty
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetHintTiming(0, TIMING_TOHAND)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) == 4
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	e:SetLabel(op)
  	Duel.SetTargetPlayer(1 - tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	if e:GetLabel() == 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetCode(EFFECT_CANNOT_DRAW)
  		if Duel.GetTurnPlayer() == p and Duel.GetCurrentPhase() == PHASE_DRAW then
  			e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN, 2)
  			e1:SetLabel(Duel.GetTurnCount())
  		else
  			e1:SetReset(RESET_PHASE + PHASE_DRAW + RESET_SELF_TURN)
  			e1:SetLabel(0)
  		end
  		e1:SetCondition(s.skipcon)
  		Duel.RegisterEffect(e1, p)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_DRAW_COUNT)
  		e2:SetValue(0)
  		Duel.RegisterEffect(e2, p)
  	else
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  		e1:SetTargetRange(1, 0)
  		e1:SetValue(s.aclimit)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, p)
  	end
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel() and Duel.GetCurrentPhase() == PHASE_DRAW
  end
  function s.aclimit(e, re, tp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE)
  end
  
  