package extend.mj.room.state;


import com.game.Global;
import com.game.data.Player;
import com.game.state.StateBase;

import extend.mj.EXMainServer;
import extend.mj.EXPlayer;
import extend.mj.EXRoom;
import extend.mj.PlayerRuleManager;
import extend.mj.player.state.EXPlayerDrawState;

/**
 * 
 */
public class EXRoomSetpState extends StateBase<EXRoom> {

	@Override
	public void enter(EXRoom owner) {
		if(owner.haidiCount == owner.maxPlayers) {
			owner.liuju = true;
			owner.endGame();
			return;
		}
		
		Player player;
		if (owner.activeSeat == 0) {
			player = owner.playerMapBySeat.get(owner.bankerSeat);

		} else {
			player = owner.playerMapBySeat.get(owner.activeSeat);
			int nextSeat = player.nextSeat;
			player = owner.playerMapBySeat.get(nextSeat);

		}

		EXMainServer.gameCtr.changeActiveSeat(owner,player.seat);
		if(!EXMainServer.playerRuleMgr.condition(PlayerRuleManager.HAIDI_RULE, (EXPlayer)player,false)){
			player.stateMachine.changeState(Global.getState(EXPlayerDrawState.class));
		}
		
	}

}
