name: Five
card_text: When this card is activated: Gain 500 LP for each Continuous Spell/Trap Card you control. If this face-up card you control is sent to your Graveyard by your opponent's card effect: Inflict 500 damage to your opponent for each Continuous Spell/Trap Card in your Graveyard.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_RECOVER)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	local rec = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_ONFIELD, 0, nil) * 500
  	Duel.SetTargetParam(rec)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, rec)
  end
  function s.filter(c)
  	return c:IsType(TYPE_CONTINUOUS) and c:IsFaceup()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rec = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_ONFIELD, 0, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Recover(p, rec, REASON_EFFECT)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) and c:IsReason(REASON_EFFECT) and c:GetReasonPlayer() == 1 - tp and c:IsPreviousControler(tp)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	local dam = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_GRAVE, 0, nil) * 500
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local dam = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_GRAVE, 0, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Damage(p, dam, REASON_EFFECT)
  end
  
  
source_text: Five
  When this card is activated: Gain 500 LP for each Continuous Spell/Trap Card you control. If this face-up card you control is sent to your Graveyard by your opponent's card effect: Inflict 500 damage to your opponent for each Continuous Spell/Trap Card in your Graveyard.
target_text: -- Five
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_RECOVER)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	local rec = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_ONFIELD, 0, nil) * 500
  	Duel.SetTargetParam(rec)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, rec)
  end
  function s.filter(c)
  	return c:IsType(TYPE_CONTINUOUS) and c:IsFaceup()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rec = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_ONFIELD, 0, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Recover(p, rec, REASON_EFFECT)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) and c:IsReason(REASON_EFFECT) and c:GetReasonPlayer() == 1 - tp and c:IsPreviousControler(tp)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	local dam = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_GRAVE, 0, nil) * 500
  	Duel.SetTargetParam(dam)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local dam = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_GRAVE, 0, nil) * 500
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Damage(p, dam, REASON_EFFECT)
  end
  
  