序列复制粘贴,回放
This commit is contained in:
@@ -115,6 +115,38 @@ function pasteBoard()
|
||||
::ERROR::TEXT.show(text.dataCorrupted,350,360,35,"flicker",.5)
|
||||
end
|
||||
|
||||
function copySequence()
|
||||
local str=""
|
||||
|
||||
for i=1,#preBag do
|
||||
str=str..char(preBag[i]-1)
|
||||
end
|
||||
|
||||
return data.encode("string","base64",data.compress("string","deflate",str))
|
||||
end
|
||||
function pasteSequence(str)
|
||||
local _
|
||||
|
||||
--Decode
|
||||
_,str=pcall(data.decode,"string","base64",str)
|
||||
if not _ then return end
|
||||
_,str=pcall(data.decompress,"string","deflate",str)
|
||||
if not _ then return end
|
||||
|
||||
local bag={}
|
||||
for i=1,#str do
|
||||
_=byte(str,i)
|
||||
if _<25 then
|
||||
bag[i]=_+1
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
preBag=bag
|
||||
return true
|
||||
end
|
||||
|
||||
function mergeStat(stat,delta)
|
||||
for k,v in next,delta do
|
||||
if type(v)=="table"then
|
||||
@@ -128,7 +160,7 @@ function mergeStat(stat,delta)
|
||||
end
|
||||
end
|
||||
end
|
||||
function randomTarget(P)
|
||||
function randomTarget(P)--Return a random opponent for P
|
||||
if #players.alive>1 then
|
||||
local R
|
||||
repeat
|
||||
@@ -136,7 +168,7 @@ function randomTarget(P)
|
||||
until R~=P
|
||||
return R
|
||||
end
|
||||
end--return a random opponent for P
|
||||
end
|
||||
function freshMostDangerous()
|
||||
game.mostDangerous,game.secDangerous=nil
|
||||
local m,m2=0,0
|
||||
@@ -198,7 +230,7 @@ function royaleLevelup()
|
||||
if P.gameEnv.drop==0 then
|
||||
P.curY=P.y_img
|
||||
P.gameEnv._20G=true
|
||||
if P.AI_mode=="CC"then CC_switch20G(P)end--little cheating,never mind
|
||||
if P.AI_mode=="CC"then CC_switch20G(P)end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -223,65 +255,34 @@ end
|
||||
function resumeGame()
|
||||
SCN.swapTo("play","none")
|
||||
end
|
||||
function loadGame(M)
|
||||
--rec={}
|
||||
function loadGame(M,ifQuickPlay)
|
||||
stat.lastPlay=M
|
||||
curMode=Modes[M]
|
||||
local lang=setting.lang
|
||||
drawableText.modeName:set(text.modes[M][1])
|
||||
drawableText.levelName:set(text.modes[M][2])
|
||||
needResetGameData=true
|
||||
SCN.swapTo("play","fade_togame")
|
||||
SCN.swapTo("play",ifQuickPlay and"swipe"or"fade_togame")
|
||||
SFX.play("enter")
|
||||
end
|
||||
function resetPartGameData()
|
||||
game={
|
||||
frame=150-setting.reTime*15,
|
||||
result=false,
|
||||
pauseTime=0,
|
||||
pauseCount=0,
|
||||
garbageSpeed=1,
|
||||
warnLVL0=0,
|
||||
warnLVL=0,
|
||||
}
|
||||
destroyPlayers()
|
||||
curMode.load()
|
||||
TEXT.clear()
|
||||
if modeEnv.task then
|
||||
for i=1,#players do
|
||||
players[i]:newTask(modeEnv.task)
|
||||
end
|
||||
end
|
||||
if modeEnv.royaleMode then
|
||||
for i=1,#players do
|
||||
players[i]:changeAtk(randomTarget(players[i]))
|
||||
end
|
||||
end
|
||||
BG.set(modeEnv.bg)
|
||||
BGM.play(modeEnv.bgm)
|
||||
if modeEnv.royaleMode then
|
||||
for i=1,#players do
|
||||
players[i]:changeAtk(randomTarget(players[i]))
|
||||
end
|
||||
game.stage=1
|
||||
game.garbageSpeed=.3
|
||||
end
|
||||
restoreVirtualKey()
|
||||
collectgarbage()
|
||||
end
|
||||
function resetGameData()
|
||||
game={
|
||||
frame=150-setting.reTime*15,
|
||||
result=false,
|
||||
pauseTime=0,--Time paused
|
||||
pauseCount=0,--Pausing count
|
||||
garbageSpeed=1,--garbage timing speed
|
||||
warnLVL0=0,
|
||||
warnLVL=0,
|
||||
}
|
||||
game.frame=150-setting.reTime*15
|
||||
game.result=false
|
||||
game.pauseTime=0
|
||||
game.pauseCount=0
|
||||
game.garbageSpeed=1
|
||||
game.warnLVL0=0
|
||||
game.warnLVL=0
|
||||
game.recording=true
|
||||
game.replaying=false
|
||||
game.rec={}
|
||||
math.randomseed(tm.getTime())
|
||||
game.seed=rnd(261046101471026)
|
||||
|
||||
destroyPlayers()
|
||||
modeEnv=curMode.env
|
||||
curMode.load()--bg/bgm need redefine in custom,so up here
|
||||
math.randomseed(game.seed)
|
||||
curMode.load()--BG/BGM need redefine in custom,so up here
|
||||
if modeEnv.task then
|
||||
for i=1,#players do
|
||||
players[i]:newTask(modeEnv.task)
|
||||
@@ -306,6 +307,47 @@ function resetGameData()
|
||||
SFX.play("ready")
|
||||
collectgarbage()
|
||||
end
|
||||
function resetPartGameData(replaying)
|
||||
game.result=false
|
||||
game.garbageSpeed=1
|
||||
if replaying then
|
||||
game.frame=0
|
||||
game.recording=false
|
||||
game.replaying=1
|
||||
else
|
||||
game.frame=150-setting.reTime*15
|
||||
game.pauseTime=0
|
||||
game.pauseCount=0
|
||||
game.recording=true
|
||||
game.replaying=false
|
||||
game.rec={}
|
||||
math.randomseed(tm.getTime())
|
||||
game.seed=rnd(1046101471,2662622626)
|
||||
end
|
||||
|
||||
destroyPlayers()
|
||||
modeEnv=curMode.env
|
||||
math.randomseed(game.seed)
|
||||
curMode.load()
|
||||
if modeEnv.task then
|
||||
for i=1,#players do
|
||||
players[i]:newTask(modeEnv.task)
|
||||
end
|
||||
end
|
||||
BG.set(modeEnv.bg)
|
||||
BGM.play(modeEnv.bgm)
|
||||
|
||||
TEXT.clear()
|
||||
if modeEnv.royaleMode then
|
||||
for i=1,#players do
|
||||
players[i]:changeAtk(randomTarget(players[i]))
|
||||
end
|
||||
game.stage=1
|
||||
game.garbageSpeed=.3
|
||||
end
|
||||
restoreVirtualKey()
|
||||
collectgarbage()
|
||||
end
|
||||
function gameStart()
|
||||
SFX.play("start")
|
||||
for P=1,#players do
|
||||
|
||||
Reference in New Issue
Block a user