// private void MoveAckEvent(string reqData, Hashtable roomClassList) { /* isHost+":"+roomNo+":"+"MoveReq"+":"+myPieceName+":"+myStartPos+":"+myFinalPos * isHost argument is needed for define who won the game and who lost the game */ roomData = reqData.Split(':'); try { /* roomClassList: key = room number, value = room class * find a right room for the received room number * and send acknowledgement */ room = (RoomHandler)roomClassList[roomData[1]]; if (room.isStart == true) { /* only startPos and finalPos are needed to proceed the movement * since the server knows a board status */ bool isValidMove = room.getMovePos(int.Parse(roomData[4]), int.Parse(roomData[5])); if (isValidMove) { room.setTurn(roomData[0]); room.SendToClient(roomData[0] + ":" + roomData[1] + ":MoveAck:" + roomData[3] + ":" + roomData[4] + ":" + room.RealFinalPos); /* any special move? like enpassant and castling? * These two must be notified separately to the clients */ //EnPassant if (room.Enpassant != null) { room.SendToClient(room.Enpassant.ToString() + ":EnPassant"); room.Enpassant = null; } //Castling if (room.StartPosCastling != null) { room.SendToClient(room.StartPosCastling.ToString() + ":"+ room.FinalPosCastling.ToString() + ":Castling"); room.StartPosCastling = null; room.FinalPosCastling = null; } /* then send the status of the game along with the roomData[0](isHost value). * if either checkmate, draw then notifies the clients to end the game * if check, notifies the client to show 'check' pop-up window */ switch (room.getStatus()) { case "Check": case "Stalemate": case "Normal": case "DrawByFiftyMove": case "DrawByLackOfMaterial": case "DrawByThreefold": room.SendToClient(roomData[0] +":"+ room.getStatus()); break; case "Checkmate": room.SendToClient(roomData[0] +":"+ room.getStatus()); //if the move was made by the host, then do the number of the win games += 1 to host if (roomData[0] == "True") { UpdateRankIfWin(room.hostName); UpdateRankIfLose(room.guestName); } //if the move was made by the guset, then do the number of the win games += 1 to guest else if (roomData[0] == "False") { UpdateRankIfWin(room.guestName); UpdateRankIfLose(room.hostName); } break; default: break; } } else { //Send("NotMoveNoti"); } } //room.SendToClient(reqData); else Send("NotStartNoti"); } //Handle Exception catch (Exception ex) { Console.WriteLine(ex); return; } }