Skip to content

Commit 2b0374a

Browse files
committed
教程第六关草稿
1 parent 987bf6a commit 2b0374a

File tree

5 files changed

+315
-13
lines changed

5 files changed

+315
-13
lines changed

assets/game/mechanicLib/brik/allclearGenerator.lua

Lines changed: 132 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---@type Map<Techmino.Event.Brik>
21
local allclearGenerator={}
32

43
local pieceShapes do
@@ -195,7 +194,9 @@ function allclearGenerator._shuffleSeq(P,seq,holdSlot)
195194
end
196195
end
197196
end
198-
function allclearGenerator._getQuestion(P,args)
197+
---@return Mat<boolean> field, Techmino.Brik.Name[] seq
198+
function allclearGenerator._generateQuestion(P,args)
199+
---@cast P Techmino.Player.Brik
199200
local field={} -- 0-1 matrix
200201
local seq={} -- briks' names
201202
local failCount=0
@@ -283,20 +284,142 @@ function allclearGenerator._getQuestion(P,args)
283284
printSeq(seq)
284285
end
285286

286-
return field,seq
287-
end
288-
289-
function allclearGenerator.newQuestion(P,args)
290-
local field,seq=allclearGenerator._getQuestion(P,args)
291287
TABLE.reverse(field)
292288
TABLE.reverse(seq)
289+
293290
for y=1,#field do
294291
for x=1,#field[y] do
295292
field[y][x]=field[y][x] and 8 or 0
296293
end
297294
end
298-
P:setField(field)
299-
P:pushNext(seq)
295+
296+
return field,seq
297+
end
298+
299+
---@return Mat<number> field, Techmino.Brik.Name[] seq
300+
function allclearGenerator._getLibQuestion(P,args)
301+
---@cast P Techmino.Player.Brik
302+
local field={} -- 0-1 matrix
303+
local seq={} -- briks' names
304+
305+
local pool=require'assets.game.mechanicLib.brik.allclearQuestLib'
306+
local basePool=pool.base[args.lib]
307+
local seqPool=pool.sequence[args.lib]
308+
309+
local args1={
310+
debugging=false,
311+
holdUsed=false,
312+
startPiece=false,
313+
avoidRepeat=true,
314+
}
315+
if type(args)=='table' then TABLE.update(args1,args) end
316+
317+
local debugging= args1.debugging
318+
local holdUsed= TABLE.getFirstValue(args1.holdUsed,P and P.settings.holdSlot)
319+
local startPiece= args1.startPiece
320+
321+
-- Initialize
322+
if not P.modeData.allclearBaseID then
323+
P.modeData.allclearBaseID={}
324+
P.modeData.allclearSeqHis={}
325+
for lib in next,pool.base do
326+
P.modeData.allclearBaseID[lib]=1
327+
P.modeData.allclearSeqHis[lib]={}
328+
end
329+
end
330+
331+
local baseID=P.modeData.allclearBaseID[args.lib]
332+
local seqHis=P.modeData.allclearSeqHis[args.lib]
333+
334+
field=basePool[baseID]
335+
local attempts=0
336+
local r
337+
while true do
338+
r=P:random(#seqPool)
339+
attempts=attempts+1
340+
if attempts>26 then break end
341+
if not args1.avoidRepeat then break end
342+
if not TABLE.find(seqHis,r) then
343+
table.insert(seqHis,1,r)
344+
seqHis[11]=nil
345+
break
346+
end
347+
end
348+
seq=seqPool[r]
349+
350+
field=TABLE.copy(field)
351+
seq=STRING.atomize(seq)
352+
if 1 or P:roll() then
353+
for i=1,#seq do
354+
seq[i]=
355+
seq[i]=='Z' and 'S' or
356+
seq[i]=='S' and 'Z' or
357+
seq[i]=='J' and 'L' or
358+
seq[i]=='L' and 'J' or
359+
seq[i]
360+
end
361+
for y=1,#field do
362+
TABLE.reverse(field[y])
363+
for x=1,#field[y] do
364+
local c=field[y][x]
365+
field[y][x]=c==0 and 0 or c<=2 and 3-c or c<=4 and 7-c or c
366+
end
367+
end
368+
end
369+
370+
if holdUsed==true then holdUsed=1 end
371+
if holdUsed then
372+
if debugging then
373+
print("Pre-shuffle: ")
374+
printSeq(seq)
375+
end
376+
allclearGenerator._shuffleSeq(P,seq,type(holdUsed)=='number' and holdUsed or holdUsed)
377+
end
378+
379+
if debugging then
380+
printField(field)
381+
printSeq(seq)
382+
end
383+
384+
P.modeData.allclearBaseID[args.lib]=baseID%#basePool+1
385+
386+
return field,seq
387+
end
388+
389+
---@class Techmino.Mech.Brik.AllclearGenerator.arg1
390+
---@field debugging boolean
391+
---@field raw boolean
392+
---@field pieceCount integer
393+
---@field holdUsed boolean|integer
394+
---@field emptyTop boolean
395+
---@field mergeRate number
396+
---@field repRate number
397+
---@field growRate number
398+
---@field splitRate number
399+
---@field highRate number
400+
401+
---@class Techmino.Mech.Brik.AllclearGenerator.arg2
402+
---@field lib 'box_3_4'|'pco'|'box_4_4'
403+
---@field debugging boolean
404+
---@field raw boolean
405+
---@field holdUsed boolean|integer
406+
---@field startPiece boolean
407+
---@field avoidRepeat boolean
408+
409+
---@param args Techmino.Mech.Brik.AllclearGenerator.arg1|Techmino.Mech.Brik.AllclearGenerator.arg2
410+
function allclearGenerator.newQuestion(P,args)
411+
local field,seq
412+
if args.lib then
413+
field,seq=allclearGenerator._getLibQuestion(P,args)
414+
else
415+
field,seq=allclearGenerator._generateQuestion(P,args)
416+
end
417+
if args.raw then
418+
return field,seq
419+
else
420+
P:setField(field)
421+
P:pushNext(seq)
422+
end
300423
end
301424

302425
return allclearGenerator
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
return {
2+
base={
3+
box_3_4={
4+
{
5+
{4,4,4,3,3,3,7,0,0,0},
6+
{4,1,6,6,2,3,7,0,0,0},
7+
{1,1,6,6,2,2,7,0,0,0},
8+
{1,7,7,7,7,2,7,0,0,0},
9+
},
10+
{
11+
{4,4,4,3,3,3,0,0,0,7},
12+
{4,1,6,6,2,3,0,0,0,7},
13+
{1,1,6,6,2,2,0,0,0,7},
14+
{1,7,7,7,7,2,0,0,0,7},
15+
},
16+
{
17+
{2,7,7,7,7,1,7,0,0,0},
18+
{2,2,6,6,1,1,7,0,0,0},
19+
{3,2,6,6,1,4,7,0,0,0},
20+
{3,3,3,4,4,4,7,0,0,0},
21+
},
22+
{
23+
{2,7,7,7,7,1,0,0,0,7},
24+
{2,2,6,6,1,1,0,0,0,7},
25+
{3,2,6,6,1,4,0,0,0,7},
26+
{3,3,3,4,4,4,0,0,0,7},
27+
},
28+
},
29+
pco={
30+
{
31+
{1,1,0,0,0,0,0,3,3,3},
32+
{5,1,1,0,0,0,0,6,6,3},
33+
{5,5,2,2,0,0,0,6,6,4},
34+
{5,2,2,0,0,0,0,4,4,4},
35+
},
36+
{
37+
{1,1,0,0,0,0,0,4,4,4},
38+
{5,1,1,0,0,0,0,4,6,6},
39+
{5,5,2,2,0,0,0,3,6,6},
40+
{5,2,2,0,0,0,0,3,3,3},
41+
},
42+
{
43+
{3,3,3,1,1,0,0,0,0,0},
44+
{6,6,3,5,1,1,0,0,0,0},
45+
{6,6,4,5,5,2,2,0,0,0},
46+
{4,4,4,5,2,2,0,0,0,0},
47+
},
48+
{
49+
{4,4,4,1,1,0,0,0,0,0},
50+
{4,6,6,5,1,1,0,0,0,0},
51+
{3,6,6,5,5,2,2,0,0,0},
52+
{3,3,3,5,2,2,0,0,0,0},
53+
},
54+
},
55+
box_4_4={
56+
{
57+
{4,4,4,3,3,3,0,0,0,0},
58+
{4,1,6,6,2,3,0,0,0,0},
59+
{1,1,6,6,2,2,0,0,0,0},
60+
{1,7,7,7,7,2,0,0,0,0},
61+
},
62+
{
63+
{2,7,7,7,7,1,0,0,0,0},
64+
{2,2,6,6,1,1,0,0,0,0},
65+
{3,2,6,6,1,4,0,0,0,0},
66+
{3,3,3,4,4,4,0,0,0,0},
67+
},
68+
},
69+
},
70+
sequence={
71+
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'},
72+
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'},
73+
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'},
74+
},
75+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
local function newQuestion(P)
2+
---@cast P Techmino.Player.Brik
3+
local score=P.modeData.score
4+
local field,seq=mechLib.brik.allclearGenerator.newQuestion(P,{
5+
lib=score<10 and 'box_3_4' or score%2==0 and 'pco' or 'box_4_4',
6+
raw=true,
7+
})
8+
P:setField(field)
9+
P:pushNext(seq)
10+
if not P.modeData.protect then
11+
P.modeData.dumpData=nil
12+
P.modeData.dumpData=P:serialize()
13+
end
14+
end
15+
16+
---@type Techmino.Mode
17+
return {
18+
initialize=function()
19+
GAME.newPlayer(1,'brik')
20+
GAME.setMain(1)
21+
playBgm('space',true)
22+
end,
23+
settings={brik={
24+
skin='brik_interior',
25+
clearMovement='teleBack',
26+
particles=false,
27+
shakeness=0,
28+
spawnDelay=62,
29+
dropDelay=1e99,
30+
lockDelay=1e99,
31+
deathDelay=0,
32+
nextSlot=3,
33+
holdSlot=0,
34+
seqType='none',
35+
soundEvent={
36+
countDown=NULL,
37+
drop=gameSoundFunc.drop_old,
38+
},
39+
event={
40+
playerInit=function(P)
41+
P.modeData.score=0
42+
P.modeData.protect=false
43+
P.modeData.display=false
44+
45+
if PROGRESS.getInteriorScore('tuto6_score')<99 then
46+
P.modeData.display=PROGRESS.getInteriorScore('tuto6_score').."/99"
47+
else
48+
P.modeData.display={COLOR.lY,STRING.time(PROGRESS.getInteriorScore('tuto6_time')/1000)}
49+
end
50+
51+
newQuestion(P)
52+
end,
53+
gameStart=function(P)
54+
P.modeData.dumpData=nil
55+
P.modeData.dumpData=P:serialize()
56+
end,
57+
beforeDiscard=function(P)
58+
local ac=#P.field._matrix==0
59+
if #P.nextQueue==0 or ac then
60+
if ac then
61+
P.modeData.protect=false
62+
P.modeData.score=P.modeData.score+1
63+
if P.modeData.score>=99 then
64+
PROGRESS.setInteriorScore('tuto6_score',99)
65+
PROGRESS.setInteriorScore('tuto6_time',P.gameTime,'<')
66+
P.modeData.display=STRING.time(P.gameTime/1000)
67+
P:finish('win')
68+
else
69+
newQuestion(P)
70+
end
71+
else
72+
if not P.modeData.protect then
73+
PROGRESS.setInteriorScore('tuto6_score',P.modeData.score)
74+
end
75+
local data=P.modeData.dumpData
76+
local gameTime=P.gameTime
77+
P:unserialize(data)
78+
P:release('moveLeft')
79+
P:release('moveRight')
80+
P:release('softDrop')
81+
P.modeData.dumpData=data
82+
83+
P.modeData.protect=true
84+
P.modeData.display=PROGRESS.getInteriorScore('tuto6_score').."/99"
85+
P.modeData.score=math.max(P.modeData.score-3,0)
86+
P.gameTime=gameTime
87+
end
88+
end
89+
end,
90+
drawOnPlayer=function(P)
91+
GC.setColor(1,1,1,P.modeData.protect and .5 or 1)
92+
FONT.set(80) GC.mStr(P.modeData.score,-300,-70)
93+
FONT.set(30) GC.mStr(Text.target_score,-300,20)
94+
GC.setColor(1,1,1,.872)
95+
FONT.set(20) GC.mStr(P.modeData.display,-300,60)
96+
end,
97+
},
98+
script={
99+
{cmd='say',arg={duration='4.2s',text="@tutorial_allclearPractice_1",size=60,type='bold',y=-80}},
100+
{cmd='say',arg={duration='4.2s',text="@tutorial_allclearPractice_2",size=30,y=60}},
101+
},
102+
}},
103+
result=autoBack_interior,
104+
}

assets/language/lang_en.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ local L={
303303
menu_fastype="You seems enjoy typing",
304304
},
305305

306-
-- Level
306+
-- Tutorial levels
307307
tutorial_basic="1. The Basics",
308308
tutorial_sequence="2. Next & Hold",
309309
tutorial_stackBasic="3. Basic Stacking",
310310
tutorial_finesseBasic="4. Basic Finesse",
311311
tutorial_finessePractice="5. Finesse Practice",
312-
tutorial_allclearPractice="6. All Clear Practice (WIP)",
312+
tutorial_allclearPractice="6. All Clear Practice",
313313
tutorial_techrashPractice="7. Techrash Practice",
314314
tutorial_finessePlus="8. Elegant Moves",
315315

assets/language/lang_zh.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,13 @@ local L={
302302
menu_fastype="看起来你很喜欢打字",
303303
},
304304

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

0 commit comments

Comments
 (0)