diff --git a/parts/modes/drought_l.lua b/parts/modes/drought_l.lua index 0ecd1950..adff9e2d 100644 --- a/parts/modes/drought_l.lua +++ b/parts/modes/drought_l.lua @@ -1,4 +1,4 @@ -local min=math.min +local ins=table.insert return{ color=COLOR.red, env={ @@ -26,69 +26,52 @@ return{ end height[11]=999 - local res={1,1,2,2,3,4} + local wei={1,1,2,2,3,4} local d=0 - local A for i=1,10 do d=d+height[i] end - if d<40 or P.stat.row>2*42 then - A=#res+1 + if d<40 or P.stat.row>2*42 then--Low field or almost win, give SZO for _=1,4 do - res[A]=1 - res[A+1]=2 - res[A+2]=6 - A=A+3 + ins(wei,1) + ins(wei,2) + ins(wei,6) end - goto END - end - - --Give I when no hole - d=-999--Height difference - --A=hole mark - for x=2,11 do - local _=height[x]-height[x-1] - if d<-2 and _>2 then - A=true + else + --Give I when no hole + local tempDeltaHei=-999--Height difference + for x=2,11 do + local deltaHei=height[x]-height[x-1] + if tempDeltaHei<-2 and deltaHei>2 then + break + elseif x==11 then + for _=1,3 do ins(wei,7)end + else + tempDeltaHei=deltaHei + end end - d=_ - end - if not A then - A=#res+1 - res[A]=7 - res[A+1]=7 - res[A+2]=7 - end - --Give O when no d=0/give T when no d=1 - d=0--d=0 count - A=0--d=1 count - for x=2,10 do - local _=height[x]-height[x-1] - if _==0 then - d=d+1 - elseif _==1 or _==-1 then - A=A+1 + --Give O when no d=0/give T when no d=1 + local flatCount=0--d=0 count + local stairCount=0--d=1 count + for x=2,10 do + local _=height[x]-height[x-1] + if _==0 then + flatCount=flatCount+1 + elseif _==1 or _==-1 then + stairCount=stairCount+1 + end + end + if flatCount<3 then + for _=1,3 do ins(wei,6)end + end + if stairCount<3 then + for _=1,4 do ins(wei,5)end end end - if d<3 then - A=#res+1 - res[A]=6 - res[A+1]=6 - res[A+2]=6 - end - if A<3 then - A=#res+1 - res[A]=5 - res[A+1]=5 - res[A+2]=5 - res[A+3]=5 - res[A+4]=5 - end - ::END:: FREEROW.discard(height) - P:getNext(res[P:RND(#res)]) + P:getNext(wei[P:RND(#wei)]) end end end, @@ -107,7 +90,7 @@ return{ local R=100-P.stat.row mStr(R>=0 and R or 0,69,265) end, - score=function(P)return{min(P.stat.row,100),P.stat.time}end, + score=function(P)return{math.min(P.stat.row,100),P.stat.time}end, scoreDisp=function(D)return D[1].." Lines "..TIMESTR(D[2])end, comp=function(a,b)return a[1]>b[1]or a[1]==b[1]and a[2]0 and(ifpre or P.waiting==-1)then @@ -638,44 +642,34 @@ function Player.hold(P,ifpre) end if ENV.phyHold and C and not ifpre then--Physical hold - local success local x,y=P.curX,P.curY x=x+(#C.bk[1]-#H.bk[1])*.5 y=y+(#C.bk-#H.bk)*.5 + local iki=phyHoldKickX[x==int(x)] for Y=int(y),ceil(y+.5)do - local X=x - while true do - X=int(X) + for i=1,#iki do + local X=x+iki[i] if not P:ifoverlap(H.bk,X,Y)then x,y=X,Y - success=true - goto BREAK - end - if X==x then - X=X-1 - elseif X All test failed, interrupt with sound SFX.play("finesseError") - return - end + do return end + -- + + ::BREAK_success:: + P.spinLast=false + P.spinSeq=0 + local hb=P:getBlock(C.id) + hb.name=C.name + hb.color=C.color + ins(P.holdQueue,hb) + P.cur=rem(P.holdQueue,1) + P.curX,P.curY=x,y else--Normal hold P.spinLast=false P.spinSeq=0 diff --git a/parts/scenes/app_2048.lua b/parts/scenes/app_2048.lua index dd5109da..0e092320 100644 --- a/parts/scenes/app_2048.lua +++ b/parts/scenes/app_2048.lua @@ -125,37 +125,38 @@ local function freshMaxTile() end local function squash(L) local p1,p2=1 - local moved - while p1<4 do + local moved=false + while true do p2=p1+1 while not L[p2]do p2=p2+1 if p2==5 then p1=p1+1 - goto continue + if p1==4 then + return L[1],L[2],L[3],L[4],moved + end + break end end if not L[p1]then--air←2 - L[p1]=L[p2] + L[p1],L[p2]=L[p2],false moved=true elseif L[p1]==L[p2]then--2←2 - L[p1]=L[p1]+1 + L[p1],L[p2]=L[p1]+1,false if L[p1]>maxTile then freshMaxTile() end - moved=true + L[p2]=false p1=p1+1 + moved=true elseif p1+1~=p2 then--2←4 - L[p1+1]=L[p2] - moved=true + L[p1+1],L[p2]=L[p2],false p1=p1+1 + moved=true else--2,4 p1=p1+1 end - if moved then L[p2]=false end - ::continue:: end - return L[1],L[2],L[3],L[4],moved end local function reset() for i=1,16 do board[i]=false end