name: Binary
card_text: 2 monsters, except Tokens
  Gains these effects based on the number of monsters co-linked to this card.
  ● 1+: When a monster co-linked to this card battles your opponent's monster and inflicts battle damage to them: You can gain that much LP.
  ● 2: Once per turn (Quick Effect): You can target 2 face-up monsters you control; until the end of this turn, halve the ATK of 1 monster, and if you do, add that lost ATK to the other monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.matfilter, 2, 2)
  	c:EnableReviveLimit()
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCategory(CATEGORY_RECOVER)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.reccon)
  	e1:SetTarget(s.rectg)
  	e1:SetOperation(s.recop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.matfilter(c)
  	return not c:IsLinkType(TYPE_TOKEN)
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	local lg = e:GetHandler():GetMutualLinkedGroup()
  	local tc = eg:GetFirst()
  	return ep ~= tp and lg:IsContains(tc) and tc:GetBattleTarget() ~= nil
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(ev)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ev)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return aux.dscon(e, tp, eg, ep, ev, re, r, rp) and e:GetHandler():GetMutualLinkedGroupCount() >= 2
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 2, 2, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc1 = g:GetFirst()
  	local tc2 = g:GetNext()
  	if tc1:IsFaceup() and tc1:IsRelateToEffect(e) and tc2:IsFaceup() and tc2:IsRelateToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local sg = g:Select(tp, 1, 1, nil)
  		local atk = sg:GetFirst():GetAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(math.ceil(atk / 2))
  		if sg:GetFirst():RegisterEffect(e1) then
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetCode(EFFECT_UPDATE_ATTACK)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e2:SetValue(math.ceil(atk / 2))
  			if sg:GetFirst() == tc1 then
  				tc2:RegisterEffect(e2)
  			else
  				tc1:RegisterEffect(e2)
  			end
  		end
  	end
  end
  
  
source_text: Binary
  2 monsters, except Tokens
  Gains these effects based on the number of monsters co-linked to this card.
  ● 1+: When a monster co-linked to this card battles your opponent's monster and inflicts battle damage to them: You can gain that much LP.
  ● 2: Once per turn (Quick Effect): You can target 2 face-up monsters you control; until the end of this turn, halve the ATK of 1 monster, and if you do, add that lost ATK to the other monster.
target_text: -- Binary
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.matfilter, 2, 2)
  	c:EnableReviveLimit()
  	--recover
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCategory(CATEGORY_RECOVER)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.reccon)
  	e1:SetTarget(s.rectg)
  	e1:SetOperation(s.recop)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.atkcon)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.matfilter(c)
  	return not c:IsLinkType(TYPE_TOKEN)
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	local lg = e:GetHandler():GetMutualLinkedGroup()
  	local tc = eg:GetFirst()
  	return ep ~= tp and lg:IsContains(tc) and tc:GetBattleTarget() ~= nil
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(ev)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, ev)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return aux.dscon(e, tp, eg, ep, ev, re, r, rp) and e:GetHandler():GetMutualLinkedGroupCount() >= 2
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, 0, 2, 2, nil)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc1 = g:GetFirst()
  	local tc2 = g:GetNext()
  	if tc1:IsFaceup() and tc1:IsRelateToEffect(e) and tc2:IsFaceup() and tc2:IsRelateToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  		local sg = g:Select(tp, 1, 1, nil)
  		local atk = sg:GetFirst():GetAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		e1:SetValue(math.ceil(atk / 2))
  		if sg:GetFirst():RegisterEffect(e1) then
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e2:SetCode(EFFECT_UPDATE_ATTACK)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e2:SetValue(math.ceil(atk / 2))
  			if sg:GetFirst() == tc1 then
  				tc2:RegisterEffect(e2)
  			else
  				tc1:RegisterEffect(e2)
  			end
  		end
  	end
  end
  
  