云环境和本地调试 添加
This commit is contained in:
49
assets/script/game/common/Test.ts
Normal file
49
assets/script/game/common/Test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { oops } from "db://oops-framework/core/Oops"
|
||||
|
||||
export class Test{
|
||||
load_data_from_local() {
|
||||
let local_data = this.get_local_data()
|
||||
if(!local_data.data||!local_data.fight_heros||!local_data.heros||!local_data.items||!local_data.tals||!local_data.equips){
|
||||
return this.init_local_data()
|
||||
}
|
||||
return local_data
|
||||
}
|
||||
get_local_data(){
|
||||
let local_data ={
|
||||
user_id: "local_debug",
|
||||
openid: "local_debug",
|
||||
regist_time: Date.now(),
|
||||
data: JSON.parse(oops.storage.get("data")),
|
||||
fight_heros: JSON.parse(oops.storage.get("fight_heros")),
|
||||
heros: JSON.parse(oops.storage.get("heros")),
|
||||
items: JSON.parse(oops.storage.get("items")),
|
||||
tals: JSON.parse(oops.storage.get("tals")),
|
||||
equips: JSON.parse(oops.storage.get("equips"))
|
||||
}
|
||||
return local_data
|
||||
}
|
||||
init_local_data(){
|
||||
let init_data = {
|
||||
data : {
|
||||
score: 0, mission: 1, gold: 100, diamond: 100, meat: 0, exp: 0,
|
||||
ghstone: 0, bhstone: 0, phlestone: 0, rhstone: 0, herocard: 0,
|
||||
ckey: 0, skey: 0, gkey: 0,},
|
||||
fight_heros: { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 },
|
||||
heros: {
|
||||
5001: { uuid: 5001, lv: 1 },
|
||||
5005: { uuid: 5005, lv: 1 },
|
||||
5007: { uuid: 5007, lv: 1 }
|
||||
},
|
||||
items: {},
|
||||
tals: {},
|
||||
equips: {}
|
||||
}
|
||||
oops.storage.set("data", JSON.stringify(init_data.data))
|
||||
oops.storage.set("fight_heros", JSON.stringify(init_data.fight_heros))
|
||||
oops.storage.set("heros", JSON.stringify(init_data.heros))
|
||||
oops.storage.set("items", JSON.stringify(init_data.items))
|
||||
oops.storage.set("tals", JSON.stringify(init_data.tals))
|
||||
oops.storage.set("equips", JSON.stringify(init_data.equips))
|
||||
return this.get_local_data()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user