Decode
Target 1 "Decode Talker" you control; apply the following effects this turn, depending on the number of monsters it currently points to.
● 1+: That monster gains 500 ATK for each monster it currently points to.
● 2+: Monsters destroyed by battle with that monster are banished after damage calculation.
● 3: After damage calculation, if that monster destroys your opponent's monster by battle: Destroy all cards your opponent controls.
You can only activate 1 "Decode Destruction" per turn.
local CARD_ID_0 = 1861629 --Decode Talker

local CARD_ID_0 = 1861629 --Decode Talker
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.filter(c)
	return c:IsFaceup() and c:IsCode(CARD_ID_0) and c:GetLinkedGroupCount() > 0
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local tc = Duel.GetFirstTarget()
	if not (tc:IsFaceup() and tc:IsRelateToEffect(e)) then
		return
	end
	local ct = tc:GetLinkedGroupCount()
	if ct >= 1 then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		e1:SetValue(ct * 500)
		tc:RegisterEffect(e1)
	end
	if ct >= 2 then
		local e2 = Effect.CreateEffect(c)
		e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
		e2:SetCode(EVENT_BATTLED)
		e2:SetOwnerPlayer(tp)
		e2:SetCondition(s.rmcon)
		e2:SetOperation(s.rmop)
		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		tc:RegisterEffect(e2, true)
	end
	if ct == 3 then
		tc:RegisterFlagEffect(id, RESET_EVENT + 0x1220000 + RESET_PHASE + PHASE_END, 0, 1)
		local e3 = Effect.CreateEffect(c)
		e3:SetDescription(aux.Stringid(id, 1))
		e3:SetCategory(CATEGORY_DESTROY)
		e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
		e3:SetCode(EVENT_BATTLED)
		e3:SetLabelObject(tc)
		e3:SetCondition(s.descon)
		e3:SetTarget(s.destg)
		e3:SetOperation(s.desop)
		e3:SetReset(RESET_PHASE + PHASE_END)
		Duel.RegisterEffect(e3, tp)
	end
end
function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetHandler():GetBattleTarget()
	return tp == e:GetOwnerPlayer() and tc and tc:IsStatus(STATUS_BATTLE_DESTROYED)
end
function s.rmop(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetHandler():GetBattleTarget()
	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
end
function s.descon(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetLabelObject()
	local bc = tc:GetBattleTarget()
	return tc:GetFlagEffect(id) ~= 0 and bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and tc:IsStatus(STATUS_OPPO_BATTLE)
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	local sg = Duel.GetMatchingGroup(nil, tp, 0, LOCATION_ONFIELD, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, sg, sg:GetCount(), 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local sg = Duel.GetMatchingGroup(nil, tp, 0, LOCATION_ONFIELD, nil)
	Duel.Destroy(sg, REASON_EFFECT)
end


Decode
Target 1 "Decode Talker" you control; apply the following effects this turn, depending on the number of monsters it currently points to.
● 1+: That monster gains 500 ATK for each monster it currently points to.
● 2+: Monsters destroyed by battle with that monster are banished after damage calculation.
● 3: After damage calculation, if that monster destroys your opponent's monster by battle: Destroy all cards your opponent controls.
You can only activate 1 "Decode Destruction" per turn.
-- Decode
local CARD_ID_0 = 1861629 --Decode Talker
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.filter(c)
	return c:IsFaceup() and c:IsCode(CARD_ID_0) and c:GetLinkedGroupCount() > 0
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local tc = Duel.GetFirstTarget()
	if not (tc:IsFaceup() and tc:IsRelateToEffect(e)) then
		return
	end
	local ct = tc:GetLinkedGroupCount()
	if ct >= 1 then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		e1:SetValue(ct * 500)
		tc:RegisterEffect(e1)
	end
	if ct >= 2 then
		local e2 = Effect.CreateEffect(c)
		e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
		e2:SetCode(EVENT_BATTLED)
		e2:SetOwnerPlayer(tp)
		e2:SetCondition(s.rmcon)
		e2:SetOperation(s.rmop)
		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		tc:RegisterEffect(e2, true)
	end
	if ct == 3 then
		tc:RegisterFlagEffect(id, RESET_EVENT + 0x1220000 + RESET_PHASE + PHASE_END, 0, 1)
		local e3 = Effect.CreateEffect(c)
		e3:SetDescription(aux.Stringid(id, 1))
		e3:SetCategory(CATEGORY_DESTROY)
		e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
		e3:SetCode(EVENT_BATTLED)
		e3:SetLabelObject(tc)
		e3:SetCondition(s.descon)
		e3:SetTarget(s.destg)
		e3:SetOperation(s.desop)
		e3:SetReset(RESET_PHASE + PHASE_END)
		Duel.RegisterEffect(e3, tp)
	end
end
function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetHandler():GetBattleTarget()
	return tp == e:GetOwnerPlayer() and tc and tc:IsStatus(STATUS_BATTLE_DESTROYED)
end
function s.rmop(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetHandler():GetBattleTarget()
	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
end
function s.descon(e, tp, eg, ep, ev, re, r, rp)
	local tc = e:GetLabelObject()
	local bc = tc:GetBattleTarget()
	return tc:GetFlagEffect(id) ~= 0 and bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) and tc:IsStatus(STATUS_OPPO_BATTLE)
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	local sg = Duel.GetMatchingGroup(nil, tp, 0, LOCATION_ONFIELD, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, sg, sg:GetCount(), 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local sg = Duel.GetMatchingGroup(nil, tp, 0, LOCATION_ONFIELD, nil)
	Duel.Destroy(sg, REASON_EFFECT)
end

