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.EXMainServer;
import extend.mj.EXPlayer;
import extend.mj.EXRoom;
import extend.mj.OpCard;
import extend.mj.OpenKong;
import extend.mj.RuleWeight;
import extend.mj.player.state.EXPlayerOpenKongState;

/**
 * 
 */
public class PRSelfOpenKongState 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);

		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);
		
		OpenKong ok = new OpenKong();
		ok.fromSeat = owner.seat;
		ok.kongSeat = owner.seat;
		room.activeKong = ok;
		
		EXMainServer.gameCtr.actionCard(owner, card, RuleWeight.TYPE_SELF_KONG, owner.seat,opcard,true);
		
		owner.stateMachine.changeState(Global.getState(EXPlayerOpenKongState.class));
	}

}
