package com.backfire.doudizhu.userinfo;

import java.util.List;
import java.util.TreeMap;

import android.graphics.Bitmap;

import com.backfire.doudizhu.common.BitmapDownloadTask.BitmapDownloadCallback;
import com.backfire.doudizhu.common.MyJson;
import com.backfire.doudizhu.common.ShareData;
import com.backfire.room.data.State.Sex;
import com.backfire.utils.Log;

public class UserInfo implements BitmapDownloadCallback {

	private long uid = 0; // 用户唯一识别ID
	private String email = ""; // 用户名称（邮箱）
	private String nick = ""; // 用户昵称
	private int sex = 0; // 性别:未知 1:男2女
	private String address = ""; // 地址
	private String session = ""; // 用户session
	private String icon = ""; // 图像地址

	private List<Integer> items = null; // 用户道具

	private long money = 0; // 金币
	private int vipTime = 0; // VIP持续时间
	private int vip = 0; // VIP等级

	private String signature = ""; // 其他信息

	private int level = 0; // 等级
	private long exp = 0; // 经验
	private long winCount = 0; // 经验
	private String title = ""; // 称谓
	// -----新添数据--
	private int gameCnt = 0; // 游戏场数
	private int winCnt = 0; // 胜利场数
	private int dropCnt = 0; // 掉线次数
	private int runCnt = 0; // 逃跑次数

	private String open_id = ""; // 第三方ID
	private String token = ""; // 第三方token

	private String tableIP = ""; // 服务器IP
	private int tablePort = 0; // 服务器port
	private int roomId = 0; // roomid

	private int type = 0; // 桌子类型
	private int form = 0; // 桌子类型
	private long minEnter = 0; // 准入
	private long maxEnter = 0; // 准入
	private String tableName="";//桌子名

	private long lottery = 0; // 持有奖券数
	private int needLottery = 0; // 每次抽奖所需奖券数
	private long exchangeCard = 0; // 持有兑奖卡数

	private int tasknumber = 0; // 可领取任务次数
	private int giftnumber = 0; // 可领取礼包次数

	public int getGameCnt() {
		return gameCnt;
	}

	public void setGameCnt(int gameCnt) {
		this.gameCnt = gameCnt;
	}

	public int getWinCnt() {
		return winCnt;
	}

	public void setWinCnt(int winCnt) {
		this.winCnt = winCnt;
	}

	public int getDropCnt() {
		return dropCnt;
	}

	public void setDropCnt(int dropCnt) {
		this.dropCnt = dropCnt;
	}

	public int getRunCnt() {
		return runCnt;
	}

	public void setRunCnt(int runCnt) {
		this.runCnt = runCnt;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		if (Sex.MALE == sex) {
			this.sex = sex;
		} else {
			this.sex = Sex.FEMALE;
		}
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getSession() {
		return session;
	}

	public void setSession(String session) {
		this.session = session;
	}

	public long getMoney() {
		return money;
	}

	public void setMoney(long money) {
		this.money = money;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		if (icon == null || icon.trim().length() == 0) {
			icon = ShareData.getInstance().getStringValue("USER_ICON", "");
			if (icon == null || icon.trim().length() == 0) {
				icon = String.valueOf((int) (Math.random() * 24 + 1));
				ShareData.getInstance().saveStringValue("USER_ICON", icon);
				Log.i(this, "------>icon:" + icon);
			}

		}
		this.icon = icon;
	}

	public int getVip() {
		return vip;
	}

	public void setVip(int vip) {
		this.vip = vip;
	}

	public String getOpen_id() {
		return open_id;
	}

	public void setOpen_id(String open_id) {
		this.open_id = open_id;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getTableIP() {
		return tableIP;
	}

	public void setTableIP(String tableIP) {
		this.tableIP = tableIP;
	}

	public int getTablePort() {
		return tablePort;
	}

	public void setTablePort(int tablePort) {
		this.tablePort = tablePort;
	}

	@Override
	public void onBitmapDownloadFinished(int tag, Bitmap bitmap) {

	}

	public void removeServer() {
		tableIP = "";
		tablePort = 0;
		roomId = 0;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getVipTime() {
		return vipTime;
	}

	public void setVipTime(int vipDay) {
		this.vipTime = vipDay;
	}

	public String getSignature() {
		return signature;
	}

	public void setSignature(String signature) {
		this.signature = signature;
	}

	public long getExp() {
		return exp;
	}

	public void setExp(long exp) {
		this.exp = exp;
	}

	public long getWinCount() {
		return winCount;
	}

	public void setWinCount(long winCount) {
		this.winCount = winCount;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public String getOther() {
		TreeMap<String, Object> param = new TreeMap<String, Object>();
		param.put("uname", email);
		param.put("sex", sex);
		param.put("address", address);
		param.put("money", money);
		param.put("vipTime", vipTime);
		param.put("vip", vip);
		param.put("signature", signature);
		param.put("level", level);
		param.put("exp", exp);
		param.put("winCount", winCount);
		param.put("gameCnt", gameCnt);
		param.put("winCnt", winCnt);
		param.put("dropCnt", dropCnt);
		param.put("runCnt", runCnt);
		param.put("title", title);
		param.put("open_id", open_id);
		param.put("token", token);

		String json = new MyJson(param).toString();
		return json;
	}

	@Override
	public String toString() {
		return "UserInfo [uid=" + uid + ", email=" + email + ", nick=" + nick
				+ ", sex=" + sex + ", address=" + address + ", session="
				+ session + ", icon=" + icon + ", items=" + items + ", money="
				+ money + ", vipTime=" + vipTime + ", vip=" + vip
				+ ", signature=" + signature + ", level=" + level + ", exp="
				+ exp + ", winCount=" + winCount + ", title=" + title
				+ ", gameCnt=" + gameCnt + ", winCnt=" + winCnt + ", dropCnt="
				+ dropCnt + ", runCnt=" + runCnt + ", open_id=" + open_id
				+ ", token=" + token + ", tableIP=" + tableIP + ", tablePort="
				+ tablePort + ", type=" + type + ", form=" + form
				+ ", minEnter=" + minEnter + "]";
	}

	public void clear() {
		uid = 0; // 用户唯一识别ID
		email = null; // 用户名称（邮箱）
		nick = null; // 用户昵称
		sex = 0; // 性别：0未知，1男 2女
		address = null; // 地址
		session = null; // 用户session
		icon = null; // 图像地址

		money = 0; // 金币
		vipTime = 0; // VIP持续时间
		vip = 0; // VIP等级

		signature = null; // 其他信息

		level = 0; // 等级
		exp = 0; // 经验
		winCount = 0; // 经验
		title = null; // 称谓

		open_id = null; // 第三方ID
		token = null; // 第三方token

		tableIP = null; // 服务器IP
		tablePort = 0; // 服务器port
		minEnter = 0;
		maxEnter = 0;
		tableName="";

		type = 0; // 桌子类型

		needLottery = 0; // 每次抽奖所需奖券数
		lottery = 0; // 持有奖券数
		exchangeCard = 0; // 持有兑奖卡数

		tasknumber = 0; // 可领取任务次数
		giftnumber = 0; // 可领取礼包次数
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public int getForm() {
		return form;
	}

	public void setForm(int form) {
		this.form = form;
	}

	public List<Integer> getItems() {
		return items;
	}

	public void setItems(List<Integer> items) {
		this.items = items;
	}

	public long getMinEnter() {
		return minEnter;
	}

	public void setMinEnter(long minEnter) {
		this.minEnter = minEnter;
	}

	public int getRoomId() {
		return roomId;
	}

	public void setRoomId(int roomId) {
		this.roomId = roomId;
	}

	public int getNeedLottery() {
		return needLottery;
	}

	public void setNeedLottery(int needLottery) {
		this.needLottery = needLottery;
	}

	public long getExchangeCard() {
		return exchangeCard;
	}

	public void setExchangeCard(long exchangeCard) {
		this.exchangeCard = exchangeCard;
	}

	public long getLottery() {
		return lottery;
	}

	public void setLottery(long lottery) {
		this.lottery = lottery;
	}


	public long getMaxEnter() {
		return maxEnter;
	}

	public void setMaxEnter(long maxEnter) {
		this.maxEnter = maxEnter;
	}

	public int getTasknumber() {
		return tasknumber;
	}

	public void setTasknumber(int tasknumber) {
		this.tasknumber = tasknumber;
	}

	public int getGiftnumber() {
		return giftnumber;
	}

	public void setGiftnumber(int giftnumber) {
		this.giftnumber = giftnumber;
	}
}
