name: Coach
card_text: 3 Level 8 monsters
  You can detach 1 material from this card; draw 1 card and reveal it, then if it was a monster, inflict 800 damage to your opponent. You cannot conduct your Battle Phase the turn you activate this effect. You can only use this effect of "Coach King Giantrainer" up to thrice per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 8, 3)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_DAMAGE)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(3, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCurrentPhase() == PHASE_MAIN1 and e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.Draw(tp, 1, REASON_EFFECT)
  	if ct == 0 then
  		return
  	end
  	local dc = Duel.GetOperatedGroup():GetFirst()
  	Duel.ConfirmCards(1 - tp, dc)
  	if dc:IsType(TYPE_MONSTER) then
  		Duel.BreakEffect()
  		Duel.Damage(1 - tp, 800, REASON_EFFECT)
  	end
  	Duel.ShuffleHand(tp)
  end
  
  
source_text: Coach
  3 Level 8 monsters
  You can detach 1 material from this card; draw 1 card and reveal it, then if it was a monster, inflict 800 damage to your opponent. You cannot conduct your Battle Phase the turn you activate this effect. You can only use this effect of "Coach King Giantrainer" up to thrice per turn.
target_text: -- Coach
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 8, 3)
  	c:EnableReviveLimit()
  	--draw
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW + CATEGORY_DAMAGE)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(3, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCurrentPhase() == PHASE_MAIN1 and e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.Draw(tp, 1, REASON_EFFECT)
  	if ct == 0 then
  		return
  	end
  	local dc = Duel.GetOperatedGroup():GetFirst()
  	Duel.ConfirmCards(1 - tp, dc)
  	if dc:IsType(TYPE_MONSTER) then
  		Duel.BreakEffect()
  		Duel.Damage(1 - tp, 800, REASON_EFFECT)
  	end
  	Duel.ShuffleHand(tp)
  end
  
  