private void HandleRemoveTrackCommand(string login) { if (!LoginHasRight(login, true, Command.RemoveCurrentTrack)) { return; } ChallengeListSingleInfo challengeInfo = GetCurrentChallengeInfoCached(); if (challengeInfo == null) { SendFormattedMessageToLogin(login, "{[#ServerStyle]}> {[#ErrorStyle]} Could not retrieve current challenge info."); return; } GenericResponse <bool> response = Context.RPCClient.Methods.RemoveChallenge(challengeInfo.FileName); if (!response.Erroneous && response.Value) { SendFormattedMessageToLogin(login, "{[#ServerStyle]}> {[#MessageStyle]} Removed track {[#HighlightStyle]}{[Track]}{[#MessageStyle]}. Use {[#HighlightStyle]}WriteTrackList{[#MessageStyle]} command to save the changes!", "Track", StripTMColorsAndFormatting(challengeInfo.Name)); } else { SendFormattedMessageToLogin(login, "{[#ServerStyle]}> {[#ErrorStyle]} Error removing current track."); } }
protected void OnChallengeCreatedOrUpdated(ChallengeListSingleInfo challengeInfo, Challenge challenge) { if (ChallengeCreatedOrUpdated != null) { ChallengeCreatedOrUpdated(this, new ChallengeCreatedOrUpdatedEventArgs(challengeInfo, challenge)); } }
private void EnsureChallengeExistsInStorage(ChallengeListSingleInfo challengeInfo) { Challenge challenge = new Challenge(challengeInfo.UId, challengeInfo.Name, challengeInfo.Author, challengeInfo.Environnement); ChallengeAdapter.IncreaseRaces(challenge); CurrentChallengeID = challenge.ID.Value; OnChallengeCreatedOrUpdated(challengeInfo, challenge); }
public ChallengeCreatedOrUpdatedEventArgs(ChallengeListSingleInfo challengeInfo, Challenge challenge) { ChallengeInfo = challengeInfo; Challenge = challenge; }
private void ReportCurrentChallenge(ICollection <PlayerRank> currentRankings, ChallengeListSingleInfo currentChallenge) { if (currentChallenge == null) { return; } ServerOptions serverOptions = GetServerOptionsCached(this); if (serverOptions == null) { return; } GameMode?currentGameMode = GetCurrentGameModeCached(this); if (!currentGameMode.HasValue) { return; } List <PlayerSettings> currentPlayers = Context.PlayerSettings.GetAllAsList(); List <PlayerSettings> nonSpectators = currentPlayers.FindAll(player => !player.SpectatorStatus.IsSpectator); List <DedimaniaPlayerInfo> playersToReport = new List <DedimaniaPlayerInfo>(); foreach (PlayerSettings playerSettings in nonSpectators) { playersToReport.Add(new DedimaniaPlayerInfo(playerSettings.Login, string.Empty, string.Empty, playerSettings.TeamID, playerSettings.SpectatorStatus.IsSpectator, playerSettings.LadderRanking, playerSettings.IsInOfficialMode)); } int playersCount = playersToReport.Count; int spectatorsCount = currentPlayers.Count - playersCount; DedimaniaServerInfo serverInfo = new DedimaniaServerInfo(serverOptions.Name, serverOptions.Comment, serverOptions.Password.Length > 0, string.Empty, 0, Context.ServerInfo.ServerXMLRpcPort, playersCount, serverOptions.CurrentMaxPlayers, spectatorsCount, serverOptions.CurrentMaxSpectators, serverOptions.CurrentLadderMode, string.Empty); DedimaniaCurrentChallengeReply currentChallengeReply = null; try { currentChallengeReply = DedimaniaClient.CurrentChallenge(currentChallenge.UId, currentChallenge.Name, currentChallenge.Environnement, currentChallenge.Author, Context.ServerInfo.Version.GetShortName(), (int)currentGameMode.Value, serverInfo, (int)DedimaniaSettings.MAX_RECORDS_TO_REPORT, playersToReport.ToArray()); IsDedimaniaResponsive = true; } catch (Exception ex) { Logger.ErrorToUI("Could not report current challenge: " + ex.Message); Logger.Error("Could not report current challenge: " + ex); IsDedimaniaResponsive = false; } if (currentChallengeReply != null) { FillRankingsFromDedimania(currentChallengeReply.Records, currentRankings); BestTime = Rankings.Length == 0 ? null : (uint?)Rankings[0].TimeOrScore; } else { Rankings = new DedimaniaRanking[] {}; BestTime = null; if (IsDedimaniaResponsive) { Logger.Debug("Error while calling CurrentChallenge!"); } } OnRankingsChanged(Rankings); }