Secret grade mode improvements (#726)
* Fix crash when getting TM+6 and above * Add line counter to secret grade
This commit is contained in:
@@ -1,18 +1,58 @@
|
||||
local gc_setColor,gc_draw=love.graphics.setColor,love.graphics.draw
|
||||
local ply_applyField=PLY.draw.applyField
|
||||
local function GetOpenHole(num)
|
||||
local function getOpenHole(num)
|
||||
return -math.abs(((num-1) % 18)-9)+10
|
||||
end
|
||||
local F={}
|
||||
local ranks={"10","9","8","7","6","5","4","3","2","1","S1","S2","S3","S4","S5","S6","S7","S8","S9","GM","GM+","TM","TM+","TM+₂","TM+₃", "TM+₄","TM+₅"}
|
||||
-- lines: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
||||
|
||||
-- local ranks={"10","9","8","7","6","5","4","3","2","1","S1","S2","S3","S4","S5","S6","S7","S8","S9","GM","GM+","TM","TM+","TM+₂","TM+₃", "TM+₄","TM+₅"}
|
||||
-- lines: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
||||
|
||||
local function getSmallNum(num)
|
||||
local smalldigit={[0]="₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"}
|
||||
local str=tostring(num)
|
||||
local out=""
|
||||
for i=1,#str do
|
||||
out=out..smalldigit[tonumber(string.sub(str,i,i))]
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function getRank(index)
|
||||
if index<11 then -- rank 10 - 1
|
||||
return tostring(11-index)
|
||||
elseif index<20 then -- S1 - S9 ranks
|
||||
return "S"..index-10
|
||||
elseif index<24 then -- GM, GM+, TM, TM+ ranks
|
||||
local r={"GM","GM+","TM","TM+"}
|
||||
return r[index-19]
|
||||
else
|
||||
return "TM+"..getSmallNum(index-22)
|
||||
end
|
||||
end
|
||||
|
||||
local function generateGuide(num)
|
||||
local l=#F
|
||||
if l>num then
|
||||
return
|
||||
end
|
||||
for i=l,num do
|
||||
F[i] = {}
|
||||
local h=getOpenHole(i)
|
||||
for j=1,10 do
|
||||
F[i][j]=h==j and -1 or 21
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return{
|
||||
fkey1=function(P)P.modeData.showGuide=not P.modeData.showGuide end,
|
||||
mesDisp=function(P)
|
||||
mText(TEXTOBJ.grade,63,190)
|
||||
mText(TEXTOBJ.line,63,310)
|
||||
setFont(55)
|
||||
mStr(ranks[P.modeData.rankPts],63,125)
|
||||
|
||||
mStr(getRank(P.modeData.rankPts),63,125)
|
||||
mStr(P.modeData.rankPts-1,63,245)
|
||||
ply_applyField(P)
|
||||
local mark=TEXTURE.puzzleMark
|
||||
gc_setColor(1,1,1)
|
||||
@@ -29,26 +69,22 @@ return{
|
||||
task=function(P)
|
||||
P.modeData.rankPts=1
|
||||
P.modeData.showGuide=true
|
||||
for i=1,50 do
|
||||
F[i] = {}
|
||||
local h=GetOpenHole(i)
|
||||
for j=1,10 do
|
||||
F[i][j]=h==j and -1 or 21
|
||||
end
|
||||
end
|
||||
generateGuide(10)
|
||||
end,
|
||||
hook_drop=function(P)
|
||||
local D=P.modeData
|
||||
D.rankPts=1
|
||||
for i=1,#P.field do
|
||||
local h=GetOpenHole(i)
|
||||
local h=getOpenHole(i)
|
||||
for j=1,10 do
|
||||
if P.field[i][j]>0 and h==j then return end
|
||||
if P.field[i][j]==0 and h~=j then return end
|
||||
if P.field[i][j]>0 and h==j then goto post_pts_calc end
|
||||
if P.field[i][j]==0 and h~=j then goto post_pts_calc end
|
||||
end
|
||||
if i==#P.field then return end
|
||||
if P.field[i+1][h]==0 then return end
|
||||
if i==#P.field then goto post_pts_calc end
|
||||
if P.field[i+1][h]==0 then goto post_pts_calc end
|
||||
D.rankPts=D.rankPts+1
|
||||
end
|
||||
::post_pts_calc::
|
||||
generateGuide(D.rankPts+20)
|
||||
end
|
||||
}
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
local ranks={"Grade 10","Grade 9","Grade 8","Grade 7","Grade 6","Grade 5","Grade 4","Grade 3","Grade 2","Grade 1","S1","S2","S3","S4","S5","S6","S7","S8","S9","GM","GM+","TM","TM+","TM+₂","TM+₃", "TM+₄","TM+₅"}
|
||||
-- index: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
||||
local function getSmallNum(num)
|
||||
local smalldigit={[0]="₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"}
|
||||
local str=tostring(num)
|
||||
local out=""
|
||||
for i=1,#str do
|
||||
out=out..smalldigit[tonumber(string.sub(str,i,i))]
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function getRank(index)
|
||||
if index<11 then -- rank 10 - 1
|
||||
return "Grade "..tostring(11-index)
|
||||
elseif index<20 then -- S1 - S9 ranks
|
||||
return "S"..index-10
|
||||
elseif index<24 then -- GM, GM+, TM, TM+ ranks
|
||||
local r={"GM","GM+","TM","TM+"}
|
||||
return r[index-19]
|
||||
else
|
||||
return "TM+"..getSmallNum(index-22)
|
||||
end
|
||||
end
|
||||
|
||||
return{
|
||||
env={
|
||||
drop=180,lock=180,
|
||||
@@ -8,7 +29,7 @@ return{
|
||||
bg='bg2',bgm='race',
|
||||
},
|
||||
score=function(P)return{P.modeData.rankPts,P.stat.piece}end,
|
||||
scoreDisp=function(D)return ranks[D[1]].." "..D[2].." Pieces"end,
|
||||
scoreDisp=function(D)return getRank(D[1]).." "..D[2].." Pieces"end,
|
||||
comp=function(a,b)return a[1]>b[1]or a[1]==b[1]and a[2]<b[2]end,
|
||||
getRank=function(P)
|
||||
local G=P.modeData.rankPts
|
||||
|
||||
Reference in New Issue
Block a user