
import { AccountManager } from "./AccountManager";
//用户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 Invincible():number{
        return Number(this.netzheshe["Invincible"]);
    }

    //是否检测场景值
    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];
    }

    //npc开始跑向玩家的距离
    public get NpcRunDistance():number{
        return Number(this.netzheshe["NpcRunDistance"]);
    }
    //npc开始攻击玩家的距离
    public get NpcAtkDistance():number{
        return Number(this.netzheshe["NpcAtkDistance"]);
    }
    //npc距玩家多远 开始追逐人质的距离
    public get NpcChaseDistance():number{
        return Number(this.netzheshe["NpcChaseDistance"]);
    }
    //npc追逐多远距离后开始扑向人质
    public get NpcRushDistance():number{
        return Number(this.netzheshe["NpcRushDistance"]);
    }
    //boss攻击的时间间隔
    public get BossAtkInterval():number{
        return Number(this.netzheshe["BossAtkInterval"]);
    }
    //npc移动速度
    public get NpcSpeed():number{
        return Number(this.netzheshe["NpcSpeed"]);
    }
    //人质移动速度
    public get HostageSpeed():number{
        return Number(this.netzheshe["HostageSpeed"]);
    }
    //箭速
    public get ArrowSpeed():number{
        return Number(this.netzheshe["ArrowSpeed"]);
    }
    //boss距离玩家多远开始跑
    public get BossDistance():number{
        return Number(this.netzheshe["ArrowSpeed"]);
    }
    //boss移动速度
    public get BossSpeed():number{
        return Number(this.netzheshe["BossSpeed"]);
    }
    //玩家攻击力
    public get PlayerDamage():number{
        return Number(this.netzheshe["PlayerDamage"]);
    }
    //boss距离玩家多远距离开始静止
    public get MaxBossDistance():number{
        return Number(this.netzheshe["MaxBossDistance"]);
    }
    //boss距离玩家多远距离开始跟玩家保持一样的速度
    public get MinBossDistance():number{
        return Number(this.netzheshe["MinBossDistance"]);
    }
    //获取分享信息 
    public get ShareContent():string{
        return this.netzheshe["sharecontent"];
    }
    //左右轴向转动速度插值
    public get DirRoatationLerp():number{
        return Number(this.netzheshe["DirRoatationLerp"]);
    }
    //左右移动速度插值
    public get DirMoveLerp():number{
        return Number(this.netzheshe["DirMoveLerp"]);
    }
    //左右移动插值
    public get CurTouchsmoothness():number{
        return Number(this.netzheshe["curtouchsmoothness"]);
    }
    //轴向
    public get CurTouchsize():number{
        return Number(this.netzheshe["curtouchsize"]);
    }
    //npc扑向人质时的速度
    public get NPCRushSpeed():number{
        return Number(this.netzheshe["NPCRushSpeed"]);
    }
    //获取玩家的射程
    public get Range():number{
        return Number(this.netzheshe["Range"]);
    }
    //屏幕抖动开关
    public get CanStageShake():boolean{
        return this.netzheshe["canstageshake"] == "1"
    }
    //获得全局变量
    public GlobalData(_key:string):number{
        var dataarray = [];
        var _global = this.GainCollocation("global");
        for(var key in _global){
            dataarray.push(_global[key]);
        }
        for (let i = 0; i < dataarray.length; i++) {
            if(_key == dataarray[i].key){
                return Number(dataarray[i].value);
            }
        }
    }

    /**判断是否已经拥有该马匹、帽子 */
    public HasEquip(_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;
    }
}