name: Hourglass
card_text: If this card is Normal or Flip Summoned, its original ATK and DEF are halved until the End Phase of your next turn. After that, the original ATK and DEF are doubled.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_BASE_ATTACK_FINAL)
  		e1:SetValue(s.atkval)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_SET_BASE_DEFENSE_FINAL)
  		e2:SetValue(s.defval)
  		c:RegisterEffect(e2)
  		if Duel.GetTurnPlayer() == tp then
  			c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 2)
  		else
  			c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 1)
  		end
  	end
  end
  function s.atkval(e, c)
  	if c:GetFlagEffect(id) == 0 then
  		return c:GetBaseAttack() * 2
  	else
  		return math.ceil(c:GetBaseAttack() / 2)
  	end
  end
  function s.defval(e, c)
  	if c:GetFlagEffect(id) == 0 then
  		return c:GetBaseDefense() * 2
  	else
  		return math.ceil(c:GetBaseDefense() / 2)
  	end
  end
  
  
source_text: Hourglass
  If this card is Normal or Flip Summoned, its original ATK and DEF are halved until the End Phase of your next turn. After that, the original ATK and DEF are doubled.
target_text: -- Hourglass
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DEFCHANGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_BASE_ATTACK_FINAL)
  		e1:SetValue(s.atkval)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_SET_BASE_DEFENSE_FINAL)
  		e2:SetValue(s.defval)
  		c:RegisterEffect(e2)
  		if Duel.GetTurnPlayer() == tp then
  			c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 2)
  		else
  			c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 1)
  		end
  	end
  end
  function s.atkval(e, c)
  	if c:GetFlagEffect(id) == 0 then
  		return c:GetBaseAttack() * 2
  	else
  		return math.ceil(c:GetBaseAttack() / 2)
  	end
  end
  function s.defval(e, c)
  	if c:GetFlagEffect(id) == 0 then
  		return c:GetBaseDefense() * 2
  	else
  		return math.ceil(c:GetBaseDefense() / 2)
  	end
  end
  
  