public async Task OnLoginAccepted(ConnectedUser conus) { await conus.SendCommand(new MatchMakerSetup() { PossibleQueues = PossibleQueues }); await UpdatePlayerStatus(conus.Name); }
public async Task RequestConnectSpring(ConnectedUser conus, string joinPassword) { UserBattleStatus ubs; if (!Users.TryGetValue(conus.Name, out ubs) && !(IsInGame && spring.LobbyStartContext.Players.Any(x => x.Name == conus.Name))) { if (IsPassworded && (Password != joinPassword)) { await conus.Respond("Invalid password"); return; } } var pwd = GenerateClientScriptPassword(conus.Name); spring.AddUser(conus.Name, pwd, conus.User); await conus.SendCommand(GetConnectSpringStructure(pwd)); }
public virtual async Task ProcessPlayerJoin(ConnectedUser user, string joinPassword) { if (IsPassworded && (Password != joinPassword)) { await user.Respond("Invalid password"); return; } if (IsKicked(user.Name)) { await KickFromBattle(user.Name, "Banned for five minutes"); return; } if ((user.MyBattle != null) && (user.MyBattle != this)) { await user.Process(new LeaveBattle()); } UserBattleStatus ubs; if (!Users.TryGetValue(user.Name, out ubs)) { ubs = new UserBattleStatus(user.Name, user.User, GenerateClientScriptPassword(user.Name)); Users[user.Name] = ubs; } ValidateBattleStatus(ubs); user.MyBattle = this; await server.TwoWaySyncUsers(user.Name, Users.Keys); // mutually sync user statuses await server.SyncUserToAll(user); await RecalcSpectators(); await user.SendCommand(new JoinBattleSuccess() { BattleID = BattleID, Players = Users.Values.Select(x => x.ToUpdateBattleStatus()).ToList(), Bots = Bots.Values.Select(x => x.ToUpdateBotStatus()).ToList(), Options = ModOptions }); await server.Broadcast(Users.Keys.Where(x => x != user.Name), ubs.ToUpdateBattleStatus()); // send my UBS to others in battle if (spring.IsRunning) { spring.AddUser(ubs.Name, ubs.ScriptPassword, ubs.LobbyUser); var started = DateTime.UtcNow.Subtract(spring.IngameStartTime ?? RunningSince ?? DateTime.UtcNow); started = new TimeSpan((int)started.TotalHours, started.Minutes, started.Seconds); await SayBattle($"THIS GAME IS CURRENTLY IN PROGRESS, PLEASE WAIT UNTIL IT ENDS! Running for {started}", ubs.Name); await SayBattle("If you say !notify, I will message you when the current game ends.", ubs.Name); } try { var ret = PlayerJoinHandler.AutohostPlayerJoined(GetContext(), ubs.LobbyUser.AccountID); if (ret != null) { if (!IsNullOrEmpty(ret.PrivateMessage)) { await SayBattle(ret.PrivateMessage, ubs.Name); } if (!IsNullOrEmpty(ret.PublicMessage)) { await SayBattle(ret.PublicMessage); } } } catch (Exception ex) { Trace.TraceError(ex.ToString()); await SayBattle("ServerManage error: " + ex); } }