Commit 9a9c738e authored by Chen Bill's avatar Chen Bill Committed by GitHub

fix GP-Nブラスター (#2596)

* update Auxiliary.GetColumn

* Auxiliary: add GetGlobalRow, GetGlobalColumn

* add Auxiliary.GetAdjacentGroup

* fix GP-Nブラスター
parent 2a6ce774
...@@ -61,9 +61,12 @@ end ...@@ -61,9 +61,12 @@ end
function s.desop(e,tp,eg,ep,ev,re,r,rp) function s.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) then if tc:IsRelateToEffect(e) and tc:IsType(TYPE_MONSTER) then
local cg=Duel.GetMatchingGroup(s.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,tc,1-tc:GetControler(),tc:GetSequence()) local row,column=aux.GetFieldIndex(tc)
if Duel.Destroy(tc,REASON_EFFECT)~=0 and Duel.GetLP(tp)<Duel.GetLP(1-tp) and #cg>0 if Duel.Destroy(tc,REASON_EFFECT)==0 or row<0 or column<0 then
and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then return
end
local cg=aux.GetAdjacentGroup(tp,LOCATION_ONFIELD,LOCATION_ONFIELD,row,column)
if Duel.GetLP(tp)<Duel.GetLP(1-tp) and #cg>0 and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then
Duel.BreakEffect() Duel.BreakEffect()
Duel.Destroy(cg,REASON_EFFECT) Duel.Destroy(cg,REASON_EFFECT)
end end
......
...@@ -3,6 +3,7 @@ aux=Auxiliary ...@@ -3,6 +3,7 @@ aux=Auxiliary
POS_FACEUP_DEFENCE=POS_FACEUP_DEFENSE POS_FACEUP_DEFENCE=POS_FACEUP_DEFENSE
POS_FACEDOWN_DEFENCE=POS_FACEDOWN_DEFENSE POS_FACEDOWN_DEFENCE=POS_FACEDOWN_DEFENSE
RACE_CYBERS=RACE_CYBERSE RACE_CYBERS=RACE_CYBERSE
NULL_VALUE=-10
function GetID() function GetID()
local offset=self_code<100000000 and 1 or 100 local offset=self_code<100000000 and 1 or 100
...@@ -548,38 +549,130 @@ end ...@@ -548,38 +549,130 @@ end
function Auxiliary.IsInGroup(c,g) function Auxiliary.IsInGroup(c,g)
return g:IsContains(c) return g:IsContains(c)
end end
--return the column of card c (from the viewpoint of p) --Get the row index (from the viewpoint of controller)
function Auxiliary.GetColumn(c,p) function Auxiliary.GetLocalRow(location,sequence)
local seq=c:GetSequence() if location==LOCATION_SZONE then
if c:IsLocation(LOCATION_MZONE) then if 0<=sequence and sequence<=4 then
if seq==5 then return 0
seq=1 else
elseif seq==6 then return NULL_VALUE
seq=3
end end
elseif c:IsLocation(LOCATION_SZONE) then elseif location==LOCATION_MZONE then
if seq>4 then if 0<=sequence and sequence<=4 then
return nil return 1
elseif 5<=sequence and sequence<=6 then
return 2
else
return NULL_VALUE
end end
else else
return nil return NULL_VALUE
end
end
--Get the global row index (from the viewpoint of 0)
function Auxiliary.GetGlobalRow(p,location,sequence)
local row=Auxiliary.GetLocalRow(location,sequence)
if row<0 then
return NULL_VALUE
end
if p==0 then
return row
else
return 4-row
end
end
--Get the column index (from the viewpoint of controller)
function Auxiliary.GetLocalColumn(location,sequence)
if location==LOCATION_SZONE then
if 0<=sequence and sequence<=4 then
return sequence
else
return NULL_VALUE
end
elseif location==LOCATION_MZONE then
if 0<=sequence and sequence<=4 then
return sequence
elseif sequence==5 then
return 1
elseif sequence==6 then
return 3
else
return NULL_VALUE
end
else
return NULL_VALUE
end
end
--Get the global column index (from the viewpoint of 0)
function Auxiliary.GetGlobalColumn(p,location,sequence)
local column=Auxiliary.GetLocalColumn(location,sequence)
if column<0 then
return NULL_VALUE
end
if p==0 then
return column
else
return 4-column
end
end
---Get the global row and column index of c
---@param c Card
---@return integer
---@return integer
function Auxiliary.GetFieldIndex(c)
local cp=c:GetControler()
local loc=c:GetLocation()
local seq=c:GetSequence()
return Auxiliary.GetGlobalRow(cp,loc,seq),Auxiliary.GetGlobalColumn(cp,loc,seq)
end
---Check if c is adjacent to (i,j)
---@param c Card
---@param i integer
---@param j integer
---@return boolean
function Auxiliary.AdjacentFilter(c,i,j)
local row,column=Auxiliary.GetFieldIndex(c)
if row<0 or column<0 then
return false
end
return (row==i and math.abs(column-j)==1) or (math.abs(row-i)==1 and column==j)
end
---Get the card group adjacent to (i,j)
---@param tp integer
---@param location1 integer
---@param location2 integer
---@param i integer
---@param j integer
---@return Group
function Auxiliary.GetAdjacentGroup(tp,location1,location2,i,j)
return Duel.GetMatchingGroup(Auxiliary.AdjacentFilter,tp,location1,location2,nil,i,j)
end
---Get the column index of card c (from the viewpoint of p)
---@param c Card
---@param p? integer default: 0
---@return integer
function Auxiliary.GetColumn(c,p)
p=p or 0
local cp=c:GetControler()
local loc=c:GetLocation()
local seq=c:GetSequence()
local column=Auxiliary.GetGlobalColumn(cp,loc,seq)
if column<0 then
return NULL_VALUE
end end
if c:IsControler(p or 0) then if p==0 then
return seq return column
else else
return 4-seq return 4-column
end end
end end
--return the column of monster zone seq (from the viewpoint of controller) --return the column of monster zone seq (from the viewpoint of controller)
function Auxiliary.MZoneSequence(seq) function Auxiliary.MZoneSequence(seq)
if seq==5 then return 1 end return Auxiliary.GetLocalColumn(LOCATION_MZONE,seq)
if seq==6 then return 3 end
return seq
end end
--return the column of spell/trap zone seq (from the viewpoint of controller) --return the column of spell/trap zone seq (from the viewpoint of controller)
function Auxiliary.SZoneSequence(seq) function Auxiliary.SZoneSequence(seq)
if seq>4 then return nil end return Auxiliary.GetLocalColumn(LOCATION_SZONE,seq)
return seq
end end
--generate the value function of EFFECT_CHANGE_BATTLE_DAMAGE on monsters --generate the value function of EFFECT_CHANGE_BATTLE_DAMAGE on monsters
function Auxiliary.ChangeBattleDamage(player,value) function Auxiliary.ChangeBattleDamage(player,value)
......
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