package com.data.bean;

import java.util.Map;

import com.data.cache.GameCache;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TObject;

public class GroupPlayBean extends BaseBean {
    public ITObject data      = null;
    public ITObject simp_data = null;
    public int	    pay_type;
	public int      gameType;
    public int	    gameId;
    public int 		maxPlayers;
    public String   config;
    public String   hpConfig;
    public int	    hp_times;
    public int 		hpOnOff;
    public int 		ban;
    public boolean  mark;
    public String   name;
    public int 		deskId;
    public int	    reward;
	public int	    xipai_reward;
	public int	    rewardType;
    public int 		rewardValueType;
	public int	    xipai_rewardType;
	public int 		xipai_rewardValueType;

	public int	    anchou_reward;
	public int      anchou_rewardType;
	public int 		anchou_rewardValueType;

	public int		robot_room;

    public ITObject configData;
    
    public void fillData(Map<String,String> map) {
		if(!map.get("opt").equals("1")) {
			this.del = true;
			return;
		}
		ITObject obj = data;
		if(obj==null) {
			obj = TObject.newInstance();
			this.data = obj;
		}
		this.id = Integer.parseInt(map.get("id"));
		this.name = map.get("name");
		this.gameId = Integer.parseInt(map.get("gameId"));
		this.config = map.get("config");
		this.hpConfig = map.get("hpData");
		this.hpOnOff = Integer.parseInt(map.get("hpOnOff"));
		this.hp_times = Integer.parseInt(map.get("hp_times"));
		this.ban = map.containsKey("ban") ? Integer.parseInt(map.get("ban")) : 0;

		int iMark = map.containsKey("mark") ? Integer.parseInt(map.get("mark")) : 0;
		this.mark = iMark==1 ? true : false;

		this.reward = Integer.parseInt(map.get("reward"));
		this.xipai_reward = 100000000;
		if(map.get("xipai_reward") != null) {
			this.xipai_reward = Integer.parseInt(map.get("xipai_reward"));
		}
		this.rewardType = Integer.parseInt(map.get("rewardType"));
		this.rewardValueType = 1;
		if(map.get("rewardValueType") != null) {
			this.rewardValueType = Integer.parseInt(map.get("rewardValueType"));
		}

		this.xipai_rewardType = 1;
		if(map.get("xipai_rewardType") != null) {
			this.xipai_rewardType = Integer.parseInt(map.get("xipai_rewardType"));
		}

		this.xipai_rewardValueType = 1;
		if(map.get("xipai_rewardValueType") != null) {
			this.xipai_rewardValueType = Integer.parseInt(map.get("xipai_rewardValueType"));
		}

		this.anchou_reward = 100000000;
		if(map.get("anchou_reward") != null) {
			this.anchou_reward = Integer.parseInt(map.get("anchou_reward"));
		}

		this.anchou_rewardType = 1;
		if(map.get("anchou_rewardType") != null) {
			this.anchou_rewardType = Integer.parseInt(map.get("anchou_rewardType"));
		}

		this.anchou_rewardValueType = 1;
		if(map.get("anchou_rewardValueType") != null) {
			this.anchou_rewardValueType = Integer.parseInt(map.get("anchou_rewardValueType"));
		}

		this.robot_room = 0;
		if(map.get("robot_room") != null) {
			this.robot_room = Integer.parseInt(map.get("robot_room"));
		}
		if(map.get("deskId") != null) {
			this.deskId = Integer.parseInt(map.get("deskId"));
		}
		
		obj.putInt("id", this.id);
		obj.putString("name", this.name);
		obj.putInt("gameId", gameId);
		obj.putInt("deskId", this.deskId);
		obj.putString("config", config);
		obj.putString("hpData", hpConfig);
		obj.putInt("hp_times", hp_times);
		obj.putInt("hpOnOff", hpOnOff);
		obj.putInt("reward", reward);
		obj.putInt("xipai_reward", xipai_reward);
		obj.putInt("rewardType", rewardType);
		obj.putInt("rewardValueType", rewardValueType);
		obj.putInt("xipai_rewardType", xipai_rewardType);
		obj.putInt("xipai_rewardValueType", xipai_rewardValueType);

		obj.putInt("anchou_reward", anchou_reward);
		obj.putInt("anchou_rewardType", anchou_rewardType);
		obj.putInt("anchou_rewardValueType", anchou_rewardValueType);

		obj.putInt("ban", ban);
		obj.putBoolean("mark", mark);
		
		GameBean gb = GameCache.getGame(gameId);
		obj.putString("game_name", gb.name);

		configData = TObject.newFromJsonData(map.get("config"));
		maxPlayers = gb.maxPlayers;
		if(configData.containsKey("maxPlayers")) {
			maxPlayers = configData.getInt("maxPlayers");
		}
		obj.putInt("maxPlayers", maxPlayers);
		
		if(simp_data==null) {
			simp_data = TObject.newInstance();
		}

		simp_data.putInt("gameId", gameId);
		simp_data.putInt("id", this.id);
		simp_data.putInt("hpOnOff", obj.getInt("hpOnOff"));
		simp_data.putInt("maxPlayers", maxPlayers);
		simp_data.putString("name", obj.getString("name"));
		simp_data.putInt("deskId", this.deskId);
	}
}
