Beispiel #1
0
 public static PlayerData InfoDataDeal(SQLCtrl sqlCtrl, Socket socket, string[] strs)
 {
     PlayerData playerData = new PlayerData();
     //1连接请求。2注册信息。3登录信息
     switch (strs[1])
     {
         //连接
         case "1":
             playerData.Status = "1|1|1|";
             return playerData;
         //邮箱|昵称|密码|真实姓名|
         //注册
         case "2":
             if (sqlCtrl.IsMailExistInDb(strs[2]))
             { playerData.Status = "1|2|-1|邮箱已注册|"; return playerData; }
             if (sqlCtrl.IsNickExistInDb(strs[3]))
             { playerData.Status = "1|2|-1|昵称已注册|"; return playerData; }
             Register(sqlCtrl, socket, strs, out playerData);
             return playerData;
         //邮箱|密码|
         //登陆
         case "3":
             if (!sqlCtrl.IsMailExistInDb(strs[2]))
             { playerData.Status = "1|3|-1|邮箱未注册|"; return playerData; }
             Sign(sqlCtrl, socket, strs, out playerData);
             return playerData;
         default:
             playerData.Status = "1|信息未知情形|";
             return playerData;
     }
 }
Beispiel #2
0
 //处理登陆数据
 private static bool Sign(SQLCtrl sqlCtrl, Socket socket, string[] strs, out PlayerData playerData)
 {
     playerData = sqlCtrl.SelectInDb(strs[2]);
     if (strs[3] == playerData.Pwd)
     {
         playerData.Status = "1|3|1|"+playerData.Mail+"|"+0 + "|" + playerData.Nick + "|" + playerData.Real + "|" + playerData.Exp + "|";
         playerData.Socket = socket; return true;
     }
     else { playerData.Status = "1|3|-1|登陆失败,请检查密码或重试|"; return false; }
 }
Beispiel #3
0
 //处理注册数据
 private static bool Register(SQLCtrl sqlCtrl, Socket socket, string[] strs, out PlayerData playerData)
 {
     if (sqlCtrl.InsertToDb(strs[2], strs[3], strs[4], strs[5]))
     {
         playerData = new PlayerData(strs[2], strs[3], strs[4], strs[5], 0);
         playerData.Status = "1|2|1";
         playerData.Socket = socket;
         return true;
     }
     playerData = new PlayerData();
     playerData.Status = "1|2|-1|注册失败,请重试|";
     return false;
 }
Beispiel #4
0
 //在citadelsdb的GameUser表中依靠邮箱查询
 public PlayerData SelectInDb(string mail)
 {
     PlayerData playerData = new PlayerData();
     SqlCmd.CommandText = String.Format("select* from GameUser where GameUser_Mail='{0}'", mail);
     SqlCmd.Connection = SqlConnection;
     MySqlDataReader reader = SqlCmd.ExecuteReader();
     while (reader.Read())
     {
         if (reader.HasRows)
         {
             playerData = new PlayerData(reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), int.Parse(reader.GetString(5)));
         }
     }
     reader.Close();
     return playerData;
 }
Beispiel #5
0
 private static void SignDeal(DataCenter dataCenter, Socket socket, PlayerData playerData)
 {
     foreach (var item in dataCenter.LobbyPlayerList)
     {
         if (item.Mail == playerData.Mail)
         {
             switch (item.Status)
             {
                 case "Online": playerData.Status = "1|3|-1|您的账号已在大厅了|"; return;
                 case "Break": item.Socket = socket; item.Status = "Online"; return;
             }
         }
     }
     foreach (var room in dataCenter.RoomDataDic)
     {
         foreach (var player in room.Value.PlayerDataList)
         {
             if (player.Mail == playerData.Mail)
             {
                 switch (player.Status)
                 {
                     case "Online": playerData.Status = "1|3|-1|您的账号已经在游戏了|"; return;
                     case "Break": player.Socket = socket; player.Status = "Online"; return;
                 }
             }
         }
     }
 }