name: Iron
card_text: Loses 1000 ATK while you control "Iron Hans". If this card on the field is destroyed by battle or sent to the GY by a card effect: You can add 1 "Iron Hans" from your Deck to your hand, or, if "Golden Castle of Stromberg" is in a Field Zone, you can add 1 Warrior monster from your Deck to your hand, instead. You can only use this effect of "Iron Knight" once per turn.
external_ids: local CARD_ID_0 = 41916534 --Iron Hans
  local CARD_ID_1 = 72283691 --Golden Castle of Stromberg
  
lua: local CARD_ID_0 = 41916534 --Iron Hans
  local CARD_ID_1 = 72283691 --Golden Castle of Stromberg
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--atk down
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetCondition(s.atkcon)
  	e1:SetValue(-1000)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_BATTLE_DESTROYED)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetCondition(s.thcon)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.atkcon(e)
  	return Duel.IsExistingMatchingCard(s.filter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.thfilter(c)
  	return (c:IsCode(CARD_ID_0) or (Duel.IsEnvironment(CARD_ID_1, PLAYER_ALL, LOCATION_FZONE) and c:IsRace(RACE_WARRIOR))) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Iron
  Loses 1000 ATK while you control "Iron Hans". If this card on the field is destroyed by battle or sent to the GY by a card effect: You can add 1 "Iron Hans" from your Deck to your hand, or, if "Golden Castle of Stromberg" is in a Field Zone, you can add 1 Warrior monster from your Deck to your hand, instead. You can only use this effect of "Iron Knight" once per turn.
target_text: -- Iron
  local CARD_ID_0 = 41916534 --Iron Hans
  local CARD_ID_1 = 72283691 --Golden Castle of Stromberg
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1)
  	--atk down
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetCondition(s.atkcon)
  	e1:SetValue(-1000)
  	c:RegisterEffect(e1)
  	--search
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_BATTLE_DESTROYED)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetCondition(s.thcon)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.atkcon(e)
  	return Duel.IsExistingMatchingCard(s.filter, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.thfilter(c)
  	return (c:IsCode(CARD_ID_0) or (Duel.IsEnvironment(CARD_ID_1, PLAYER_ALL, LOCATION_FZONE) and c:IsRace(RACE_WARRIOR))) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  