package extend.zp.player.rulestate;

import com.game.Global;
import com.game.Util;
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.uitl.CardUtil;

public class PRPongState extends StateBase<EXPlayer> {

	@Override
	public void enter(EXPlayer owner) {
		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);
		owner.cardInhand.add(room.showCard);

		int card = room.showCard;
		Util.removeCard(owner.cardInhand, card, 3);
		room.showCard = 0;
		
		ITArray opcard = TArray.newInstance();
		opcard.addInt(card);
		opcard.addInt(card);
		
		
		
		OpCard opc = new OpCard(RuleWeight.TYPE_PONG, opcard, card);
		opc.huXi = CardUtil.getCardGroupHuxi(card, RuleWeight.TYPE_PONG, owner.opCardList);
		owner.opCardList.add(opc);
		
		EXMainServer.gameCtr.actionCard(owner, card, RuleWeight.TYPE_PONG, fromseat,opcard,opc.huXi,null);
		
		owner.stateMachine.changeState(Global.getState(EXPlayerDiscardState.class));
		
	}
}
