package extend.pk;

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;

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



/**
 * 
 * 
 */
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;
	
	public SettleLog		settleLog;
	
	public int boomnum = 0;

	public int baochun = -1;

	public int bonusScore = 0;
	public int awardScore = 0;

	public int ziranchun = 0;

	public int dis_times = 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, 1);
		settleLog.put(Config.SETTLE_CHUNTIAN_COUNT, 1);
		settleLog.put(Config.SETTLE_CTSTATUS, 1);
		settleLog.put(Config.SETTLE_BOMB_COUNT, 0);
		settleLog.put(Config.SETTLE_MAX_SCORE, 20);
	}
	
	protected Score newScore() {
		return new EXScore(this);
	}
	
	@Override
	public ITObject getReloadInfo() {
		ITObject playerData = super.getReloadInfo();
		playerData.putInt("card_size", this.cardInhand.size());
		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);
		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.open = 0;
		this.boomnum = 0;
		this.baochun = -1;
		this.ziranchun = 0;
		this.dis_times = 0;
	}

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

}
