
import { AccountManager } from "./AccountManager";
import { GameTools } from "../GameUtils/GameTools";
//用户user数据
export enum AccountUser{buyed_kun,diamond,equip_themes,favorite_times,game_times,get_themes,list_kun,moeny,progress_themes,revival,stage }
export class PlayerData {
    constructor(_token: string, _config: Object, _appSetting: Object, _user: Object, _userbase: Object, _useInvite: any[], _user_stage: Object = null, _user_sign, _user_achievement,lottery)  {
        this.zhengshu = _token;
        //this.peizhis = _config;
        this.netzheshe = _appSetting;
        this.account = _user;
        this.accountssss = _userbase;
        this.qiandao = _user_sign;
        this.renwu = _user_achievement;
        this.userId = this.account["user_id"];
        this.openid = this.accountssss["openid"];
        this.m_invite = _useInvite;
        this.lottery=lottery;
        console.log("user_id:" + this.userId);
    }

    public zhengshu: string;
    public peizhis: Object;
    public netzheshe: Object;
    public account: Object;
    public accountssss: Object;
    public qiandao: Object;
    public renwu: Object;
    public openid: string = "";
    public userId: string = "";
    public m_invite: any[];
    public lottery: any;


    public _globaldic:{[key:string]:any}
   

    public GainCollocation(_type: string): any  {
        return this.peizhis[_type];
    }

    public GainAccount(_type: string)  {
        return this.account[_type];
    }

    public get fenxiang(): boolean  {
        return this.netzheshe["share"] == "1";
    }
    //是否检测场景值
    public get CheckScene():boolean{
        return this.netzheshe["checkscene"] == "1";
    }
    //是否误触
    public get Cheat():boolean{
        return this.netzheshe["cheat"] == "1";
    }
    //banner
    public get Banner():boolean{
        return this.netzheshe["Banner"] == "1";
    }
    //误导时间
    public get wudaoshijian():number{
        return Number(this.netzheshe["wudaoshijian"]) ;
    }
    
    public GetUser(_type: AccountUser) {
        var type = AccountUser[_type];
        return this.account[type];
    }

    /** 判断玩家是否含有枪*/
    public HasGun(_id: number): boolean {
        var data = this.GainAccount("get_themes");
        for (var i = 0; i < data.length; i++) {
            var hd = data[i];
            if (_id == hd) {
                return true;
            }
        }
        return false;
    }

    /**获取看视频得皮肤进度 */
    public GetProgress(_id:number):number{
        var config = this.account["progress_themes"];
        var progress = config[_id] ? config[_id] : 0;
        return progress;
    }

    //分享文案
    public get ShareTxt():string{
        return this.netzheshe["sharecontent"];
    }
}