代码优化,卡块spin判定无须最后一步旋转

This commit is contained in:
MrZ626
2020-09-12 12:15:28 +08:00
parent d89a2f60a9
commit 731e6bfaca

View File

@@ -2003,6 +2003,7 @@ do--player.drop(P)--Place piece
local cmb=P.combo local cmb=P.combo
P.waiting=P.gameEnv.wait P.waiting=P.gameEnv.wait
local STAT=P.stat local STAT=P.stat
local CB,CX,CY=P.cur,P.curX,P.curY
local clear--If (perfect)clear local clear--If (perfect)clear
local cc,gbcc=0,0--Row/garbage-row cleared,full-part local cc,gbcc=0,0--Row/garbage-row cleared,full-part
local atk,exblock=0,0--Attack & extra defense local atk,exblock=0,0--Attack & extra defense
@@ -2011,12 +2012,10 @@ do--player.drop(P)--Place piece
local dospin=0 local dospin=0
local mini local mini
--Spin check --Tri-corner spin check
if P.spinLast then if P.spinLast then
if CB.id<6 then
--Tri-corner local x,y=CX+P.sc[2],CY+P.sc[1]
if P.cur.id<6 then
local x,y=P.curX+P.sc[2],P.curY+P.sc[1]
local c=0 local c=0
if P:solid(x-1,y+1)then c=c+1 end if P:solid(x-1,y+1)then c=c+1 end
if P:solid(x+1,y+1)then c=c+1 end if P:solid(x+1,y+1)then c=c+1 end
@@ -2026,11 +2025,10 @@ do--player.drop(P)--Place piece
if c>2 then dospin=dospin+1 end if c>2 then dospin=dospin+1 end
end end
::NTC:: ::NTC::
end
--Immovable --Immovable spin check
if P:ifoverlap(P.cur.bk,P.curX-1,P.curY)and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)and P:ifoverlap(P.cur.bk,P.curX,P.curY+1)then if P:ifoverlap(CB.bk,CX,CY+1)and P:ifoverlap(CB.bk,CX-1,CY)and P:ifoverlap(CB.bk,CX+1,CY)then
dospin=dospin+2 dospin=dospin+2
end
end end
--Lock block to field --Lock block to field
@@ -2041,7 +2039,7 @@ do--player.drop(P)--Place piece
--Check rows to be cleared --Check rows to be cleared
for i=0,P.r-1 do for i=0,P.r-1 do
local h=P.curY+i local h=CY+i
if P:ckfull(h)then if P:ckfull(h)then
cc=cc+1 cc=cc+1
P.clearingRow[cc]=h-cc+1 P.clearingRow[cc]=h-cc+1
@@ -2077,7 +2075,7 @@ do--player.drop(P)--Place piece
if dospin>0 then if dospin>0 then
dospin=dospin+P.spinLast dospin=dospin+P.spinLast
if dospin<2 then if dospin<2 then
mini=P.cur.id<6 and cc<3 and cc<P.r mini=CB.id<6 and cc<3 and cc<P.r
end end
else else
dospin=false dospin=false
@@ -2093,12 +2091,12 @@ do--player.drop(P)--Place piece
--Finesse: roof check --Finesse: roof check
local finesse local finesse
if P.cur.id>7 then if CB.id>7 then
finesse=true finesse=true
elseif P.curY<=18 then elseif CY<=18 then
local y0=P.curY local y0=CY
local x,c=P.curX,P.c local x,c=CX,P.c
local B=P.cur.bk local B=CB.bk
for x=1,c do for x=1,c do
local y local y
for i=#B,1,-1 do for i=#B,1,-1 do
@@ -2110,7 +2108,7 @@ do--player.drop(P)--Place piece
goto L2 goto L2
::L1:: ::L1::
if y then if y then
x=P.curX+x-1 x=CX+x-1
for y=y0+y,#P.field do for y=y0+y,#P.field do
--Roof=finesse --Roof=finesse
if P:solid(x,y)then if P:solid(x,y)then
@@ -2153,8 +2151,8 @@ do--player.drop(P)--Place piece
--Finesse check (control) --Finesse check (control)
if not finesse then if not finesse then
if dospin then P.ctrlCount=P.ctrlCount-2 end--Allow 2 more step for roof-less spin if dospin then P.ctrlCount=P.ctrlCount-2 end--Allow 2 more step for roof-less spin
local id=P.cur.id local id=CB.id
local d=P.ctrlCount-finesseList[id][P.dir+1][P.curX] local d=P.ctrlCount-finesseList[id][P.dir+1][CX]
if d>=2 then if d>=2 then
P:finesseError(2) P:finesseError(2)
elseif d>0 then elseif d>0 then
@@ -2165,9 +2163,9 @@ do--player.drop(P)--Place piece
if cc>0 then if cc>0 then
cmb=cmb+1 cmb=cmb+1
if dospin then if dospin then
cscore=(spinSCR[P.cur.name]or spinSCR[8])[cc] cscore=(spinSCR[CB.name]or spinSCR[8])[cc]
if P.b2b>1000 then if P.b2b>1000 then
P:showText(text.b3b..text.block[P.cur.name]..text.spin.." "..text.clear[cc],0,-30,35,"stretch") P:showText(text.b3b..text.block[CB.name]..text.spin.." "..text.clear[cc],0,-30,35,"stretch")
atk=b2bATK[cc]+cc*.5 atk=b2bATK[cc]+cc*.5
exblock=exblock+1 exblock=exblock+1
cscore=cscore*2 cscore=cscore*2
@@ -2176,7 +2174,7 @@ do--player.drop(P)--Place piece
VOC.play("b3b",CHN) VOC.play("b3b",CHN)
end end
elseif P.b2b>=50 then elseif P.b2b>=50 then
P:showText(text.b2b..text.block[P.cur.name]..text.spin.." "..text.clear[cc],0,-30,35,"spin") P:showText(text.b2b..text.block[CB.name]..text.spin.." "..text.clear[cc],0,-30,35,"spin")
atk=b2bATK[cc] atk=b2bATK[cc]
cscore=cscore*1.2 cscore=cscore*1.2
STAT.b2b=STAT.b2b+1 STAT.b2b=STAT.b2b+1
@@ -2184,7 +2182,7 @@ do--player.drop(P)--Place piece
VOC.play("b2b",CHN) VOC.play("b2b",CHN)
end end
else else
P:showText(text.block[P.cur.name]..text.spin.." "..text.clear[cc],0,-30,45,"spin") P:showText(text.block[CB.name]..text.spin.." "..text.clear[cc],0,-30,45,"spin")
atk=2*cc atk=2*cc
end end
sendTime=20+atk*20 sendTime=20+atk*20
@@ -2200,10 +2198,10 @@ do--player.drop(P)--Place piece
else else
P.b2b=P.b2b+b2bPoint[cc] P.b2b=P.b2b+b2bPoint[cc]
end end
P.lastClear=P.cur.id*10+cc P.lastClear=CB.id*10+cc
if P.human then if P.human then
SFX.play(spin_n[cc]) SFX.play(spin_n[cc])
VOC.play(spinName[P.cur.name],CHN) VOC.play(spinName[CB.name],CHN)
end end
elseif cc>=4 then elseif cc>=4 then
cscore=cc==4 and 1000 or 1500 cscore=cc==4 and 1000 or 1500
@@ -2232,7 +2230,7 @@ do--player.drop(P)--Place piece
atk=cc atk=cc
end end
P.b2b=P.b2b+cc*80-220 P.b2b=P.b2b+cc*80-220
P.lastClear=P.cur.name*10+cc P.lastClear=CB.name*10+cc
end end
if P.human then if P.human then
VOC.play(clearName[cc],CHN) VOC.play(clearName[cc],CHN)
@@ -2268,7 +2266,7 @@ do--player.drop(P)--Place piece
else else
goto checkB2Breduce goto checkB2Breduce
end end
P.lastClear=P.cur.name*10+5 P.lastClear=CB.name*10+5
goto skipB2Breduce goto skipB2Breduce
end end
@@ -2325,7 +2323,7 @@ do--player.drop(P)--Place piece
local M=#P.atker local M=#P.atker
if M>0 then if M>0 then
for i=1,M do for i=1,M do
P:attack(P.atker[i],send,sendTime,M,P.cur.color,P.lastClear,dospin,cmb) P:attack(P.atker[i],send,sendTime,M,CB.color,P.lastClear,dospin,cmb)
end end
else else
T=randomTarget(P) T=randomTarget(P)
@@ -2338,7 +2336,7 @@ do--player.drop(P)--Place piece
T=randomTarget(P) T=randomTarget(P)
end end
if T then if T then
P:attack(T,send,sendTime,1,P.cur.color,P.lastClear,dospin,cmb) P:attack(T,send,sendTime,1,CB.color,P.lastClear,dospin,cmb)
end end
end end
if P.human and send>3 then SFX.play("emit",min(send,7)*.1)end if P.human and send>3 then SFX.play("emit",min(send,7)*.1)end
@@ -2357,11 +2355,11 @@ do--player.drop(P)--Place piece
--Spin bonus --Spin bonus
if dospin then if dospin then
P:showText(text.block[P.cur.name]..text.spin,0,-30,45,"appear") P:showText(text.block[CB.name]..text.spin,0,-30,45,"appear")
P.b2b=P.b2b+20 P.b2b=P.b2b+20
if P.human then if P.human then
SFX.play("spin_0") SFX.play("spin_0")
VOC.play(spinName[P.cur.name],CHN) VOC.play(spinName[CB.name],CHN)
end end
dropScore=25 dropScore=25
end end
@@ -2408,7 +2406,7 @@ do--player.drop(P)--Place piece
end end
--Update stat --Update stat
local n=P.cur.name local n=CB.name
if dospin then if dospin then
_=STAT.spin[n] _[cc+1]=_[cc+1]+1--Spin[1~25][0~4] _=STAT.spin[n] _[cc+1]=_[cc+1]+1--Spin[1~25][0~4]
_=STAT.spins _[cc+1]=_[cc+1]+1--Spin[0~4] _=STAT.spins _[cc+1]=_[cc+1]+1--Spin[0~4]