name: Kuribon
card_text: During damage calculation, if this card is attacked by your opponent's monster: You can activate this effect; you take no battle damage from that battle, your opponent gains LP equal to the attacking monster's ATK, also you return this card to the hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--be target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_RECOVER + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetCondition(s.con)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttackTarget() == e:GetHandler() and Duel.GetBattleDamage(tp) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local val = Duel.GetAttacker():GetAttack()
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, 1 - tp, val)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_DAMAGE)
  	Duel.RegisterEffect(e1, tp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  	Duel.SendtoHand(c, nil, REASON_EFFECT)
  end
  
  
source_text: Kuribon
  During damage calculation, if this card is attacked by your opponent's monster: You can activate this effect; you take no battle damage from that battle, your opponent gains LP equal to the attacking monster's ATK, also you return this card to the hand.
target_text: -- Kuribon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--be target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_RECOVER + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE)
  	e1:SetCondition(s.con)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttackTarget() == e:GetHandler() and Duel.GetBattleDamage(tp) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local val = Duel.GetAttacker():GetAttack()
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, 1 - tp, val)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_DAMAGE)
  	Duel.RegisterEffect(e1, tp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  	Duel.SendtoHand(c, nil, REASON_EFFECT)
  end
  
  