Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Auxiliary.IsPlayerCanSpecialSummonMonster #2535

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions c15590355.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ function s.initial_effect(c)
end
function s.cfilter(c,tp)
return c:IsSetCard(0x17c) and c:IsType(TYPE_MONSTER) and c:IsType(TYPE_RITUAL) and not c:IsPublic()
and Duel.IsPlayerCanSpecialSummonMonster(tp,id+o,0,TYPES_TOKEN_MONSTER,0,0,c:GetLevel(),RACE_CYBERSE,ATTRIBUTE_FIRE)
and aux.IsPlayerCanSpecialSummonMonster(tp,id+o,{level=c:GetLevel()})
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
e:SetLabel(100)
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND,0,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM)
local tc=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_HAND,0,1,1,nil,tp):GetFirst()
Expand All @@ -33,18 +32,14 @@ function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.ShuffleHand(tp)
end
function s.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local res=e:GetLabel()==100
e:SetLabel(0)
return res and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
end
if chk==0 then return e:IsCostChecked() and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0)
end
function s.op(e,tp,eg,ep,ev,re,r,rp)
local lv=e:GetLabel()
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,id+o,0,TYPES_TOKEN_MONSTER,0,0,lv,RACE_CYBERSE,ATTRIBUTE_FIRE) then
and aux.IsPlayerCanSpecialSummonMonster(tp,id+o,{level=lv}) then
local tk=Duel.CreateToken(tp,id+o)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
Expand Down
4 changes: 2 additions & 2 deletions c176392.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ function c176392.spcon(e,tp,eg,ep,ev,re,r,rp)
end
function c176392.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,176393,0x1d,TYPES_TOKEN_MONSTER,1800,1800,4,RACE_ROCK,ATTRIBUTE_EARTH) end
and aux.IsPlayerCanSpecialSummonMonster(tp,176393) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0)
end
function c176392.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
if not Duel.IsPlayerCanSpecialSummonMonster(tp,176393,0x1d,TYPES_TOKEN_MONSTER,1800,1800,4,RACE_ROCK,ATTRIBUTE_EARTH) then return end
if not aux.IsPlayerCanSpecialSummonMonster(tp,176393) then return end
local token=Duel.CreateToken(tp,176393)
Duel.SpecialSummon(token,0,tp,tp,false,false,POS_FACEUP)
end
7 changes: 4 additions & 3 deletions c23626223.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ function c23626223.initial_effect(c)
c:RegisterEffect(e3)
end
function c23626223.target(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return e:IsCostChecked()
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,23626223,0,TYPES_EFFECT_TRAP_MONSTER,0,2500,7,RACE_ROCK,ATTRIBUTE_EARTH) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
and aux.IsPlayerCanSpecialSummonMonster(tp,c,TYPES_EFFECT_TRAP_MONSTER) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function c23626223.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not Duel.IsPlayerCanSpecialSummonMonster(tp,23626223,0,TYPES_EFFECT_TRAP_MONSTER,0,2500,7,RACE_ROCK,ATTRIBUTE_EARTH) then return end
if not aux.IsPlayerCanSpecialSummonMonster(tp,c,TYPES_EFFECT_TRAP_MONSTER) then return end
c:AddMonsterAttribute(TYPE_EFFECT+TYPE_TRAP)
Duel.SpecialSummon(c,SUMMON_VALUE_SELF,tp,tp,true,false,POS_FACEUP)
end
Expand Down
4 changes: 2 additions & 2 deletions c9336190.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function c9336190.spcon(e,tp,eg,ep,ev,re,r,rp)
end
function c9336190.spfilter(c,e,tp)
return c:IsSetCard(0x10db) and c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.IsPlayerCanSpecialSummonMonster(tp,9336190,0x10db,TYPES_NORMAL_TRAP_MONSTER,0,0,c:GetLevel(),RACE_WARRIOR,ATTRIBUTE_DARK)
and aux.IsPlayerCanSpecialSummonMonster(tp,9336190,{type=TYPES_NORMAL_TRAP_MONSTER,level=c:GetLevel()})
end
function c9336190.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c9336190.spfilter(chkc,e,tp) end
Expand All @@ -62,7 +62,7 @@ function c9336190.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)>0
and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsRelateToEffect(e)
and Duel.IsPlayerCanSpecialSummonMonster(tp,9336190,0x10db,TYPES_NORMAL_TRAP_MONSTER,0,0,tc:GetLevel(),RACE_WARRIOR,ATTRIBUTE_DARK) then
and aux.IsPlayerCanSpecialSummonMonster(tp,9336190,{type=TYPES_NORMAL_TRAP_MONSTER,level=tc:GetLevel()}) then
c:AddMonsterAttribute(TYPE_NORMAL,0,0,tc:GetLevel(),0,0)
Duel.SpecialSummonStep(c,0,tp,tp,true,false,POS_FACEUP)
local e1=Effect.CreateEffect(c)
Expand Down
36 changes: 36 additions & 0 deletions utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1598,3 +1598,39 @@ end
function Auxiliary.BanishRedirectCondition(e)
return e:GetHandler():IsFaceup()
end
---Wrap of Duel.IsPlayerCanSpecialSummonMonster with more clear parameters
---@param tp integer
---@param v integer|Card
---@param data? integer|{ setcode:integer, type:integer, atk:integer, def:integer, level:integer, race:integer, attribute:integer, position:integer, target_player:integer, sumtype:integer }
function Auxiliary.IsPlayerCanSpecialSummonMonster(tp,v,data)
local id
if Auxiliary.GetValueType(v)=="Card" then id=v:GetCode() end
if Auxiliary.GetValueType(v)=="number" then id=v end
if data==nil then
return Duel.IsPlayerCanSpecialSummonMonster(tp,id)
end
if data==TYPES_NORMAL_TRAP_MONSTER or data==TYPES_EFFECT_TRAP_MONSTER then
return Duel.IsPlayerCanSpecialSummonMonster(tp,id,nil,data)
end
local setcode=nil
if data.setcode then setcode=data.setcode end
local type=nil
if data.type then type=data.type end
local atk=nil
if data.atk then atk=data.atk end
local def=nil
if data.def then def=data.def end
local level=nil
if data.level then level=data.level end
local race=nil
if data.race then race=data.race end
local attribute=nil
if data.attribute then attribute=data.attribute end
local position=POS_FACEUP
if data.position then pos=data.position end
local target_player=tp
if data.target_player then target_player=data.target_player end
local sumtype=0
if data.sumtype then sumtype=data.sumtype end
return Duel.IsPlayerCanSpecialSummonMonster(tp,id,setcode,type,atk,def,level,race,attribute,position,target_player,sumtype)
end