package extend.pk;

import java.util.ArrayList;
import java.util.List;

import com.game.data.Player;
import com.game.data.Room;
import com.game.data.Score;
import com.taurus.core.entity.ITObject;

import extend.pk.uitl.CardUtil;



/**
 * 
 * 
 */
public class EXPlayer extends Player {
	
	/**默认action时间 20s*/
	public static final int	DEFAULT_ACTION_TIME		        = 20000;
	/**默认托管时间 1s*/
	public static final int	DEFAULT_ENTRUST_TIME	        = 1000;
	/**
	 * 默认准备时间 20s
	 */
	public static final int	DEFAULT_READY_TIME		        = 20000;
		
	// 手牌
	public List<CardObj> cardInhand;

	//打出的牌
	public List<CardObj> outCards;
	
	public CardGroup last_outcard;
	public boolean pass;
	
	// 放作弊场第一张牌是否关闭
	public int open = 0;
	
	/**春天 */
	public boolean chuntian;
	
	/**是否有红桃10*/
	public boolean isHaveRedTen;
	
	public SettleLog		settleLog;
	
	public int boomnum = 0;
	public int piao = -1;
	public int daniaoScore = 0;
	public int bonusScore = 0;
	public int awardScore = 0;
	public int cur510kFen = 0;
	public int ju510kFen = 0;
	public int allJu510kFen = 0;
	public int curXiFen = 0;
	public int juXiFen = 0;
	public int jiangli = 0;
	public int allJiangLi = 0;
	public int leftCardFen = 0;
	public int allLeftCardFen = 0;
	public int jieSuanJiangLi = 0;

	public EXPlayer(int playerid, Room table, String session_id) {
		super(playerid, table, session_id);
		cardInhand = new ArrayList<>();
		outCards   = new ArrayList<>();
		
		settleLog = new SettleLog();
		settleLog.put(Config.SETTLE_WIN_COUNT, 0);
		settleLog.put(Config.SETTLE_CHUNTIAN_COUNT, 0);
		settleLog.put(Config.SETTLE_BOMB_COUNT, 0);
		settleLog.put(Config.SETTLE_MAX_SCORE, 0);
	}
	
	protected Score newScore() {
		return new EXScore(this);
	}
	
	@Override
	public ITObject getReloadInfo() {
		ITObject playerData = super.getReloadInfo();
		playerData.putInt("card_size", this.cardInhand.size());
		playerData.putInt("piao", this.piao);
		playerData.putInt("cur510kFen", this.cur510kFen);
		playerData.putInt("ju510kFen", this.ju510kFen);
		playerData.putInt("curXiFen", this.curXiFen);
		playerData.putInt("juXiFen", this.juXiFen);
		playerData.putInt("jiangli", this.jiangli);
		playerData.putInt("leftCardFen", this.leftCardFen);

		playerData.putInt("allJu510kFen", this.allJu510kFen);
		playerData.putInt("allJiangLi", this.allJiangLi);
		playerData.putInt("allLeftCardFen", this.allLeftCardFen);
		if(last_outcard!=null) {
			playerData.putTObject("last_outcard", last_outcard.toObject(false));
		}
		
		if(this.room.isplaying == false) {
			playerData.putTArray("cards", CardUtil.toTArray(this.cardInhand));

			playerData.putTArray("handCards", CardUtil.toTArray(this.cardInhand));
			playerData.putTArray("outCards", CardUtil.toTArray(this.outCards));

			playerData.putInt("score", score.total_score);
			playerData.putInt("winscore", score.round_score);
			playerData.putInt("thisboomnum", boomnum);
			playerData.putInt("open", open);
		}
		return playerData;
	}
	
	@Override
	public ITObject getInfo() {
		ITObject playerData = super.getInfo();
		playerData.putInt("score", score.total_score);
		playerData.putInt("cur510kFen", this.cur510kFen);
		return playerData;
	}
	

	public void clear() {
		super.clear();
	
	}
	
	public void clearEx() {
		
		this.score.resetRound();
		this.cardInhand.clear();
		this.outCards.clear();
		this.last_outcard = null;
		this.pass = false;
		this.chuntian =false;
		this.isHaveRedTen=false;
		this.open = 0;
		//this.boomnum = 0;
		this.piao = -1;
		this.daniaoScore = 0;
		this.ju510kFen = 0;
		this.juXiFen = 0;
		this.jiangli = 0;
		this.leftCardFen = 0;
	}

	public EXRoom getRoom() {
		return (EXRoom) room;
	}

}
