package extend.zp;

import java.util.Map;

import com.game.GameController;
import com.game.Global;
import com.game.MainServer;
import com.game.data.Player;
import com.game.data.Room;
import com.game.player.state.PlayerWaitState;
import com.game.room.state.RoomStartGameState;

import extend.zp.player.rulestate.PRChowState;
import extend.zp.player.rulestate.PRPongState;
import extend.zp.player.rulestate.PRWinState;
import extend.zp.player.state.EXPlayerDisCardTipState;
import extend.zp.player.state.EXPlayerDiscardState;
import extend.zp.player.state.EXPlayerDrawState;
import extend.zp.player.state.EXPlayerDrawTipState;
import extend.zp.player.state.EXPlayerPreDrawState;
import extend.zp.player.state.EXPlayerWaitState;
import extend.zp.player.state.EXPlayerWeiState;
import extend.zp.room.state.EXRoomDealState;
import extend.zp.room.state.EXRoomSetpState;
import extend.zp.room.state.EXRoomStartGameState;

/**
 * 
 * 
 */
public class EXMainServer extends MainServer{
	
	
	public static PlayerRuleManager playerRuleMgr;
	
	public static EXGameController gameCtr;
	
	@Override
	public void onStart() {
		super.onStart();
		gameCtr = (EXGameController)Global.gameCtr;
		
		registerState();
		
		playerRuleMgr = new PlayerRuleManager();
	}
	

	
	private final void registerState() {
		Global.registerState(RoomStartGameState.class, new EXRoomStartGameState());
		Global.registerState(EXRoomSetpState.class, new EXRoomSetpState());
		Global.registerState(EXRoomDealState.class, new EXRoomDealState());
		
		Global.registerState(EXPlayerPreDrawState.class, new EXPlayerPreDrawState());
		Global.registerState(PlayerWaitState.class, new EXPlayerWaitState());
		Global.registerState(EXPlayerDrawState.class, new EXPlayerDrawState());
		Global.registerState(EXPlayerDiscardState.class, new EXPlayerDiscardState());
		Global.registerState(EXPlayerDisCardTipState.class, new EXPlayerDisCardTipState());
		Global.registerState(EXPlayerDrawTipState.class, new EXPlayerDrawTipState());
		Global.registerState(EXPlayerWeiState.class, new EXPlayerWeiState());
		
		Global.registerState(PRChowState.class, new PRChowState());
		Global.registerState(PRWinState.class, new PRWinState());
		Global.registerState(PRPongState.class, new PRPongState());
	}
	
	@Override
	public Room newRoom(String roomid, Map<String, String> redis_room_map) {
		// TODO Auto-generated method stub
		return new EXRoom(roomid, redis_room_map);
	}


	@Override
	public Player newPlayer(int playerid, Room room, String session_id) {
		// TODO Auto-generated method stub
		return new EXPlayer(playerid, room, session_id);

	}


	@Override
	protected GameController newController() {
		// TODO Auto-generated method stub
		return new EXGameController();
	}
}
