protected override bool PerformInit(TasSayEventArgs e, string[] words, out string question, out int winCount) { if (spring.IsRunning) { context = spring.StartContext; voteStarter = context.Players.FirstOrDefault(x => x.Name == e.UserName && !x.IsSpectator); if (voteStarter != null) { question = string.Format("Resign team {0}?", voteStarter.AllyID + 1); int cnt = 0, total = 0; foreach (var p in context.Players.Where(x => x.AllyID == voteStarter.AllyID && !x.IsSpectator)) { total++; if (p.IsIngame || tas.MyBattle.Users.ContainsKey(p.Name)) { //Note: "ExistingUsers" is empty if users disconnected from lobby but still ingame. bool afk = tas.ExistingUsers.ContainsKey(p.Name) && tas.ExistingUsers[p.Name].IsAway; if (!afk) cnt++; } } winCount = (cnt * 3 / 5) + 1; if (total > 1 && winCount == 1) winCount = 2; // prevents most pathological cases (like a falsely AFK partner in 2v2) return true; } } AutoHost.Respond(tas, spring, e, "You cannot resign now"); question = null; winCount = 0; return false; }
static void ScriptAddUser(StringBuilder script, int userNum, PlayerTeam pteam, int teamNum, Dictionary<string,string> customParameters) { // PLAYERS script.AppendFormat(" [PLAYER{0}]\n", userNum); script.AppendLine(" {"); script.AppendFormat(" Name={0};\n", pteam.Name); script.AppendFormat(" Spectator={0};\n", pteam.IsSpectator ? 1 : 0); if (!pteam.IsSpectator) script.AppendFormat(" Team={0};\n", teamNum); if (pteam.ScriptPassword != null) script.AppendFormat(" Password={0};\n", pteam.ScriptPassword); if (customParameters != null) foreach (var kvp in customParameters) script.AppendFormat(" {0}={1};\n", kvp.Key, kvp.Value); script.AppendLine(" }"); }
static void SpecPlayerOnCondition(PlayerTeam player, Account account, string userMessage, ZkLobbyServer.ZkLobbyServer server) { player.IsSpectator = true; server.GhostPm(account.Name, userMessage); }
static void SpecPlayerOnCondition(PlayerTeam player, Account account, string userMessage) { player.IsSpectator = true; AuthServiceClient.SendLobbyMessage(account, userMessage); }
static void AddPwPlayer(BattleContext context, string matchUser, BalanceTeamsResult res, int allyID) { PlayerTeam player = context.Players.FirstOrDefault(x => x.Name == matchUser); if (player == null) { player = new PlayerTeam() { Name = matchUser }; User us; if (Global.Nightwatch.Tas.GetExistingUser(matchUser, out us)) player.LobbyID = us.AccountID; else { var db = new ZkDataContext(); var acc = Account.AccountByName(db, matchUser); if (acc != null) player.LobbyID = acc.AccountID; } } res.Players.Add(new PlayerTeam { AllyID = allyID , IsSpectator = false, Name = player.Name, LobbyID = player.LobbyID, TeamID = player.TeamID }); }
static void AddPwPlayer(LobbyHostingContext context, string matchUser, BalanceTeamsResult res, int allyID) { var player = context.Players.FirstOrDefault(x => x.Name == matchUser); if (player == null) { player = new PlayerTeam { Name = matchUser }; ConnectedUser us; // todo hack if (Global.Server.ConnectedUsers.TryGetValue(matchUser, out us)) player.LobbyID = us.User.AccountID; // else { var db = new ZkDataContext(); var acc = Account.AccountByName(db, matchUser); if (acc != null) player.LobbyID = acc.AccountID; } } res.Players.Add( new PlayerTeam { AllyID = allyID, IsSpectator = false, Name = player.Name, LobbyID = player.LobbyID }); }
static void SpecPlayerOnCondition(PlayerTeam player, Account account, string userMessage) { player.IsSpectator = true; Global.Server.GhostPm(account.Name, userMessage); }