name: Kaiser
card_text: If you control no monsters, you can Special Summon this card (from your hand). If this card destroys an opponent's monster by battle: This card gains 500 ATK. If this card is destroyed by battle: The monster that destroyed it loses 500 ATK.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon proc
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetCondition(aux.bdocon)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	--atkdown
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	if not tc:IsRelateToBattle() or tc:IsFacedown() then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(-500)
  	tc:RegisterEffect(e1)
  end
  
  
source_text: Kaiser
  If you control no monsters, you can Special Summon this card (from your hand). If this card destroys an opponent's monster by battle: This card gains 500 ATK. If this card is destroyed by battle: The monster that destroyed it loses 500 ATK.
target_text: -- Kaiser
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon proc
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetCondition(aux.bdocon)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  	--atkdown
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_ATKCHANGE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetFieldGroupCount(c:GetControler(), LOCATION_MZONE, 0) == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(500)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetBattleTarget()
  	if not tc:IsRelateToBattle() or tc:IsFacedown() then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	e1:SetValue(-500)
  	tc:RegisterEffect(e1)
  end
  
  