import { _decorator } from 'cc';
const { ccclass } = _decorator;

/** 玩家数据类 */
@ccclass('UserData')
class UserData {
    public static instance: UserData | null = null;

    /** 剩余抽奖次数 */
    public point : number = 0;
    /** 奖品列表 */
    public prize_list : any[] = [];
    /** 游戏描述 */
    public description : string = "";

    private constructor(){}
    static get Instance(){
        if(UserData.instance == null){
            UserData.instance = new UserData();
        }
        return UserData.instance;
    }

    public setUserData(data:any){
        for (let key in data){
            if (this.hasOwnProperty(key)){
                (this as any)[key] = data[key];
            }
        }
    }
}

/**
 * 玩家数据
 */
export const USERDATA = UserData.Instance;