package extend.zp.player.rulestate;

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

import extend.zp.EXMainServer;
import extend.zp.EXPlayer;
import extend.zp.EXRoom;
import extend.zp.OpCard;
import extend.zp.RuleWeight;
import extend.zp.player.state.EXPlayerDiscardState;
import extend.zp.room.state.EXRoomSetpState;
import extend.zp.uitl.CardUtil;
import extend.zp.uitl.Paixing;

/**
 * ��Ӧ���ƴ���״̬
 * 
 * 
 *
 *         2017��8��30�� PRPongState.java
 */
public class PRPongState extends StateBase<EXPlayer> {
	@Override
	public void enter(EXPlayer owner) {
		// TODO Auto-generated method stub
		////System.out.println("PRPongState");
		EXRoom room = (EXRoom) owner.room;
		EXPlayer activePlayer = (EXPlayer) room.playerMapBySeat.get(owner.room.activeSeat);
		activePlayer.stateMachine.changeState(Global.getState(PlayerWaitState.class));
		int fromseat = activePlayer.seat;

		EXMainServer.gameCtr.changeActiveSeat(room, owner.seat);

		int[] pongGroup = new int[3];
		int card = room.activeCard;
		pongGroup[0] = card;
		pongGroup[1] = card;
		pongGroup[2] = card;


		CardUtil.removeCard(owner.cardInhand, card, 2);
		room.activeCard = 0;
		room.lastDiscardSeat = 0;

		owner.pongGroup.add(pongGroup);
		owner.isTingHu = false;
		owner.opCardList.add(new OpCard(RuleWeight.TYPE_PONG, card, card, card, Paixing.caclHuxi(RuleWeight.TYPE_PONG, card)));

		ITArray opcard = TArray.newInstance();
		opcard.addInt(card);
		opcard.addInt(card);
		EXMainServer.gameCtr.actionCard(owner, card, card, RuleWeight.TYPE_PONG, fromseat, opcard);
		CardUtil.removeCard(owner.getRoom().paochucardlist,card,1);
		this.toNextState(owner);

	}

	@Override
	public void toNextState(EXPlayer owner) {
		owner.stateMachine.changeState(Global.getState(EXPlayerDiscardState.class));
	}

	@Override
	public void exit(EXPlayer owner) {
		// TODO Auto-generated method stub

	}

	@Override
	public void execute(EXPlayer owner, String cmd, int gid, Object param) {
		// TODO Auto-generated method stub

	}
}
