public async Task <bool> Setup(BattleCommand cmd, Say e, string args) { command = cmd.Create(); Creator = e; question = command.Arm(battle, e, args); if (question == null) { return(false); } winCount = battle.Users.Values.Count(x => command.GetRunPermissions(battle, x.Name) >= BattleCommand.RunPermission.Vote && !cmd.IsSpectator(battle, x.Name, x)) / 2 + 1; if (winCount <= 0) { winCount = 1; } if (!await Vote(e, true)) { await battle.SayBattle($"Poll: {question} [!y=0/{winCount}, !n=0/{winCount}]"); } else { return(false); } return(true); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { var afkers = battle.Users.Values.Where(x => !x.IsSpectator && x.LobbyUser.IsAway); var unready = battle.Users.Values.Where(x => !x.IsSpectator && x.SyncStatus != SyncStatuses.Synced); bool wait = false; if (afkers.Any()) { wait = true; await battle.SayBattle("The following users are afk and will be spectated: " + afkers.Select(x => x.Name).StringJoin()); } if (unready.Any()) { wait = true; await battle.SayBattle("The following users are still downloading the map: " + unready.Select(x => x.Name).StringJoin()); } if (wait) { await battle.SayBattle("Game starting in 10 seconds..."); battle.BlockPolls(10); startTimer = new Timer(10000); startTimer.Enabled = true; startTimer.AutoReset = false; startTimer.Elapsed += (t, s) => { StartGame(battle); }; } else { await StartGame(battle); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchMaxLevel(lvl); await battle.SayBattle("Max level changed to " + lvl); await battle.SayBattle($"Warning: This command will have no effect if there are more than {DynamicConfig.Instance.MaximumStatLimitedBattlePlayers} players in the room!"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (rank < Ranks.Percentiles.Length && rank >= 0) { await battle.SwitchMaxRank(rank); await battle.SayBattle("Max rank changed to " + Ranks.RankNames[rank]); await battle.SayBattle($"Warning: This command will have no effect if there are more than {DynamicConfig.Instance.MaximumStatLimitedBattlePlayers} players in the room!"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { battle.SwitchAutohost(!battle.IsAutohost, e?.User); if (battle.IsAutohost) { await battle.SayBattle("This battle is now an autohost. It will stay open until this command is executed again. Maps are rotated after each game. Title, player limit, password and modoptions are locked. Use !maxelo, !minelo, !maxlevel, !minlevel, !minmapsupportlevel to customize this autohost."); } else { await battle.SayBattle("This battle is no longer an autohost, it will close as soon as it is empty."); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { battle.SwitchCbal(!battle.IsCbalEnabled); if (battle.IsCbalEnabled) { await battle.SayBattle("This battle will attempt to place clan members together when balancing."); } else { await battle.SayBattle("This battle will NOT attempt to place clan members together when balancing."); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (gameName != null) { await battle.SwitchGame(gameName); await battle.SayBattle("Changing game to " + gameName); battle.SwitchDefaultGame(false); await battle.SayBattle("This host will no longer update its game automatically"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.SayGame("/cheat"); await battle.SayBattle("Cheats!"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.SayGame(cmd); await battle.SayBattle($"Host executing {cmd}"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.ForceStart(); await battle.SayBattle($"Force starting game"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.ForceStart(); await battle.SayBattle($"Force starting game"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.SayGame("/cheat"); await battle.SayBattle("Cheats!"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { battle.spring.SayGame(cmd); await battle.SayBattle($"Host executing {cmd}"); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (game != null) { await battle.SwitchGame(game.InternalName); await battle.SayBattle("changing game to " + game.InternalName); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (cnt > 0) { await battle.SwitchMaxPlayers(cnt); await battle.SayBattle("Max players changed to " + cnt); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (gameName != null) { await battle.SwitchGame(gameName); await battle.SayBattle("changing game to " + gameName); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (map != null) { await battle.SwitchMap(map.InternalName); await battle.SayBattle("changing map to " + map.InternalName); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (Map != null) { await battle.SwitchMap(Map.InternalName); await battle.SayBattle("Changing map to " + Map.InternalName); if (Map.MapSupportLevel < MapSupportLevel.Supported) { await battle.SayBattle($"This map is not officially supported!"); } if (alternativeMap != null) { await battle.SayBattle($"Did you mean {alternativeMap.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{alternativeMap.ResourceID}?"); } } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (title != null) { await battle.SwitchTitle(title); await battle.SayBattle("Title changed to " + title); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (engine != null) { await battle.SwitchEngine(engine); await battle.SayBattle("Engine changed to " + engine); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (map != null) { await battle.SwitchMap(map.InternalName); await battle.SayBattle("changing map to " + map.InternalName); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (title != null) { await battle.SwitchTitle(title); await battle.SayBattle("Title changed to " + title); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (Enum.IsDefined(typeof(MapSupportLevel), level)) { await battle.SwitchMinMapSupportLevel(((MapSupportLevel)level)); await battle.SayBattle("Minimum map support level changed to " + ((MapSupportLevel)level).ToString()); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (battle.spring.IsRunning) { await battle.SayBattle("exiting game"); battle.spring.ExitGame(); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (rank < Ranks.Percentiles.Length && rank >= 0) { await battle.SwitchMaxRank(rank); await battle.SayBattle("Max rank changed to " + Ranks.RankNames[rank]); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (engine != null) { await battle.SwitchEngine(engine); await battle.SayBattle("Engine changed to " + engine); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (cnt > 0) { await battle.SwitchMaxPlayers(cnt); await battle.SayBattle("Max players changed to " + cnt); } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { var s = battle.spring; if (s.IsRunning) { foreach (var p in s.LobbyStartContext.Players.Where(x => x.AllyID == alliance && !x.IsSpectator)) { s.ResignPlayer(p.Name); } } await battle.SayBattle($"Team {alliance + 1} resigned"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (target == null) { foreach (var usr in battle.Users.Values.Where(x => !x.IsSpectator && x.LobbyUser.IsAway)) await battle.Spectate(usr.Name); } else { await battle.Spectate(target); } await battle.SayBattle($"forcing {target ?? "AFK"} to spectator"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { foreach (var usr in battle.Users.Values.Where(x => !x.IsSpectator && x.LobbyUser.IsAway)) { await battle.server.GhostSay(new Say() { User = GlobalConst.NightwatchName, Target = usr.Name, Text = "You have been forced to spectator status due to inactivity.", IsEmote = true, Ring = true, Place = SayPlace.User }); await battle.Spectate(usr.Name); } await battle.SayBattle($"forcing AFK to spectator"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { if (target == null) { foreach (var usr in battle.Users.Values.Where(x => !x.IsSpectator && x.LobbyUser.IsAway)) { await battle.Spectate(usr.Name); } } else { await battle.Spectate(target); } await battle.SayBattle($"forcing {target ?? "AFK"} to spectator"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SetModOptions(new Dictionary<string, string>()); await battle.SayBattle($"options reset to defaults"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { var b = battle; List <IEnumerable <Account> > teams; RatingCategory cat = RatingCategory.Casual; if (b.IsMatchMakerBattle) { cat = RatingCategory.MatchMaking; } if (b.Mode == PlasmaShared.AutohostMode.Planetwars) { cat = RatingCategory.Planetwars; } using (var db = new ZkDataContext()) { if (battle.IsInGame) { teams = b.spring.LobbyStartContext?.Players.Where(u => !u.IsSpectator) .GroupBy(u => u.AllyID) .Select(x => x.Select(p => Account.AccountByName(db, p.Name))).ToList(); } else { switch (battle.Mode) { case PlasmaShared.AutohostMode.Game1v1: teams = b.Users.Values.Where(u => !u.IsSpectator) .GroupBy(u => u.Name) .Select(x => x.Select(p => Account.AccountByName(db, p.Name))).ToList(); break; case PlasmaShared.AutohostMode.Teams: await battle.SayBattle($"The battle will be balanced when it starts"); return; default: teams = b.Users.Values.Where(u => !u.IsSpectator) .GroupBy(u => u.AllyNumber) .Select(x => x.Select(p => Account.AccountByName(db, p.Name))).ToList(); break; } } if (teams.Count < 2) { await battle.SayBattle($"!predict needs at least two human teams to work"); return; } var chances = RatingSystems.GetRatingSystem(cat).PredictOutcome(teams, DateTime.UtcNow); for (int i = 0; i < teams.Count; i++) { await battle.SayBattle($"Team {teams[i].OrderByDescending(x => x.GetRating(cat).Elo).First().Name} has a {Math.Round(1000 * chances[i]) / 10}% chance to win"); } } }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SetModOptions(options); await battle.SayBattle($"options changed {optionsAsString}"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SetModOptions(new Dictionary<string, string>()); await battle.SayBattle($"options reset to defaults"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchInviteMmPlayers(minplayers); await battle.SayBattle("Minimum players for automatic MM invites changed to " + minplayers); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { var s = battle.spring; if (s.IsRunning) foreach (var p in s.LobbyStartContext.Players.Where(x => x.AllyID == alliance && !x.IsSpectator)) s.ResignPlayer(p.Name); await battle.SayBattle($"Team {alliance + 1} resigned"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { battle.StopVote(e); await battle.SayBattle("poll cancelled"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchPassword(pwd); await battle.SayBattle(string.IsNullOrEmpty(pwd)? "battle password removed" : "battle room password changed"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.RunServerBalance(false, teamCount, null); await battle.SayBattle("Teams were balanced"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchPassword(pwd); await battle.SayBattle("battle room password changed"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchMinLevel(lvl); await battle.SayBattle("Min level changed to " + lvl); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { battle.StopVote(); await battle.SayBattle("poll cancelled"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.RunServerBalance(false, teamCount, null); await battle.SayBattle("Teams were balanced"); }
public override async Task ExecuteArmed(ServerBattle battle, Say e) { await battle.SwitchGameType(mode); await battle.SayBattle("Game type changed to " + mode.Description()); }