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.PRChiState;
import extend.zp.player.rulestate.PRDiscardPaoState;
import extend.zp.player.rulestate.PRDrawChiState;
import extend.zp.player.rulestate.PRDrawPaoState;
import extend.zp.player.rulestate.PRDrawPongState;
import extend.zp.player.rulestate.PRPongState;
import extend.zp.player.rulestate.PRTiState;
import extend.zp.player.rulestate.PRWeiState;
import extend.zp.player.rulestate.PRWinState;
import extend.zp.player.state.*;
import extend.zp.room.state.EXRoomDaNiaoState;
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();
		Global.loggerDebug = true;
		Global.gameId = Config.GAME_ID;
		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(EXRoomDaNiaoState.class, new EXRoomDaNiaoState());
		//Global.registerState(EXRoomRoundSettleState.class, new EXRoomRoundSettleState());

		Global.registerState(PlayerWaitState.class, new EXPlayerWaitState());
		Global.registerState(EXPlayerDrawState.class, new EXPlayerDrawState());
		Global.registerState(EXPlayerPreDrawState.class, new EXPlayerPreDrawState());
		Global.registerState(EXPlayerDiscardState.class, new EXPlayerDiscardState());
		Global.registerState(EXPlayerDisCardTipState.class, new EXPlayerDisCardTipState());
		Global.registerState(EXPlayerDrawTipState.class, new EXPlayerDrawTipState());
		//Global.registerState(EXPlayerRoundSettleState.class, new EXPlayerRoundSettleState());
		Global.registerState(EXPlayerDaNiaoTipState.class,new EXPlayerDaNiaoTipState());

		Global.registerState(PRTiState.class, new PRTiState());
		Global.registerState(PRWeiState.class, new PRWeiState());
		Global.registerState(PRDrawPaoState.class, new PRDrawPaoState());
		Global.registerState(PRDiscardPaoState.class, new PRDiscardPaoState());
		Global.registerState(PRDrawPongState.class, new PRDrawPongState());
		Global.registerState(PRPongState.class, new PRPongState());
		Global.registerState(PRChiState.class, new PRChiState());
		Global.registerState(PRDrawChiState.class, new PRDrawChiState());
		Global.registerState(PRWinState.class, new PRWinState());
	}
	
	@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();
	}
}
