Commit 46387862 authored by Vury Leo's avatar Vury Leo

Add タツネクロ

parent 9b44ce56
--タツネクロ
function c3096468.initial_effect(c)
local s,id,o=GetID()
function s.initial_effect(c)
--synchro custom
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SYNCHRO_MATERIAL_CUSTOM)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCondition(c3096468.syncon)
e1:SetTarget(c3096468.syntg)
e1:SetCondition(s.syncon)
e1:SetTarget(s.syntg)
e1:SetValue(1)
e1:SetOperation(c3096468.synop)
e1:SetOperation(s.synop)
c:RegisterEffect(e1)
--splimit
local e2=Effect.CreateEffect(c)
......@@ -17,39 +18,47 @@ function c3096468.initial_effect(c)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e2:SetTargetRange(1,0)
e2:SetTarget(c3096468.splimit)
e2:SetTarget(s.splimit)
c:RegisterEffect(e2)
--hand synchro
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SPSUM_PARAM)
e3:SetCondition(c3096468.syncon)
e3:SetCondition(s.syncon)
e3:SetCode(EFFECT_HAND_SYNCHRO)
e3:SetTargetRange(0,1)
c:RegisterEffect(e3)
--hand synchro
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e4:SetRange(LOCATION_MZONE)
e4:SetCondition(s.syncon)
e4:SetCode(id)
c:RegisterEffect(e4)
end
function c3096468.synfilter(c,syncard,tuner,f)
function s.synfilter(c,syncard,tuner,f)
return c:IsFaceupEx() and c:IsCanBeSynchroMaterial(syncard,tuner) and (f==nil or f(c,syncard))
end
function c3096468.syncheck(c,g,mg,tp,lv,syncard,minc,maxc)
function s.syncheck(c,g,mg,tp,lv,syncard,minc,maxc)
g:AddCard(c)
local ct=g:GetCount()
local res=c3096468.syngoal(g,tp,lv,syncard,minc,ct)
or (ct<maxc and mg:IsExists(c3096468.syncheck,1,g,g,mg,tp,lv,syncard,minc,maxc))
local res=s.syngoal(g,tp,lv,syncard,minc,ct)
or (ct<maxc and mg:IsExists(s.syncheck,1,g,g,mg,tp,lv,syncard,minc,maxc))
g:RemoveCard(c)
return res
end
function c3096468.syngoal(g,tp,lv,syncard,minc,ct)
function s.syngoal(g,tp,lv,syncard,minc,ct)
return ct>=minc
and g:CheckWithSumEqual(Card.GetSynchroLevel,lv,ct,ct,syncard)
and Duel.GetLocationCountFromEx(tp,tp,g,syncard)>0
and g:FilterCount(Card.IsLocation,nil,LOCATION_HAND)<=1
and aux.MustMaterialCheck(g,tp,EFFECT_MUST_BE_SMATERIAL)
end
function c3096468.syncon(e)
function s.syncon(e)
return e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
end
function c3096468.syntg(e,syncard,f,min,max)
function s.syntg(e,syncard,f,min,max)
local minc=min+1
local maxc=max+1
local c=e:GetHandler()
......@@ -57,25 +66,25 @@ function c3096468.syntg(e,syncard,f,min,max)
local lv=syncard:GetLevel()
if lv<=c:GetLevel() then return false end
local g=Group.FromCards(c)
local mg=Duel.GetSynchroMaterial(tp):Filter(c3096468.synfilter,c,syncard,c,f)
local exg=Duel.GetMatchingGroup(c3096468.synfilter,tp,LOCATION_HAND,0,c,syncard,c,f)
local mg=Duel.GetSynchroMaterial(tp):Filter(s.synfilter,c,syncard,c,f)
local exg=Duel.GetMatchingGroup(s.synfilter,tp,LOCATION_HAND,0,c,syncard,c,f)
mg:Merge(exg)
return mg:IsExists(c3096468.syncheck,1,g,g,mg,tp,lv,syncard,minc,maxc)
return mg:IsExists(s.syncheck,1,g,g,mg,tp,lv,syncard,minc,maxc)
end
function c3096468.synop(e,tp,eg,ep,ev,re,r,rp,syncard,f,min,max)
function s.synop(e,tp,eg,ep,ev,re,r,rp,syncard,f,min,max)
local minc=min+1
local maxc=max+1
local c=e:GetHandler()
local lv=syncard:GetLevel()
local g=Group.FromCards(c)
local mg=Duel.GetSynchroMaterial(tp):Filter(c3096468.synfilter,c,syncard,c,f)
local exg=Duel.GetMatchingGroup(c3096468.synfilter,tp,LOCATION_HAND,0,c,syncard,c,f)
local mg=Duel.GetSynchroMaterial(tp):Filter(s.synfilter,c,syncard,c,f)
local exg=Duel.GetMatchingGroup(s.synfilter,tp,LOCATION_HAND,0,c,syncard,c,f)
mg:Merge(exg)
for i=1,maxc do
local cg=mg:Filter(c3096468.syncheck,g,g,mg,tp,lv,syncard,minc,maxc)
local cg=mg:Filter(s.syncheck,g,g,mg,tp,lv,syncard,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c3096468.syngoal(g,tp,lv,syncard,minc,i) then
if s.syngoal(g,tp,lv,syncard,minc,i) then
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
......@@ -96,6 +105,6 @@ function c3096468.synop(e,tp,eg,ep,ev,re,r,rp,syncard,f,min,max)
end
Duel.SetSynchroMaterial(g)
end
function c3096468.splimit(e,c)
function s.splimit(e,c)
return not c:IsRace(RACE_ZOMBIE)
end
......@@ -3598,7 +3598,6 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_race,tuner_f
--- include branch
if can_include then
Debug.Message(string.format("can include %d true",mc:GetCode()))
for _,diff in ipairs(Synchro.GenerateVariantForCard(
state,mc,#selected+1,tc,tuner_race,prune_tuner_filter,non_tuner_race,prune_non_tuner_filter
)) do
......@@ -3616,23 +3615,18 @@ function Synchro.CanCompleteSelection(candidates,target_level,tuner_race,tuner_f
selected,index+1,branch_state,prune_indexes
) then
table.remove(selected)
Debug.Message(string.format("include %d true",mc:GetCode()))
return true
end
table.remove(selected)
end
else
Debug.Message(string.format("can include %d false",mc:GetCode()))
end
-- exclude branch
if Synchro.CanCompleteSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,base_mapper,scheck,selected,index+1,state,prune_indexes) then
Debug.Message(string.format("exclude %d true",mc:GetCode()))
return true
end
Debug.Message(string.format("final %d false",mc:GetCode()))
return false
end
......@@ -3648,12 +3642,9 @@ function Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_f
local old_scheck=scheck
--- @param g Group
scheck=aux.AND(function(g)
Debug.Message(string.format("scheck for %d %d",#g,g:GetFirst():GetCode()))
if not g:IsExists(function(mc) return mc:IsType(TYPE_TUNER) and mc:IsSetCard(0x2) end,1,nil) then
Debug.Message(string.format("scheck false"))
return false
end
Debug.Message(string.format("scheck true"))
return true
end,
old_scheck)
......@@ -3837,7 +3828,45 @@ function Synchro.SynOperation()
return function(e,tp,eg,ep,ev,re,r,rp,c)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
-- confirm hand hard
local hand_cards=g:Filter(function(c) return c:IsLocation(LOCATION_HAND) end,nil)
Duel.ConfirmCards(1-tp,hand_cards)
-- Detect whether Tatsunecro’s effect was actually used:
-- (a) Tatsunecro itself was used as material, AND
-- (b) At least one hand card was included.
local used_tatsunecro_effect=g:IsExists(function(card) return Synchro.IsTatsunecro(card) end,1,nil)
and g:IsExists(function(card) return card:IsLocation(LOCATION_HAND) end,1,nil)
-- Detect which effect-bearing monster(s) were used as material:
-- Tatsunecro ⇒ banish clause; Tatsunoko ⇒ normal GY clause
local has_tatsunecro=g:IsExists(function(card) return Synchro.IsTatsunecro(card) end,1,nil)
local has_tatsunoko=g:IsExists(function(card) return Synchro.IsTatsunoko(card) end,1,nil)
if used_tatsunecro_effect then
if has_tatsunecro and not has_tatsunoko then
-- Only Tatsunecro applies: banish all materials
Duel.Remove(g, POS_FACEUP, REASON_MATERIAL+REASON_SYNCHRO)
elseif has_tatsunoko and not has_tatsunecro then
-- Only Tatsunoko applies: send all materials to the GY
Duel.SendtoGrave(g, REASON_MATERIAL+REASON_SYNCHRO)
else
-- Both apply: prompt the player to choose
local opts={
1005, -- banish
1004, -- grave
}
local choice=Duel.SelectOption(tp,table.unpack(opts))
if choice==0 then
Duel.Hint(HINT_CARD,0,3096468)
Duel.Remove(g,POS_FACEUP,REASON_MATERIAL+REASON_SYNCHRO)
else
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
end
end
else
-- Tatsunecro’s banish clause not used: always send to the GY
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
end
g:DeleteGroup()
end
end
......@@ -4017,6 +4046,11 @@ function Synchro.IsTatsunoko(c)
return c:IsHasEffect(55863245)~=nil
end
--- @param c Card
function Synchro.IsTatsunecro(c)
return c:IsHasEffect(3096468)~=nil
end
--- @param c Card
function Synchro.IsGenomix(c)
return c:IsHasEffect(42155488)~=nil
......@@ -4036,6 +4070,9 @@ function Synchro.SortMaterials(materials,tc,tuner_filter)
if Synchro.IsTatsunoko(a)~=Synchro.IsTatsunoko(b) then
return Synchro.IsTatsunoko(a) -- then tatsunoko
end
if Synchro.IsTatsunecro(a)~=Synchro.IsTatsunecro(b) then
return Synchro.IsTatsunecro(a) -- then tatsunecro
end
if tuner_filter(a,tc)~=tuner_filter(b,tc) then
return tuner_filter(a,tc) -- then tuner
end
......@@ -4049,7 +4086,7 @@ function Synchro.IsLevelAlter(c)
end
function Synchro.IsHandAlter(c)
return Synchro.IsTatsunoko(c)
return Synchro.IsTatsunoko(c) or Synchro.IsTatsunecro(c)
end
function Synchro.IsRaceAlter(c)
......@@ -4061,7 +4098,7 @@ function Synchro.IsMandatory(c)
end
function Synchro.IsNoHarm(c)
return Synchro.IsTatsunoko(c)
return Synchro.IsTatsunoko(c) or Synchro.IsTatsunecro(c)
end
-- Helper to generate only the variant-specific diffs for a card
......@@ -4117,6 +4154,13 @@ function Synchro.GenerateVariantForCard(st,card,selected_count,tc,tuner_race,tun
})
end
-- Tatsunecro effect
if Synchro.IsTatsunecro(card) then
table.insert(base_variants,{
hand_count_limit=1,
})
end
-- now wrap each base_variant in role‐specific diffs
local variants={}
local can_be_tuner=tuner_filter(card,tc)
......@@ -4245,7 +4289,7 @@ function Synchro.CanIncludeMaterial(mc,state,selected,tc,
-- hand‐location count limit
if mc:IsLocation(LOCATION_HAND)
and index>prune_indexes.hand_prune_index
and state.hand_count>state.hand_count_limit then
and state.hand_count+1>state.hand_count_limit then
return false,nil
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment