name: Superheavy
card_text: Pendulum Scale = 1
  [ Pendulum Effect ]
  You cannot Pendulum Summon monsters, except "Superheavy Samurai" monsters. This effect cannot be negated. Once per turn: You can target 1 "Superheavy Samurai" monster you control; increase its Level by 1 (even if this card leaves the field).
  ----------------------------------------
  [ Monster Effect ]
  You can Tribute Summon this card by Tributing 1 "Superheavy Samurai" monster. When this card is Normal or Special Summoned: You can change its battle position. This card can attack while in face-up Defense Position. If it does, apply its DEF for damage calculation.
external_ids: local SETCARD_ID_0 = 0x9a --Superheavy
  
lua: local SETCARD_ID_0 = 0x9a --Superheavy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetTargetRange(1, 0)
  	e2:SetCondition(s.splimcon)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  	--level
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_PZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.lvtg)
  	e3:SetOperation(s.lvop)
  	c:RegisterEffect(e3)
  	--pos
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_POSITION)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e4:SetTarget(s.postg)
  	e4:SetOperation(s.posop)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e5)
  	--normal summon with 1 tribute
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_SUMMON_PROC)
  	e6:SetCondition(s.otcon)
  	e6:SetOperation(s.otop)
  	e6:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e7)
  	--
  	local e8 = Effect.CreateEffect(c)
  	e8:SetType(EFFECT_TYPE_SINGLE)
  	e8:SetCode(EFFECT_DEFENSE_ATTACK)
  	e8:SetValue(1)
  	c:RegisterEffect(e8)
  end
  function s.splimcon(e)
  	return not e:GetHandler():IsForbidden()
  end
  function s.splimit(e, c, tp, sumtp, sumpos)
  	return not c:IsSetCard(SETCARD_ID_0) and bit.band(sumtp, SUMMON_TYPE_PENDULUM) == SUMMON_TYPE_PENDULUM
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0
  end
  function s.lvtg(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_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, e:GetHandler(), 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK)
  	end
  end
  function s.otfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.otcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local mg = Duel.GetMatchingGroup(s.otfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, tp)
  	return c:IsLevelAbove(7) and minc <= 1 and Duel.CheckTribute(c, 1, 1, mg)
  end
  function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
  	local mg = Duel.GetMatchingGroup(s.otfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, tp)
  	local sg = Duel.SelectTribute(tp, c, 1, 1, mg)
  	c:SetMaterial(sg)
  	Duel.Release(sg, REASON_SUMMON + REASON_MATERIAL)
  end
  
  
source_text: Superheavy
  Pendulum Scale = 1
  [ Pendulum Effect ]
  You cannot Pendulum Summon monsters, except "Superheavy Samurai" monsters. This effect cannot be negated. Once per turn: You can target 1 "Superheavy Samurai" monster you control; increase its Level by 1 (even if this card leaves the field).
  ----------------------------------------
  [ Monster Effect ]
  You can Tribute Summon this card by Tributing 1 "Superheavy Samurai" monster. When this card is Normal or Special Summoned: You can change its battle position. This card can attack while in face-up Defense Position. If it does, apply its DEF for damage calculation.
target_text: -- Superheavy
  local SETCARD_ID_0 = 0x9a --Superheavy
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetTargetRange(1, 0)
  	e2:SetCondition(s.splimcon)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  	--level
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_PZONE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.lvtg)
  	e3:SetOperation(s.lvop)
  	c:RegisterEffect(e3)
  	--pos
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_POSITION)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e4:SetTarget(s.postg)
  	e4:SetOperation(s.posop)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e5)
  	--normal summon with 1 tribute
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_SUMMON_PROC)
  	e6:SetCondition(s.otcon)
  	e6:SetOperation(s.otop)
  	e6:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e7)
  	--
  	local e8 = Effect.CreateEffect(c)
  	e8:SetType(EFFECT_TYPE_SINGLE)
  	e8:SetCode(EFFECT_DEFENSE_ATTACK)
  	e8:SetValue(1)
  	c:RegisterEffect(e8)
  end
  function s.splimcon(e)
  	return not e:GetHandler():IsForbidden()
  end
  function s.splimit(e, c, tp, sumtp, sumpos)
  	return not c:IsSetCard(SETCARD_ID_0) and bit.band(sumtp, SUMMON_TYPE_PENDULUM) == SUMMON_TYPE_PENDULUM
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0
  end
  function s.lvtg(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_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_LEVEL)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, e:GetHandler(), 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK)
  	end
  end
  function s.otfilter(c, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsControler(tp) or c:IsFaceup())
  end
  function s.otcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local mg = Duel.GetMatchingGroup(s.otfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, tp)
  	return c:IsLevelAbove(7) and minc <= 1 and Duel.CheckTribute(c, 1, 1, mg)
  end
  function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
  	local mg = Duel.GetMatchingGroup(s.otfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, tp)
  	local sg = Duel.SelectTribute(tp, c, 1, 1, mg)
  	c:SetMaterial(sg)
  	Duel.Release(sg, REASON_SUMMON + REASON_MATERIAL)
  end
  
  