Skip to content

Commit

Permalink
教程第六关草稿
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Oct 6, 2024
1 parent 987bf6a commit 2b0374a
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 13 deletions.
141 changes: 132 additions & 9 deletions assets/game/mechanicLib/brik/allclearGenerator.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---@type Map<Techmino.Event.Brik>
local allclearGenerator={}

local pieceShapes do
Expand Down Expand Up @@ -195,7 +194,9 @@ function allclearGenerator._shuffleSeq(P,seq,holdSlot)
end
end
end
function allclearGenerator._getQuestion(P,args)
---@return Mat<boolean> field, Techmino.Brik.Name[] seq
function allclearGenerator._generateQuestion(P,args)
---@cast P Techmino.Player.Brik
local field={} -- 0-1 matrix
local seq={} -- briks' names
local failCount=0
Expand Down Expand Up @@ -283,20 +284,142 @@ function allclearGenerator._getQuestion(P,args)
printSeq(seq)
end

return field,seq
end

function allclearGenerator.newQuestion(P,args)
local field,seq=allclearGenerator._getQuestion(P,args)
TABLE.reverse(field)
TABLE.reverse(seq)

for y=1,#field do
for x=1,#field[y] do
field[y][x]=field[y][x] and 8 or 0
end
end
P:setField(field)
P:pushNext(seq)

return field,seq
end

---@return Mat<number> field, Techmino.Brik.Name[] seq
function allclearGenerator._getLibQuestion(P,args)
---@cast P Techmino.Player.Brik
local field={} -- 0-1 matrix
local seq={} -- briks' names

local pool=require'assets.game.mechanicLib.brik.allclearQuestLib'
local basePool=pool.base[args.lib]
local seqPool=pool.sequence[args.lib]

local args1={
debugging=false,
holdUsed=false,
startPiece=false,
avoidRepeat=true,
}
if type(args)=='table' then TABLE.update(args1,args) end

local debugging= args1.debugging
local holdUsed= TABLE.getFirstValue(args1.holdUsed,P and P.settings.holdSlot)
local startPiece= args1.startPiece

-- Initialize
if not P.modeData.allclearBaseID then
P.modeData.allclearBaseID={}
P.modeData.allclearSeqHis={}
for lib in next,pool.base do
P.modeData.allclearBaseID[lib]=1
P.modeData.allclearSeqHis[lib]={}
end
end

local baseID=P.modeData.allclearBaseID[args.lib]
local seqHis=P.modeData.allclearSeqHis[args.lib]

field=basePool[baseID]
local attempts=0
local r
while true do
r=P:random(#seqPool)
attempts=attempts+1
if attempts>26 then break end
if not args1.avoidRepeat then break end
if not TABLE.find(seqHis,r) then
table.insert(seqHis,1,r)
seqHis[11]=nil
break
end
end
seq=seqPool[r]

field=TABLE.copy(field)
seq=STRING.atomize(seq)
if 1 or P:roll() then
for i=1,#seq do
seq[i]=
seq[i]=='Z' and 'S' or
seq[i]=='S' and 'Z' or
seq[i]=='J' and 'L' or
seq[i]=='L' and 'J' or
seq[i]
end
for y=1,#field do
TABLE.reverse(field[y])
for x=1,#field[y] do
local c=field[y][x]
field[y][x]=c==0 and 0 or c<=2 and 3-c or c<=4 and 7-c or c
end
end
end

if holdUsed==true then holdUsed=1 end
if holdUsed then
if debugging then
print("Pre-shuffle: ")
printSeq(seq)
end
allclearGenerator._shuffleSeq(P,seq,type(holdUsed)=='number' and holdUsed or holdUsed)
end

if debugging then
printField(field)
printSeq(seq)
end

P.modeData.allclearBaseID[args.lib]=baseID%#basePool+1

return field,seq
end

---@class Techmino.Mech.Brik.AllclearGenerator.arg1
---@field debugging boolean
---@field raw boolean
---@field pieceCount integer
---@field holdUsed boolean|integer
---@field emptyTop boolean
---@field mergeRate number
---@field repRate number
---@field growRate number
---@field splitRate number
---@field highRate number

---@class Techmino.Mech.Brik.AllclearGenerator.arg2
---@field lib 'box_3_4'|'pco'|'box_4_4'
---@field debugging boolean
---@field raw boolean
---@field holdUsed boolean|integer
---@field startPiece boolean
---@field avoidRepeat boolean

---@param args Techmino.Mech.Brik.AllclearGenerator.arg1|Techmino.Mech.Brik.AllclearGenerator.arg2
function allclearGenerator.newQuestion(P,args)
local field,seq
if args.lib then
field,seq=allclearGenerator._getLibQuestion(P,args)
else
field,seq=allclearGenerator._generateQuestion(P,args)
end
if args.raw then
return field,seq
else
P:setField(field)
P:pushNext(seq)
end
end

return allclearGenerator
75 changes: 75 additions & 0 deletions assets/game/mechanicLib/brik/allclearQuestLib.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
return {
base={
box_3_4={
{
{4,4,4,3,3,3,7,0,0,0},
{4,1,6,6,2,3,7,0,0,0},
{1,1,6,6,2,2,7,0,0,0},
{1,7,7,7,7,2,7,0,0,0},
},
{
{4,4,4,3,3,3,0,0,0,7},
{4,1,6,6,2,3,0,0,0,7},
{1,1,6,6,2,2,0,0,0,7},
{1,7,7,7,7,2,0,0,0,7},
},
{
{2,7,7,7,7,1,7,0,0,0},
{2,2,6,6,1,1,7,0,0,0},
{3,2,6,6,1,4,7,0,0,0},
{3,3,3,4,4,4,7,0,0,0},
},
{
{2,7,7,7,7,1,0,0,0,7},
{2,2,6,6,1,1,0,0,0,7},
{3,2,6,6,1,4,0,0,0,7},
{3,3,3,4,4,4,0,0,0,7},
},
},
pco={
{
{1,1,0,0,0,0,0,3,3,3},
{5,1,1,0,0,0,0,6,6,3},
{5,5,2,2,0,0,0,6,6,4},
{5,2,2,0,0,0,0,4,4,4},
},
{
{1,1,0,0,0,0,0,4,4,4},
{5,1,1,0,0,0,0,4,6,6},
{5,5,2,2,0,0,0,3,6,6},
{5,2,2,0,0,0,0,3,3,3},
},
{
{3,3,3,1,1,0,0,0,0,0},
{6,6,3,5,1,1,0,0,0,0},
{6,6,4,5,5,2,2,0,0,0},
{4,4,4,5,2,2,0,0,0,0},
},
{
{4,4,4,1,1,0,0,0,0,0},
{4,6,6,5,1,1,0,0,0,0},
{3,6,6,5,5,2,2,0,0,0},
{3,3,3,5,2,2,0,0,0,0},
},
},
box_4_4={
{
{4,4,4,3,3,3,0,0,0,0},
{4,1,6,6,2,3,0,0,0,0},
{1,1,6,6,2,2,0,0,0,0},
{1,7,7,7,7,2,0,0,0,0},
},
{
{2,7,7,7,7,1,0,0,0,0},
{2,2,6,6,1,1,0,0,0,0},
{3,2,6,6,1,4,0,0,0,0},
{3,3,3,4,4,4,0,0,0,0},
},
},
},
sequence={
box_3_4={'ZJJ','ZJL','ZTJ','JZJ','JZL','JSL','JJS','JJT','JJO','JJI','JLZ','JLT','JLO','JTJ','JTL','JTT','JOJ','JOL','JIJ','JIL','TJL','TJT','TTZ','TTJ','TIJ','OJJ','OJL','OOI','OIO','IJJ','IJL','ITJ','IOO'},
pco={'TJLL','TJII','TILL','JTLL','JLTL','JJIL','ITLL','ZTIL','ZSLT','ZLTT','ZLTS','ZLST','TZLT','TTLZ','TTLS','TTLL','TLTL','TLLT','TLLJ','TILO','TILJ','STLL','OILO','LZST','LTLT','LTII','LLJT','LLJO','LJLT','LJLO','LIJL','LIIT','JZLL','JZLJ','JZJL','JTTL','JTLT','JTII','JSTS','JSLL','JOLL','JLZJ','JLLT','JLLO','JLJI','JITI','JILJ','JIJL','ITLO','ITLJ','ITJL','ITIZ','IOLO','ILZT','ILTO','ILJL','ILIT','IJZT','IJTI','IJLL','IJJL','IJIT','IILT','ZZTS','ZZIL','ZTZS','ZTZJ','ZTTS','ZTSZ','ZTSJ','ZTOJ','ZTOI','ZTLZ','ZTLT','ZTLS','ZTLJ','ZTLI','ZTJZ','ZTJL','ZTIS','ZTIO','ZTII','ZSTZ','ZSTL','ZSIL','ZLZT','ZLTZ','ZLTL','ZLOT','ZLLJ','ZLJJ','ZJZS','ZJTS','ZJLL','ZJLJ','ZJJL','ZIZL','ZITO','ZITL','ZITJ','ZITI','ZISJ','ZIOL','ZILZ','ZILT','ZILI','ZIJZ','ZIIL','TZTS','TZTL','TZSJ','TZOJ','TZLZ','TZLS','TZLI','TZIS','TZIL','TTZS','TTZL','TTSZ','TTOI','TTLJ','TTJZ','TTJL','TTIO','TSZJ','TSTL','TSLT','TSJZ','TSJO','TSIZ','TOZJ','TOTI','TOOZ','TLZT','TLZI','TLTZ','TLTS','TLTJ','TLST','TLLZ','TLJZ','TLJT','TLJL','TLIZ','TJTL','TJTJ','TJSS','TJOO','TJLZ','TJLT','TJLJ','TJJZ','TJJL','TIZS','TIZL','TIZJ','TITI','TISZ','TIOL','TIOI','TILZ','TILS','TILI','TIJZ','TIJS','TIJO','TIJL','TIJI','TIIZ','TIIO','TIIL','TIIJ','SZTZ','SZLT','SZIL','STZZ','STLT','STJO','SLZT','SLLJ','SJTO','SIZL','SITT','SILZ','SIJI','SIIJ','OTOZ','OTJZ','OOTZ','OOLT','OOIL','OLOT','OLIT','OJLJ','OJJL','OIOL','OILZ','OILT','OILI','OIIL','LZZT','LZTZ','LZTT','LZTS','LZTI','LZOT','LZLJ','LZJL','LZJJ','LZIT','LTTL','LTLZ','LTLJ','LTJZ','LTJT','LSZT','LSLJ','LSJL','LOOT','LOLJ','LOJL','LLZJ','LLTZ','LLTJ','LLIJ','LJOL','LJLI','LJJT','LJIL','LIZT','LITO','LITI','LISZ','LIST','LIOT','LILJ','JZZS','JZTZ','JZTS','JZSZ','JZOT','JZOI','JZIO','JTZS','JTTZ','JTTO','JTTJ','JTSZ','JTSS','JTOT','JTOO','JTLZ','JTLJ','JTJZ','JTJT','JTJL','JSZT','JSTZ','JSST','JOZT','JOZI','JOTT','JOTO','JOOT','JOLJ','JOJL','JLTJ','JLSL','JLOL','JLOJ','JLJZ','JLJT','JLJS','JLJO','JLIJ','JJZL','JJTZ','JJTL','JJOL','JJLZ','JJLT','JJLS','JJLO','JJLI','JIZT','JITZ','JITS','JIST','JIOT','JIIT','IZZL','IZTO','IZTL','IZTJ','IZTI','IZSJ','IZOL','IZLZ','IZLT','IZLI','IZJZ','IZIL','ITZS','ITZO','ITZL','ITZJ','ITZI','ITTI','ITSZ','ITOL','ITOI','ITLZ','ITLS','ITLI','ITJZ','ITJS','ITJO','ITJI','ITIO','ITIL','ITIJ','ISZL','ISZJ','ISTT','ISLZ','ISJI','ISIJ','IOZL','IOTL','IOOL','IOLZ','IOLT','IOLI','IOIL','ILTZ','ILTS','ILTI','ILSZ','ILST','ILOT','ILLJ','IJTZ','IJTS','IJTO','IJTL','IJST','IJSI','IJOZ','IJOT','IJLJ','IJIS','IJIO','IIZL','IITZ','IITO','IITL','IITJ','IISJ','IIOL','IIOJ','IIJO'},
box_4_4={'ZZJL','ZZLJ','ZSTJ','ZSTL','ZJLI','ZJTT','ZJIJ','ZJIL','ZLZL','ZLLO','ZTSJ','ZTJS','ZTJT','ZTLI','ZTTS','ZTTL','ZTIJ','ZTIL','ZOJJ','ZOTJ','ZIJJ','ZIJL','ZITJ','ZITL','JZJI','JZLI','JZTT','JZOJ','JZIJ','JZIL','JSSJ','JSJS','JSJO','JSLT','JSLI','JSTT','JSOJ','JSOL','JSIL','JJZT','JJSO','JJSI','JJLL','JJTL','JJOZ','JJOO','JJOI','JJIS','JJIT','JJIO','JJII','JLZS','JLZT','JLZI','JLSZ','JLST','JLSI','JLJL','JLLJ','JLTJ','JLTL','JLTI','JLOZ','JLOS','JLOI','JLIZ','JLIS','JLIT','JLIO','JTZS','JTSJ','JTST','JTJS','JTJL','JTLJ','JTLO','JTLI','JTTI','JTOL','JTIJ','JTIL','JTIT','JOZJ','JOSJ','JOSL','JOJZ','JOJT','JOJO','JOJI','JOLS','JOLI','JOTL','JOOJ','JOOL','JOIJ','JOIL','JIZJ','JIZL','JISL','JIJS','JIJT','JIJO','JIJI','JILZ','JILS','JILT','JILO','JITJ','JITL','JITT','JIOJ','JIOL','JIIJ','JIIL','TZSJ','TZJS','TZJL','TZLZ','TZLI','TZTL','TZIL','TJZS','TJZL','TJST','TJJL','TJJO','TJLJ','TJTS','TJTL','TJTI','TJIL','TJIT','TTZS','TTZL','TTJS','TTJJ','TTJL','TTJI','TTOJ','TTOI','TTIZ','TTIJ','TTIO','TOJT','TOJO','TOJI','TOTJ','TOOJ','TOIJ','TIZL','TIJL','TIJT','TITZ','TITJ','TITO','TIOJ','TIIJ','OZJJ','OJJT','OJJO','OJJI','OJLI','OJOJ','OJOL','OJIJ','OJIL','OTJT','OTJO','OTJI','OTOJ','OTIJ','OOJJ','OOJL','OOTJ','OOII','OIJJ','OIJL','OITJ','OIOI','OIIO','IZJJ','IZJL','IZTJ','IZTL','IJZJ','IJZL','IJSL','IJJS','IJJT','IJJO','IJJI','IJLZ','IJLS','IJLT','IJLO','IJTJ','IJTL','IJTT','IJOJ','IJOL','IJIJ','IJIL','ITZL','ITJL','ITJT','ITTZ','ITTJ','ITTO','ITOJ','ITIJ','IOJJ','IOJL','IOTJ','IOOI','IOIO','IIJJ','IIJL','IITJ','IIOO'},
},
}
104 changes: 104 additions & 0 deletions assets/game/mode/brik/interior/tutorial/6.allclearPractice.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
local function newQuestion(P)
---@cast P Techmino.Player.Brik
local score=P.modeData.score
local field,seq=mechLib.brik.allclearGenerator.newQuestion(P,{
lib=score<10 and 'box_3_4' or score%2==0 and 'pco' or 'box_4_4',
raw=true,
})
P:setField(field)
P:pushNext(seq)
if not P.modeData.protect then
P.modeData.dumpData=nil
P.modeData.dumpData=P:serialize()
end
end

---@type Techmino.Mode
return {
initialize=function()
GAME.newPlayer(1,'brik')
GAME.setMain(1)
playBgm('space',true)
end,
settings={brik={
skin='brik_interior',
clearMovement='teleBack',
particles=false,
shakeness=0,
spawnDelay=62,
dropDelay=1e99,
lockDelay=1e99,
deathDelay=0,
nextSlot=3,
holdSlot=0,
seqType='none',
soundEvent={
countDown=NULL,
drop=gameSoundFunc.drop_old,
},
event={
playerInit=function(P)
P.modeData.score=0
P.modeData.protect=false
P.modeData.display=false

if PROGRESS.getInteriorScore('tuto6_score')<99 then
P.modeData.display=PROGRESS.getInteriorScore('tuto6_score').."/99"
else
P.modeData.display={COLOR.lY,STRING.time(PROGRESS.getInteriorScore('tuto6_time')/1000)}
end

newQuestion(P)
end,
gameStart=function(P)
P.modeData.dumpData=nil
P.modeData.dumpData=P:serialize()
end,
beforeDiscard=function(P)
local ac=#P.field._matrix==0
if #P.nextQueue==0 or ac then
if ac then
P.modeData.protect=false
P.modeData.score=P.modeData.score+1
if P.modeData.score>=99 then
PROGRESS.setInteriorScore('tuto6_score',99)
PROGRESS.setInteriorScore('tuto6_time',P.gameTime,'<')
P.modeData.display=STRING.time(P.gameTime/1000)
P:finish('win')
else
newQuestion(P)
end
else
if not P.modeData.protect then
PROGRESS.setInteriorScore('tuto6_score',P.modeData.score)
end
local data=P.modeData.dumpData
local gameTime=P.gameTime
P:unserialize(data)
P:release('moveLeft')
P:release('moveRight')
P:release('softDrop')
P.modeData.dumpData=data

P.modeData.protect=true
P.modeData.display=PROGRESS.getInteriorScore('tuto6_score').."/99"
P.modeData.score=math.max(P.modeData.score-3,0)
P.gameTime=gameTime
end
end
end,
drawOnPlayer=function(P)
GC.setColor(1,1,1,P.modeData.protect and .5 or 1)
FONT.set(80) GC.mStr(P.modeData.score,-300,-70)
FONT.set(30) GC.mStr(Text.target_score,-300,20)
GC.setColor(1,1,1,.872)
FONT.set(20) GC.mStr(P.modeData.display,-300,60)
end,
},
script={
{cmd='say',arg={duration='4.2s',text="@tutorial_allclearPractice_1",size=60,type='bold',y=-80}},
{cmd='say',arg={duration='4.2s',text="@tutorial_allclearPractice_2",size=30,y=60}},
},
}},
result=autoBack_interior,
}
4 changes: 2 additions & 2 deletions assets/language/lang_en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ local L={
menu_fastype="You seems enjoy typing",
},

-- Level
-- Tutorial levels
tutorial_basic="1. The Basics",
tutorial_sequence="2. Next & Hold",
tutorial_stackBasic="3. Basic Stacking",
tutorial_finesseBasic="4. Basic Finesse",
tutorial_finessePractice="5. Finesse Practice",
tutorial_allclearPractice="6. All Clear Practice (WIP)",
tutorial_allclearPractice="6. All Clear Practice",
tutorial_techrashPractice="7. Techrash Practice",
tutorial_finessePlus="8. Elegant Moves",

Expand Down
4 changes: 2 additions & 2 deletions assets/language/lang_zh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ local L={
menu_fastype="看起来你很喜欢打字",
},

-- Level
-- Tutorial levels
tutorial_basic="1.基本规则",
tutorial_sequence="2.预览&暂存",
tutorial_stackBasic="3.基础堆叠",
tutorial_finesseBasic="4.基础极简",
tutorial_finessePractice="5.极简练习",
tutorial_allclearPractice="6.全消练习 (WIP)",
tutorial_allclearPractice="6.全消练习",
tutorial_techrashPractice="7.消四练习",
tutorial_finessePlus="8.优雅操作",

Expand Down

0 comments on commit 2b0374a

Please sign in to comment.