觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
juexingshike/assets/Scripts/diaoyu/DiaoYuManage.ts

115 lines
3.4 KiB

import User from "../../FrameWork/User/User";
import DataManageUtil from "../SCommon/DataManageUtil";
import DiaoYuConfigManage from "./DiaoYuConfigManage";
export default class DiaoYuManage {
public static getDiaoyuData(){
return User.getDiaoyuData();
}
public static setYuerData(yuerData){
let list = DiaoYuManage.getDiaoyuData();
let newList = DataManageUtil.setDataByDataCol(list, 'yuer', yuerData);
User.setDiaoyuData(newList);
}
public static getYuerData(){
let list = DiaoYuManage.getDiaoyuData();
let yuer = DataManageUtil.getDataByDataCol(list, 'yuer');
if(yuer == null || yuer == undefined){
yuer = [];
let yuerConfig = DiaoYuConfigManage.getDiaoyuYuerConfig();
for(let i=0;i<yuerConfig.length;i++){
let data = {
id : yuerConfig[i].id,
name: yuerConfig[i].name,
unlock: yuerConfig[i].unlock,
spTimes: 0,
freeTimes: 0
}
yuer.push(data);
}
let newList = DataManageUtil.setDataByDataCol(list, 'yuer', yuer);
User.setDiaoyuData(newList);
}
return yuer;
}
public static getYuerByName(name){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].name == name){
return yuer[i];
}
}
return null;
}
public static setYuerUnlockByName(name, unlock){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].name == name){
yuer[i].unlock = unlock
}
}
DiaoYuManage.setYuerData(yuer);
}
public static setYuerSpTimesByName(name, spTimes){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].name == name){
yuer[i].spTimes = spTimes
}
}
DiaoYuManage.setYuerData(yuer);
}
public static setYuerFreeTimesByName(name, freeTimes){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].name == name){
yuer[i].freeTimes = freeTimes
}
}
DiaoYuManage.setYuerData(yuer);
}
public static getYuerById(id){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].id == id){
return yuer[i];
}
}
return null;
}
public static setYuerUnlockById(id, unlock){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].id == id){
yuer[i].unlock = unlock
}
}
DiaoYuManage.setYuerData(yuer);
}
public static setYuerSpTimesById(id, spTimes){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].id == id){
yuer[i].spTimes = spTimes
}
}
DiaoYuManage.setYuerData(yuer);
}
public static setYuerFreeTimesById(id, freeTimes){
let yuer = DiaoYuManage.getYuerData();
for(let i=0;i<yuer.length;i++){
if(yuer[i].id == id){
yuer[i].freeTimes = freeTimes
}
}
DiaoYuManage.setYuerData(yuer);
}
}