public GameRoom CreateRoom(string name, byte[] gameInfo, PlayerAccount host) { var room = new GameRoom(name, nextRoomID, LobbyID, gameInfo, host); Rooms.Add(nextRoomID, room); nextRoomID--; return(room); }
public GameRoom(string name, int id, int lobbyId, byte[] gameInfo, PlayerAccount host) { Name = name; ID = id; lobbyID = lobbyId; GameInformation = gameInfo; Host = host; // Players.Add(host); }
protected void LadderLogin(Message msg) { var username = msg.Data[0].AsString; var game = msg.Data[1].AsString; account = PlayerAccount.Get(username); if (account != null) { Connection.Send(msg.SuccessResponse(new DNodeList())); } }
void GetPlayerInfo(Message msg) { var username = msg.Data[0].AsString; var acc = PlayerAccount.Get(username); if (acc == null) { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary(1) })); } else { Connection.Send(msg.SuccessResponse(new DNodeList { acc.IrcAlias, acc.Username, acc.FirstName, acc.LastName, acc.Language, acc.Email, acc.PublicIP })); } }
protected void LoginWaitModuleCmd(Message msg) { var username = msg.Data[0].AsString; account = PlayerAccount.Get(username); if (account != null) { Connection.Send(msg.SuccessResponse()); } else { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary(2) })); } account.PublicIP = Connection.IP; }
protected void LoginCmd(Message msg) { var username = msg.Data[0].AsString; var password = msg.Data[1].AsString; var game = msg.Data[2].AsString; // "SHOKPC1.05" var acc = PlayerAccount.Get(username); if (acc != null) { if (acc.CheckPassword(password)) { if (!PlayerAccount.LoggedInAccounts.Contains(acc)) { PlayerAccount.LoggedInAccounts.Add(acc); Connection.Send(msg.SuccessResponse()); } else { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary((int)LoginResponses.AlreadyLoggedIn) })); } } else { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary((int)LoginResponses.WrongPassword) })); } } else { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary((int)LoginResponses.InvalidUsername) })); } }
protected void NewUserCmd(Message msg) { var game = msg.Data[0].AsString; //SHOKPC1.05 var username = msg.Data[1].AsString; var password = msg.Data[2].AsString; var firstName = msg.Data[3].AsString; var lastName = msg.Data[4].AsString; var email = msg.Data[5].AsString; var language = msg.Data[6].AsString; if (!PlayerAccount.IsNameAvailable(username)) { Connection.Send(msg.FailResponse(new DNodeList { new DNodeBinary(1) })); } else { var pa = new PlayerAccount { Username = username, FirstName = firstName, LastName = lastName, Email = email, Language = language }; pa.SetPassword(password); pa.UpdateStore(); Connection.Send(msg.SuccessResponse()); } /* 1 username taken * 2 username not according to rules * 3 username contains illegal words * */ }
protected void LobbyServerLogin(Message msg) { var username = msg.Data[0].AsString; var unknownNum = msg.Data[1].AsInt; var localIP = msg.Data[2].AsString; var localSubnet = msg.Data[3].AsString; var unknownNum2 = msg.Data[4].AsInt; Connection.WriteDebug("lobby server login ({0} | {1})", unknownNum, unknownNum2); account = PlayerAccount.Get(username); if (account != null) { account.LocalIP = localIP; account.LocalSubnet = localSubnet; account.PublicIP = Connection.IP; Connection.Send(new Message(MessageCode.GSSUCCESS, new DNodeList { (int)MessageCode.LOBBYSERVERLOGIN, new DNodeList { Constants.LOBBY_SERVER_ID } })); } }