### C# ScoreContextExtension Example Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Example of creating a Score object and a ScoreContextExtension for the 'NoMods' context. It shows how to add the extension to the score and then apply it to reflect context-specific values like rank and PP. This is useful for managing separate leaderboards based on different rulesets or modifiers. ```csharp using BeatLeader.Models; var score = new Score { Id = 123456, ValidContexts = LeaderboardContexts.General | LeaderboardContexts.NoMods, BaseScore = 1048576, Accuracy = 0.9542f, Pp = 385.4f, Rank = 5, ContextExtensions = new List() }; // Create NoMods context extension var noModsExtension = new ScoreContextExtension { Id = 789012, PlayerId = score.PlayerId, LeaderboardId = score.LeaderboardId, Context = LeaderboardContexts.NoMods, ScoreId = score.Id, Score = score, // Context-specific values (higher rank/pp without mods) Rank = 2, Pp = 412.5f, BaseScore = 1048576, ModifiedScore = 1048576, // No modifier bonus Accuracy = 0.9542f, Weight = 0.970f, Modifiers = "", // Empty for NoMods Timeset = 1702041000, Qualification = false, Banned = false }; score.ContextExtensions.Add(noModsExtension); // Apply context to score for API response score.ToContext(noModsExtension); // Now score reflects NoMods context: Rank=2, Pp=412.5, Modifiers="" ``` -------------------------------- ### Create and Parse Song Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Demonstrates how to instantiate the Song model with metadata and utility functions for parsing difficulty and mode names to their internal integer representations, and vice versa. Requires the BeatLeader.Models namespace. ```csharp using BeatLeader.Models; // Creating a song entry var song = new Song { Id = "2f4a", Hash = "A1B2C3D4E5F67890A1B2C3D4E5F67890A1B2C3D4", Name = "Epic Beat Track", SubName = "Extended Mix", Author = "Music Artist", Mapper = "MapperName", MapperId = 12345, CollaboratorIds = "67890,54321", CoverImage = "https://cdn.beatsaver.com/2f4a.jpg", FullCoverImage = "https://cdn.beatsaver.com/2f4a_full.jpg", DownloadUrl = "https://beatsaver.com/api/download/key/2f4a", Bpm = 140.0, Duration = 185.5, Tags = "tech,challenge,dancestyle", UploadTime = 1702000000, CreatedTime = "", Difficulties = new List(), Searches = new List(), Checked = false, Refreshed = false }; // Parse difficulty name to internal value int diffValue = Song.DiffForDiffName("ExpertPlus"); // Returns 9 // Parse mode name to internal value int modeValue = Song.ModeForModeName("Standard"); // Returns 1 // Convert difficulty value back to name string diffName = Song.DiffNameForDiff(9); // Returns "ExpertPlus" ``` -------------------------------- ### Create Clan Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Shows how to initialize a Clan object, including properties for clan identification, leader, description, statistics, and lists for associated leaderboards, players, requests, and banned users. Requires the BeatLeader.Models namespace. ```csharp using BeatLeader.Models; // Creating a clan var clan = new Clan { Id = 42, Name = "Elite Sabers", Tag = "ELIT", Color = "#FF6B35", Icon = "https://cdn.assets.beatleader.xyz/clans/42.png", LeaderID = "76561198055557818", Description = "Competitive Beat Saber clan", Bio = "We focus on technical maps and consistency", // Statistics PlayersCount = 25, Pp = 285420.5f, AverageRank = 542.3f, AverageAccuracy = 0.9342f, // Leaderboard captures CaptureLeaderboardsCount = 18, RankedPoolPercentCaptured = 0.0042f, CapturedLeaderboards = new List(), // Members and requests Players = new List(), Requests = new List(), Banned = new List() }; ``` -------------------------------- ### Create and Manipulate Player Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Demonstrates the creation of a Player model instance, including performance metrics, rankings, and profile customization. It also shows utility methods for sanitizing names, setting default avatars, and checking supporter status. This model is essential for representing player data within the BeatLeader ecosystem. ```csharp using BeatLeader.Models; // Creating a player instance var player = new Player { Id = "76561198055557818", Name = "PlayerOne", Platform = "steam", Country = "US", Role = "player", Avatar = "https://cdn.assets.beatleader.xyz/steamavatar.png", // Performance metrics Pp = 12450.5f, AccPp = 4200.0f, TechPp = 5100.0f, PassPp = 3150.5f, Rank = 142, CountryRank = 25, // Previous week stats LastWeekPp = 12200.0f, LastWeekRank = 150, LastWeekCountryRank = 28, Banned = false, Bot = false, Inactive = false, MapperId = 0, ClanOrder = "TAG1,TAG2", ExternalProfileUrl = "" }; // Sanitize player name (removes special wide characters) player.SanitizeName(); // Set default avatar based on platform player.SetDefaultAvatar(); // Check if player has supporter role bool isSupporter = player.AnySupporter(); ``` -------------------------------- ### Create and Update Score Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Illustrates the creation of a Score model, encompassing detailed gameplay metrics, performance points, accuracy breakdowns, and replay information. It also shows how to apply context extensions to a score, adjusting specific values for different game contexts. This model is crucial for recording and analyzing player performance. ```csharp using BeatLeader.Models; // Creating a score entry var score = new Score { Id = 1234567, PlayerId = "76561198055557818", LeaderboardId = "x123abc456def", // Score values BaseScore = 1048576, ModifiedScore = 1258291, Accuracy = 0.9542f, // Performance points Pp = 385.4f, AccPP = 190.2f, TechPP = 125.8f, PassPP = 69.4f, BonusPp = 15.2f, Weight = 0.965f, // Rankings Rank = 5, CountryRank = 2, // Gameplay details FullCombo = false, MaxCombo = 1024, MaxStreak = 512, BadCuts = 3, MissedNotes = 2, BombCuts = 0, WallsHit = 1, Pauses = 0, // Accuracy breakdown AccLeft = 114.5f, AccRight = 115.2f, FcAccuracy = 0.9621f, FcPp = 398.6f, // Equipment Hmd = HMD.Quest3, Controller = ControllerEnum.Quest3, Platform = "oculuspc", // Modifiers and replay Modifiers = "FS,SS", Replay = "https://cdn.replays.beatleader.xyz/replay123.bsor", // Timestamps Timeset = "2024-12-08T10:30:00Z", Timepost = 1702041000, // Context and flags ValidContexts = LeaderboardContexts.General | LeaderboardContexts.NoMods, Qualification = false, Banned = false, Suspicious = false, Bot = false, IgnoreForStats = false, // Required navigation properties Leaderboard = leaderboard, ContextExtensions = new List(), // Replay viewing stats AuthorizedReplayWatched = 45, AnonimusReplayWatched = 123, PlayCount = 1, Country = "US" }; // Apply context extension to score var contextExtension = new ScoreContextExtension { Context = LeaderboardContexts.NoMods, Rank = 3, Pp = 412.5f, Weight = 0.970f, // ... other context-specific values }; score.ToContext(contextExtension); ``` -------------------------------- ### LeaderboardContexts Enumeration - Work with Playstyle Contexts (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Defines and utilizes various leaderboard contexts for different playstyles, such as General, NoMods, NoPause, Golf, and SCPM. The code demonstrates how to check for specific contexts, iterate through all available contexts, and filter for non-general contexts. ```csharp using BeatLeader.Models; // Define score contexts LeaderboardContexts scoreContexts = LeaderboardContexts.General | LeaderboardContexts.NoMods | LeaderboardContexts.NoPause; // Check if specific context is included bool hasGeneral = (scoreContexts & LeaderboardContexts.General) != 0; // true bool hasGolf = (scoreContexts & LeaderboardContexts.Golf) != 0; // false // Iterate all available contexts foreach (var context in ContextExtensions.All) { if ((scoreContexts & context) != 0) { Console.WriteLine($"Score valid for: {context}"); } } // Get non-general contexts only foreach (var context in ContextExtensions.NonGeneral) { Console.WriteLine($"Non-general context: {context}"); } // Available contexts: // - General: Standard leaderboard // - NoMods: No gameplay modifiers allowed // - NoPause: No pausing during gameplay // - Golf: Lowest score wins // - SCPM: Score per minute metric focus ``` -------------------------------- ### Create Leaderboard Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Shows how to construct a Leaderboard model, which represents a specific song difficulty on the BeatLeader platform. It includes song and difficulty details, play statistics, voting data, qualification status, and clan-related information. This model is fundamental for displaying and managing leaderboards. ```csharp using BeatLeader.Models; // Creating a leaderboard var leaderboard = new Leaderboard { Id = "x123abc456def", SongId = "2f4a", Timestamp = 1702041000L, // Navigation properties Song = song, Difficulty = difficulty, Scores = new List(), ContextExtensions = new List(), // Play statistics Plays = 15420, PlayCount = 15420, // Voting data PositiveVotes = 324, NegativeVotes = 12, StarVotes = 298, VoteStars = 8.45f, // Ranking status Qualification = new RankQualification { Timeset = 1701000000, RTMember = "76561198055557818", CriteriaMet = 5, CriteriaTimeset = 1701086400 }, // Clan capture ClanId = 42, Clan = clan, ClanRankingContested = false }; ``` -------------------------------- ### Create DifficultyDescription Model in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Illustrates the creation of a DifficultyDescription object, detailing various attributes like difficulty names, ranking status, rating components, map characteristics, modifier support, and requirements. Requires the BeatLeader.Models namespace. ```csharp using BeatLeader.Models; // Creating a difficulty description var difficulty = new DifficultyDescription { Id = 98765, DifficultyName = "ExpertPlus", ModeName = "Standard", Value = 9, Mode = 1, // Ranking status Status = DifficultyStatus.ranked, NominatedTime = 1701000000, QualifiedTime = 1701500000, RankedTime = 1702000000, // Rating components Stars = 9.45f, PredictedAcc = 0.925f, PassRating = 7.2f, AccRating = 8.8f, TechRating = 9.1f, Type = 1, // Map characteristics Njs = 23.0f, Nps = 8.5f, Notes = 1542, Bombs = 28, Walls = 45, MaxScore = 1572860, Duration = 185.5, // Modifiers support ModifierValues = new ModifiersMap { FS = 0.0f, SS = 0.0f, SF = 0.5f, GN = -0.3f }, ModifiersRating = new ModifiersRating { FsPredictedAcc = 0.895f, SsPredictedAcc = 0.905f, SfPassRating = 8.1f }, // Requirements Requirements = Requirements.Chroma | Requirements.MappingExtensions }; ``` -------------------------------- ### Convert Player to PlayerResponse (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Converts a full Player entity into a lightweight PlayerResponse format, suitable for general display where extensive details are not required. This function prioritizes essential player information and orders clans according to the player's specified preference. It returns a nullable PlayerResponse, handling cases where the input player might be null. ```csharp using BeatLeader.Utils; var player = new Player { Id = "76561198055557818", Name = "PlayerOne", Platform = "steam", Avatar = "avatar.jpg", Country = "US", Pp = 12450.5f, Rank = 142, CountryRank = 25, Role = "player,supporter", ClanOrder = "ELIT,TEST", Clans = new List { new Clan { Id = 42, Tag = "ELIT", Color = "#FF6B35" }, new Clan { Id = 99, Tag = "TEST", Color = "#00FF00" } } }; PlayerResponse? response = ResponseUtils.ResponseFromPLayer(player); // Returns null if player is null // Clans ordered by player's ClanOrder preference, then by ID // Output: [ELIT, TEST] in that specific order ``` -------------------------------- ### DiffModResponseFromDiffAndVotes - Create Difficulty Response with Vote Data (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Creates a DiffModResponse object from a DifficultyDescription and an array of community votes. The response includes difficulty and mode names, star ratings, status, all rating components, modifier values, and the raw vote data. ```csharp using BeatLeader.Utils; var difficulty = new DifficultyDescription { DifficultyName = "ExpertPlus", ModeName = "Standard", Stars = 9.45f, Status = DifficultyStatus.ranked, Type = 1, PassRating = 7.2f, AccRating = 8.8f, TechRating = 9.1f, ModifierValues = new ModifiersMap(), ModifiersRating = new ModifiersRating() }; float[] votes = new float[] { 9.0f, 9.5f, 8.5f, 10.0f, 9.2f }; DiffModResponse response = ResponseUtils.DiffModResponseFromDiffAndVotes(difficulty, votes); // Response contains: // - Difficulty and mode names // - Star rating and status // - All rating components (Pass, Acc, Tech) // - Modifier values and ratings // - Vote array for community star rating submissions ``` -------------------------------- ### PostProcessSettings - Sanitize Profile Settings (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Applies role-based restrictions to player profile settings and features, sanitizing data like starred friends, profile appearance, effect names, custom messages, and saber colors based on the player's role. It ensures privacy and enforces feature access levels. ```csharp using BeatLeader.Utils; var player = new PlayerResponse { Id = "76561198055557818", Role = "player,supporter", ProfileSettings = new ProfileSettings { EffectName = "Tier2Flame", Message = "Custom profile message", StarredFriends = "friend1,friend2,friend3", ProfileAppearance = "topPp,topPlatform", LeftSaberColor = "#FF0000", RightSaberColor = "#0000FF" }, PatreonFeatures = new PatreonFeatures { Message = "Patreon supporter!" } }; PlayerResponse? processed = ResponseUtils.PostProcessSettings(player); // Effects applied: // - StarredFriends cleared for privacy // - ProfileAppearance default set if null: "topPp,averageRankedAccuracy,topPlatform,topHMD" // - EffectName validated against role (Tier2 requires supporter+) // - Custom messages kept for sponsor role only // - Saber colors kept for supporters, cleared otherwise // Role hierarchy for effects: // - Special: creator, rankedteam, qualityteam, juniorrankedteam, admin // - Tier1: tipper, supporter, sponsor, booster (+ Special roles) // - Tier2: supporter, sponsor (+ Special roles) // - Tier3: sponsor (+ Special roles) ``` -------------------------------- ### Transform Player to PlayerResponseFull (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Transforms a Player entity into a comprehensive PlayerResponseFull format, including detailed statistics, historical data, and account status. This response type is used when a complete player profile is needed. It encompasses all fields from PlayerResponse plus extended statistics like AccPp, TechPp, PassPp, historical performance, badges, and account flags. ```csharp using BeatLeader.Utils; var player = new Player { Id = "76561198055557818", Name = "PlayerOne", Pp = 12450.5f, AccPp = 4200.0f, TechPp = 5100.0f, PassPp = 3150.5f, Rank = 142, CountryRank = 25, LastWeekPp = 12200.0f, LastWeekRank = 150, Banned = false, Inactive = false, Bot = false, MapperId = 12345, ExternalProfileUrl = "https://external.profile.url", History = new List(), Badges = new List(), Changes = new List(), ScoreStats = new PlayerScoreStats(), ContextExtensions = new List(), // ... other properties }; PlayerResponseFull fullResponse = ResponseUtils.ResponseFullFromPlayer(player); // Includes all base PlayerResponse fields plus: // - Full statistics breakdown (AccPp, TechPp, PassPp) // - Historical rank/pp data // - Badges and achievements // - Account status (Banned, Inactive, Bot) // - Mapper ID and external profile links // - Profile change history ``` -------------------------------- ### ScoreWithMyScore - Transform Score to ScoreResponseWithMyScore (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Transforms a Score object into a comprehensive ScoreResponseWithMyScore, including detailed leaderboard context. This response contains all score metrics, full leaderboard and song details, valid context flags, and complete difficulty information. ```csharp using BeatLeader.Utils; var score = new Score { Id = 123456, ValidContexts = LeaderboardContexts.General | LeaderboardContexts.NoMods | LeaderboardContexts.NoPause, AccLeft = 114.5f, AccRight = 115.2f, Leaderboard = leaderboard, // Full leaderboard with Song and Difficulty // ... other properties }; ScoreResponseWithMyScore response = ResponseUtils.ScoreWithMyScore(score, 0); // Returns extended response with: // - All score metrics including AccLeft/AccRight // - Full LeaderboardResponse with Song and Difficulty details // - ValidContexts flags showing which leaderboard contexts apply // - Embedded PlayerResponse without ContextExtensions (not included in this conversion) // - Complete difficulty information (Stars, ratings, NJS, NPS, etc.) ``` -------------------------------- ### Convert ScoreContextExtension to ScoreResponse (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Transforms a context-specific score extension (ScoreContextExtension) into a standard ScoreResponse format. This utility merges data from the extension, such as rank, PP, and accuracy for a specific context (e.g., NoMods), with the base score details. It uses the timeset from the extension and requires both the extension object and an integer for accuracy scaling. ```csharp using BeatLeader.Utils; var scoreExtension = new ScoreContextExtension { Id = 789012, Context = LeaderboardContexts.NoMods, PlayerId = "76561198055557818", LeaderboardId = "x123abc", BaseScore = 1048576, ModifiedScore = 1258291, Accuracy = 0.9542f, Pp = 412.5f, Rank = 3, Weight = 0.970f, Modifiers = "SS", Score = score, // Reference to base score with full details Player = player }; ScoreResponse response = ResponseUtils.RemoveLeaderboardCE(scoreExtension, 0); // Merges context-specific values (Rank, Pp, Accuracy) with base score details // Uses context extension's timepost (Timeset property) instead of score's Timepost ``` -------------------------------- ### Convert Leaderboard to LeaderboardResponse (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Converts a Leaderboard entity into a LeaderboardResponse format, which includes filtered scores and relevant metadata. This function processes all associated scores using the RemoveLeaderboard method and extracts key information about the leaderboard group, such as status and timestamp. The output provides a clean representation of the leaderboard, song, and difficulty details. ```csharp using BeatLeader.Utils; var leaderboard = new Leaderboard { Id = "x123abc456def", Song = song, Difficulty = difficulty, Plays = 15420, Scores = scores, // List Qualification = new RankQualification { Timeset = 1701000000 }, Reweight = null, Changes = new List(), LeaderboardGroup = new LeaderboardGroup { Leaderboards = new List { new Leaderboard { Id = "x123abc", Difficulty = new DifficultyDescription { Status = DifficultyStatus.ranked }, Timestamp = 1702000000L } } } }; LeaderboardResponse response = ResponseUtils.ResponseFromLeaderboard(leaderboard); // Converts all scores using RemoveLeaderboard() // Extracts leaderboard group entries with status and timestamp // Returns complete leaderboard with: // - Song metadata // - DifficultyResponse with all ratings // - Converted scores without circular references // - Qualification/reweight status ``` -------------------------------- ### Transform Score to ScoreResponseWithAcc (C#) Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Converts a Score object into a ScoreResponseWithAcc format, adding detailed left and right hand accuracy breakdowns. This function is useful for displaying granular accuracy metrics to players. It takes a Score object and an integer representing accuracy (likely a scale factor or precision) as input. ```csharp using BeatLeader.Utils; var score = new Score { Id = 123456, AccLeft = 114.5f, AccRight = 115.2f, Accuracy = 0.9542f, // ... other score properties }; ScoreResponseWithAcc response = ResponseUtils.ToScoreResponseWithAcc(score, 0); // Response includes all ScoreResponse fields plus: // - AccLeft: 114.5 // - AccRight: 115.2 ``` -------------------------------- ### Transform Score to ScoreResponse in C# Source: https://context7.com/beatleader/beatleader-server-models/llms.txt Utilizes the ResponseUtils.RemoveLeaderboard method to convert a Score object into a ScoreResponse format, excluding embedded leaderboard data and consolidating replay watch counts. Requires BeatLeader.Utils and BeatLeader.Models namespaces. ```csharp using BeatLeader.Utils; using BeatLeader.Models; var score = new Score { Id = 123456, PlayerId = "76561198055557818", BaseScore = 1048576, ModifiedScore = 1258291, Accuracy = 0.9542f, Pp = 385.4f, Rank = 5, Timeset = "2024-12-08T10:30:00Z", Replay = "https://cdn.replays.beatleader.xyz/replay123.bsor", Modifiers = "FS,SS", Player = new Player { Id = "76561198055557818", Name = "PlayerOne", Country = "US", Pp = 12450.5f, Rank = 142, CountryRank = 25, Role = "player", Platform = "steam", Avatar = "avatar.jpg" }, AnonimusReplayWatched = 123, AuthorizedReplayWatched = 45 // ... other properties }; // Convert to response format ScoreResponse response = ResponseUtils.RemoveLeaderboard(score, 0); // Response now contains: // - All score metrics (Pp, Accuracy, Rank, etc.) // - Embedded PlayerResponse with clan info ordered by player preference // - Combined replay watch count (168 = 123 + 45) // - Null-safe string fields with default empty strings ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.