name: Mahaama
card_text: During your opponent's turn, when either player takes battle damage: You can Special Summon this card from your hand, then apply 1 of these effects.
  ● Gain LP equal to that battle damage.
  ● Inflict damage to your opponent equal to that battle damage.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetCondition(s.sumcon)
  	e1:SetTarget(s.sumtg)
  	e1:SetOperation(s.sumop)
  	c:RegisterEffect(e1)
  end
  function s.sumcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EFFECT)
  		local opt = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  		if opt == 0 then
  			Duel.Recover(tp, ev, REASON_EFFECT)
  		else
  			Duel.Damage(1 - tp, ev, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Mahaama
  During your opponent's turn, when either player takes battle damage: You can Special Summon this card from your hand, then apply 1 of these effects.
  ● Gain LP equal to that battle damage.
  ● Inflict damage to your opponent equal to that battle damage.
target_text: -- Mahaama
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetCondition(s.sumcon)
  	e1:SetTarget(s.sumtg)
  	e1:SetOperation(s.sumop)
  	c:RegisterEffect(e1)
  end
  function s.sumcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.sumtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EFFECT)
  		local opt = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  		if opt == 0 then
  			Duel.Recover(tp, ev, REASON_EFFECT)
  		else
  			Duel.Damage(1 - tp, ev, REASON_EFFECT)
  		end
  	end
  end
  
  