package extend.mj;

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

import com.game.Util;
import com.game.data.Player;
import com.game.data.Room;
import com.game.data.Score;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TArray;
import com.taurus.core.entity.TObject;

import extend.mj.tip.TipManager;

/**
 * 
 * 
 *
 * 2017��8��30��
 * EXPlayer.java
 */
public class EXPlayer extends Player {
	// ����
	public List<Integer>	cardInhand;

	// ������
	public List<Integer>	outcardList;

	public ITArray			opCard;

	public List<int[]>		pongGroup;
	public List<int[]>		kongGroup;
	public List<int[]>		selfKongGroup;
	public List<OpCard>		opCardList;

	public int				drawCard	= 0;
	public int				winCard		= 0;

	public TipManager		tipMgr;
	
	public SettleLog 		settleLog;
	
	/**
	 * ©��
	 */
	public boolean 			louhu = false;
	
	/**
	 * ǿ�Ƽ�����
	 */
	public boolean 			forceCheckWin = false;
	/**
	 * 0 С��   1 ���ܺ�
	 */
	public int 				winType = 0;
	public List<Integer>	notPongKongList = new ArrayList<>();
	
	public int 				niaoCount;
	public int				piaoNiao;
	public boolean 			fengding;

	public EXPlayer(int playerid, Room table, String session_id) {
		super(playerid, table, session_id);

		cardInhand = new ArrayList<>();
		outcardList = new ArrayList<>();

		pongGroup = new ArrayList<>();
		kongGroup = new ArrayList<>();
		selfKongGroup = new ArrayList<>();
		opCardList = new ArrayList<>();

		opCard = new TArray();

		tipMgr = new TipManager(this);
		
		settleLog = new SettleLog();
		settleLog.put(Config.SETTLE_DIAN_PAO, 0);
		settleLog.put(Config.SETTLE_JIE_PAO, 0);
		settleLog.put(Config.SETTLE_ZIMO, 0);
		settleLog.put(Config.SETTLE_AN_KONG, 0);
		settleLog.put(Config.SETTLE_MING_KONG, 0);
		fengding = false;
	}
	
	protected Score newScore() {
		return new EXScore(this);
	}

	public void initOpCard(ITArray opcard) {
		this.opCard.clear();
		for (int i = 0; i < opcard.size(); ++i) {
			this.opCard.addInt(opcard.getInt(i));
		}
	}

	public ITObject getReloadInfo(boolean self) {
		ITObject playerData = super.getReloadInfo(self);
		ITArray disCard = Util.toTArray(this.outcardList);
		playerData.putTArray("outcard_list", disCard);
		playerData.putInt("card_count", cardInhand.size());
		playerData.putInt("score", score.total_score);
		playerData.putInt("piao_niao", this.piaoNiao);
		ITArray opcards = TArray.newInstance();
		for (OpCard opcard : opCardList) {
			ITObject opcardParam = new TObject();
			opcardParam.putInt("type", opcard.type);
			opcardParam.putInt("card", opcard.card);
			opcards.addTObject(opcardParam);
		}
		playerData.putTArray("opcard", opcards);

		return playerData;
	}

	public void clear() {
		super.clear();
		this.cardInhand.clear();
		this.notPongKongList.clear();
		this.winer = 0;
		this.louhu = false;
		this.outcardList.clear();
		this.drawCard = 0;
		this.kongGroup.clear();
		this.pongGroup.clear();
		this.selfKongGroup.clear();
		this.opCardList.clear();
		this.score.resetRound();
		this.niaoCount = 0;
		this.piaoNiao = 0;
		this.fengding = false;
	}
	
	

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