declare interface EosAccount {
	authority: string,
	blockchain: string
	name: string
}
class UserMgr {
	private static _instance: UserMgr;

	static get instance(): UserMgr {
		if (!this._instance) {
			this._instance = new UserMgr();
		}
		return this._instance;
	}
	account: EosAccount = null;
	balance: number = 0;//eos数量
	gt: number = 0;//gt数量
	money: number = 0;//余额数量

	public constructor() {
	}

	setAccount(account: EosAccount) {
		DEBUG && console.log('account:', account);
		this.account = account;
	}

	getPlayer(): string | null {
		return this.account && this.account.name;
	}

	setCoin(data: { balance?: number, money?: number, gt?: number }): void {
		data.balance !== undefined && (this.balance = data.balance);
		data.money !== undefined && (this.money = data.money);
		data.gt !== undefined && (this.gt = data.gt);
		Userinfo.instance.renderUserData(data);
	}

	isLogin(): boolean {
		if (this.account) {
			return true;
		} else {
			EosMgr.instance.login();
			return false;
		}
	}
}