1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import GameData from "../../gcommon/GameData";
- import { Singleton } from "../../gcommon/Singleton";
- import { GameConst } from "../../GameConst";
- export interface CanjuData{
- fen:string,
- name:string
- }
- export default class CanjuModel extends Singleton<CanjuModel>() {
- public canjuDataArr:CanjuData[]=[]
- public get canjuData(){
- return this.canjuDataArr[this.selectLv-1];
- }
- selectLv:number=1;
- getCurMaxLevel(){
- var lv= GameData.GetCustomData(GameConst.canjuLevel);
- return Math.max(1,lv);
- }
- setNewMaxLevel(lv:number){
-
- GameData.SetCustomData(GameConst.canjuLevel,lv)
-
- }
- updateMaxLevel(value:number=1){
- var lv=this.getCurMaxLevel();
- lv+=value;
- lv=Math.min(lv,this.MaxLv)
- this.setNewMaxLevel(lv);
- }
- selectNextLv(){
- if(this.selectLv<this.MaxLv){
- this.selectLv++;
- }
- else this.selectLv=1;
-
- }
- get MaxLv(){
-
- return this.canjuDataArr.length;
- }
-
-
- public isUnlock(index:number){
- if(index<=0)return true;
- return this.getCurMaxLevel()>=index+1
- }
- }
|