name: Gunkan
card_text: 2 Level 4 monsters
  If this card is Xyz Summoned: You can apply these effects, in sequence, based on the materials used. You can only use this effect of "Gunkan Suship Ikura-class Dreadnought" once per turn.
  ● "Gunkan Suship Shari": Draw 1 card.
  ● "Gunkan Suship Ikura": This card can make a second attack during each Battle Phase.
  Once per turn, when your "Gunkan" monster Special Summoned from the Extra Deck inflicts battle damage to your opponent: You can target 1 card your opponent controls; destroy it.
external_ids: local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 61027400 --Gunkan Suship Ikura
  local SETCARD_ID_0 = 0x166 --Gunkan
  
lua: local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 61027400 --Gunkan Suship Ikura
  local SETCARD_ID_0 = 0x166 --Gunkan
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_1)
  	--xyz procedure
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--apply the effect
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.valcheck)
  	c:RegisterEffect(e0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.effcon)
  	e1:SetTarget(s.efftg)
  	e1:SetOperation(s.effop)
  	c:RegisterEffect(e1)
  	e0:SetLabelObject(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.valcheck(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local flag = 0
  	if c:GetMaterial():FilterCount(Card.IsCode, nil, CARD_ID_0) > 0 then
  		flag = flag | 1
  	end
  	if c:GetMaterial():FilterCount(Card.IsCode, nil, CARD_ID_1) > 0 then
  		flag = flag | 2
  	end
  	e:GetLabelObject():SetLabel(flag)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.efftg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local chk1 = e:GetLabel() & 1 > 0
  	local chk2 = e:GetLabel() & 2 > 0
  	if chk == 0 then
  		return (chk1 and Duel.IsPlayerCanDraw(tp, 1) or chk2)
  	end
  	if chk1 then
  		e:SetCategory(CATEGORY_DRAW)
  		Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  	else
  		e:SetCategory(0)
  	end
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local chk1 = e:GetLabel() & 1 > 0
  	local chk2 = e:GetLabel() & 2 > 0
  	if chk1 then
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  	if chk2 then
  		Duel.BreakEffect()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EXTRA_ATTACK)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local rc = eg:GetFirst()
  	return ep ~= tp and rc:IsControler(tp) and rc:IsSetCard(SETCARD_ID_0) and rc:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Gunkan
  2 Level 4 monsters
  If this card is Xyz Summoned: You can apply these effects, in sequence, based on the materials used. You can only use this effect of "Gunkan Suship Ikura-class Dreadnought" once per turn.
  ● "Gunkan Suship Shari": Draw 1 card.
  ● "Gunkan Suship Ikura": This card can make a second attack during each Battle Phase.
  Once per turn, when your "Gunkan" monster Special Summoned from the Extra Deck inflicts battle damage to your opponent: You can target 1 card your opponent controls; destroy it.
target_text: -- Gunkan
  local CARD_ID_0 = 24639891 --Gunkan Suship Shari
  local CARD_ID_1 = 61027400 --Gunkan Suship Ikura
  local SETCARD_ID_0 = 0x166 --Gunkan
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_1)
  	--xyz procedure
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--apply the effect
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.valcheck)
  	c:RegisterEffect(e0)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.effcon)
  	e1:SetTarget(s.efftg)
  	e1:SetOperation(s.effop)
  	c:RegisterEffect(e1)
  	e0:SetLabelObject(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_BATTLE_DAMAGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  end
  function s.valcheck(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local flag = 0
  	if c:GetMaterial():FilterCount(Card.IsCode, nil, CARD_ID_0) > 0 then
  		flag = flag | 1
  	end
  	if c:GetMaterial():FilterCount(Card.IsCode, nil, CARD_ID_1) > 0 then
  		flag = flag | 2
  	end
  	e:GetLabelObject():SetLabel(flag)
  end
  function s.effcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.efftg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local chk1 = e:GetLabel() & 1 > 0
  	local chk2 = e:GetLabel() & 2 > 0
  	if chk == 0 then
  		return (chk1 and Duel.IsPlayerCanDraw(tp, 1) or chk2)
  	end
  	if chk1 then
  		e:SetCategory(CATEGORY_DRAW)
  		Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  	else
  		e:SetCategory(0)
  	end
  end
  function s.effop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local chk1 = e:GetLabel() & 1 > 0
  	local chk2 = e:GetLabel() & 2 > 0
  	if chk1 then
  		Duel.Draw(tp, 1, REASON_EFFECT)
  	end
  	if chk2 then
  		Duel.BreakEffect()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EXTRA_ATTACK)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1)
  	end
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local rc = eg:GetFirst()
  	return ep ~= tp and rc:IsControler(tp) and rc:IsSetCard(SETCARD_ID_0) and rc:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsOnField()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  