package extend.mj;

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.mj.player.rulestate.PROtherKongState;
import extend.mj.player.rulestate.PROtherWinState;
import extend.mj.player.rulestate.PRPongKongState;
import extend.mj.player.rulestate.PRPongState;
import extend.mj.player.rulestate.PRSelfKongState;
import extend.mj.player.rulestate.PRSelfWinState;
import extend.mj.player.state.EXPlayerDisCardTipState;
import extend.mj.player.state.EXPlayerDiscardState;
import extend.mj.player.state.EXPlayerDrawState;
import extend.mj.player.state.EXPlayerDrawTipState;
import extend.mj.player.state.EXPlayerKongWinState;
import extend.mj.player.state.EXPlayerPiaoNiaoTipState;
import extend.mj.player.state.EXPlayerWaitKongWinState;
import extend.mj.player.state.EXPlayerWaitState;
import extend.mj.room.state.EXRoomDealState;
import extend.mj.room.state.EXRoomSetpState;
import extend.mj.room.state.EXRoomStartGameState;

/**
 * 
 * 
 * EXMainServer.java
 */
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(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(EXPlayerWaitKongWinState.class, new EXPlayerWaitKongWinState());
		Global.registerState(EXPlayerKongWinState.class, new EXPlayerKongWinState());
		Global.registerState(EXPlayerPiaoNiaoTipState.class, new EXPlayerPiaoNiaoTipState());
		
		Global.registerState(PROtherKongState.class, new PROtherKongState());
		Global.registerState(PROtherWinState.class, new PROtherWinState());
		Global.registerState(PRPongKongState.class, new PRPongKongState());
		Global.registerState(PRPongState.class, new PRPongState());
		Global.registerState(PRSelfKongState.class, new PRSelfKongState());
		Global.registerState(PRSelfWinState.class, new PRSelfWinState());
		
		
	}


	@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();
	}
}
