name: Gambler
card_text: Once per turn, you can toss a coin 3 times and apply the appropriate effect:
  ● 3 Heads: Destroy all monsters your opponent controls.
  ● 2 Heads: Discard 1 random card from your opponent's hand.
  ● 1 Head: Destroy 1 card you control.
  ● 3 Tails: Discard your entire hand.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_HANDES + CATEGORY_COIN)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 3)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c1, c2, c3 = Duel.TossCoin(tp, 3)
  	if c1 + c2 + c3 == 3 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif c1 + c2 + c3 == 2 then
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 1)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	elseif c1 + c2 + c3 == 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.SelectMatchingCard(tp, aux.TRUE, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	else
  		local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  
  
source_text: Gambler
  Once per turn, you can toss a coin 3 times and apply the appropriate effect:
  ● 3 Heads: Destroy all monsters your opponent controls.
  ● 2 Heads: Discard 1 random card from your opponent's hand.
  ● 1 Head: Destroy 1 card you control.
  ● 3 Tails: Discard your entire hand.
target_text: -- Gambler
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_HANDES + CATEGORY_COIN)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COIN, nil, 0, tp, 3)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c1, c2, c3 = Duel.TossCoin(tp, 3)
  	if c1 + c2 + c3 == 3 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif c1 + c2 + c3 == 2 then
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 1)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	elseif c1 + c2 + c3 == 1 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local g = Duel.SelectMatchingCard(tp, aux.TRUE, tp, LOCATION_ONFIELD, 0, 1, 1, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	else
  		local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	end
  end
  
  