package extend.mj.player.rulestate;

import com.game.Global;
import com.game.Util;
import com.game.state.StateBase;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;

import extend.mj.Config;
import extend.mj.EXMainServer;
import extend.mj.EXPlayer;
import extend.mj.EXRoom;
import extend.mj.EXScore;
import extend.mj.OpCard;
import extend.mj.RuleWeight;
import extend.mj.player.state.EXPlayerDrawState;

/**
 * ��Ӧ���ܴ���״̬
 * 
 *
 * 2017��8��30��
 * PRSelfKongState.java
 */
public class PRSelfKongState extends StateBase<EXPlayer> {

	@Override
	public void enter(EXPlayer owner) {
		EXRoom room = owner.getRoom();
		
		ITArray opCard = owner.opCard;
		int card = opCard.getInt(0);
		Util.removeCard(owner.cardInhand, card, 4);
		int [] kongGroup = new int [4];
		kongGroup[0] = card;
		kongGroup[1] = card;
		kongGroup[2] = card;
		kongGroup[3] = card;
		owner.selfKongGroup.add(kongGroup);
		owner.opCardList.add(new OpCard(RuleWeight.TYPE_SELF_KONG, card));
		
		ITArray opcard = TArray.newInstance();
		opcard.addInt(card);
		opcard.addInt(card);
		opcard.addInt(card);
		opcard.addInt(card);
		EXMainServer.gameCtr.actionCard(owner, card, RuleWeight.TYPE_SELF_KONG, owner.seat,opcard);
		
		room.addAllScore(owner, 3, EXScore.KONG);
		owner.stateMachine.changeState(Global.getState(EXPlayerDrawState.class));
		owner.settleLog.add(Config.SETTLE_AN_KONG);
	}
}
