Ejemplo n.º 1
0
        /// <summary>
        /// Adds a gameplayModifier to our list, getting rid of any incompatible mods that are currently in there.
        /// </summary>
        public static void AddMod(ModIdentifier modIdentifier)
        {
            IGameplayModifier gameplayModifier;

            // Set the newMod based on the ModType that is coming in
            switch (modIdentifier)
            {
            case ModIdentifier.Autoplay:
                gameplayModifier = new ModAutoplay();
                break;

            default:
                return;
            }

            // Remove incompatible mods.
            var incompatibleMods = CurrentModifiersList.FindAll(x => x.IncompatibleMods.Contains(gameplayModifier.ModIdentifier));

            incompatibleMods.ForEach(x => RemoveMod(x.ModIdentifier));

            // Remove the mod if it's already on.
            var alreadyOnMod = CurrentModifiersList.Find(x => x.ModIdentifier == gameplayModifier.ModIdentifier);

            if (alreadyOnMod != null)
            {
                CurrentModifiersList.Remove(alreadyOnMod);
            }

            // Add The Mod
            CurrentModifiersList.Add(gameplayModifier);
            gameplayModifier.InitializeMod();

            ModsChanged?.Invoke(typeof(ModManager), new ModsChangedEventArgs(Mods));
            Logger.Log($"Added mod: {gameplayModifier.ModIdentifier}.", LogLevel.Info);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Ctor -
        /// </summary>
        /// <param name="map"></param>
        /// <param name="mods"></param>
        public ScoreProcessor(Qua map, ModIdentifier mods)
        {
            Map   = map;
            Mods  = mods;
            Stats = new List <HitStat>();

            InitializeMods();
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Ctor -
 ///     Create fresh replay
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="name"></param>
 /// <param name="mods"></param>
 /// <param name="md5"></param>
 public Replay(GameMode mode, string name, ModIdentifier mods, string md5)
 {
     PlayerName = name;
     Mode       = mode;
     Mods       = mods;
     MapMd5     = md5;
     Frames     = new List <ReplayFrame>();
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Ctor -
        /// </summary>
        /// <param name="map"></param>
        /// <param name="mods"></param>
        /// <param name="windows"></param>
        public ScoreProcessor(Qua map, ModIdentifier mods, JudgementWindows windows = null)
        {
            Map   = map;
            Mods  = mods;
            Stats = new List <HitStat>();

            InitializeJudgementWindows(windows);
            InitializeMods();
        }
 public void Set(UninstallModOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = ModsInterface.UninstallmodApiLatest;
         LocalUserId  = other.LocalUserId;
         Mod          = other.Mod;
     }
 }
Ejemplo n.º 6
0
        public void CanParseModIdentifier()
        {
            var id = new ModIdentifier("my-org", "my-mod", "1.0.0");

            Assert.True(id.Validate());

            Assert.Equal("my-org", id.OwnerSlug);
            Assert.Equal("my-mod", id.ModSlug);
            Assert.Equal("1.0.0", id.Version);
        }
 internal void Set(UninstallModCallbackInfoInternal?other)
 {
     if (other != null)
     {
         ResultCode  = other.Value.ResultCode;
         LocalUserId = other.Value.LocalUserId;
         ClientData  = other.Value.ClientData;
         Mod         = other.Value.Mod;
     }
 }
Ejemplo n.º 8
0
 public void Set(ModIdentifier other)
 {
     if (other != null)
     {
         m_ApiVersion = ModsInterface.ModIdentifierApiLatest;
         NamespaceId  = other.NamespaceId;
         ItemId       = other.ItemId;
         ArtifactId   = other.ArtifactId;
         Title        = other.Title;
         Version      = other.Version;
     }
 }
Ejemplo n.º 9
0
        private async Task <Stream> GetModImportStream(ModIdentifier packageId)
        {
            var allMods = await _client.ModListClient.GetModsAsync(null, null);

            var foundMod     = allMods.SingleOrDefault(m => m.Owner.Slug == packageId.OwnerSlug && m.Slug == packageId.ModSlug);
            var foundVersion = foundMod?.Versions.SingleOrDefault(v => v.VersionNumber == packageId.Version);

            if (foundVersion == null)
            {
                return(null);
            }
            return(await _client.HttpClient.GetStreamAsync(foundVersion.FileUrl));
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Solves the difficulty of the map and returns the data for it.
        /// </summary>
        /// <param name="mods"></param>
        /// <returns></returns>
        public DifficultyProcessor SolveDifficulty(ModIdentifier mods = ModIdentifier.None)
        {
            switch (Mode)
            {
            case GameMode.Keys4:
                return(new DifficultyProcessorKeys(this, new StrainConstantsKeys(), mods));

            case GameMode.Keys7:
                return(new DifficultyProcessorKeys(this, new StrainConstantsKeys(), mods));

            default:
                throw new InvalidEnumArgumentException();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// </summary>
        /// <param name="args"></param>
        public CalcDiffCommand(string[] args) : base(args)
        {
            var path = args[1];

            if (path.EndsWith(".qua"))
            {
                Map = Qua.Parse(path);
            }
            else if (path.EndsWith(".osu"))
            {
                Map = new OsuBeatmap(path).ToQua();
            }

            Mods = (ModIdentifier)Enum.Parse(typeof(ModIdentifier), args[2]);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Removes a gameplayModifier from our GameBase
        /// </summary>
        public static void RemoveMod(ModIdentifier modIdentifier)
        {
            try
            {
                // Try to find the removed gameplayModifier in the list
                var removedMod = CurrentModifiersList.Find(x => x.ModIdentifier == modIdentifier);

                // Remove the Mod
                CurrentModifiersList.Remove(removedMod);

                ModsChanged?.Invoke(typeof(ModManager), new ModsChangedEventArgs(Mods));
                Logger.Log($"Removed mod: {removedMod.ModIdentifier}.", LogLevel.Info);
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
        }
        /// <summary>
        ///     Solves the difficulty of a .qua file
        /// </summary>
        /// <param name="map"></param>
        /// <param name="constants"></param>
        /// <param name="mods"></param>
        /// <param name="detailedSolve"></param>
        public DifficultyProcessorKeys(Qua map, StrainConstants constants, ModIdentifier mods = ModIdentifier.None, bool detailedSolve = false) : base(map, constants, mods)
        {
            // Cast the current Strain Constants Property to the correct type.
            StrainConstants = (StrainConstantsKeys)constants;

            // Don't bother calculating map difficulty if there's less than 2 hit objects
            if (map.HitObjects.Count < 2)
            {
                return;
            }

            // Solve for difficulty
            CalculateDifficulty(mods);

            // If detailed solving is enabled, expand calculation
            if (detailedSolve)
            {
                // ComputeNoteDensityData();
                ComputeForPatternFlags();
            }
        }
        /// <summary>
        ///     Calculate difficulty of a map with given rate
        /// </summary>
        /// <param name="rate"></param>
        public void CalculateDifficulty(ModIdentifier mods)
        {
            // If map does not exist, ignore calculation.
            if (Map == null)
            {
                return;
            }

            // Get song rate from selected mods
            var rate = ModHelper.GetRateFromMods(mods);

            // Compute for overall difficulty
            switch (Map.Mode)
            {
            case (GameMode.Keys4):
                OverallDifficulty = ComputeForOverallDifficulty(rate);
                break;

            case (GameMode.Keys7):
                OverallDifficulty = (ComputeForOverallDifficulty(rate, Hand.Left) + ComputeForOverallDifficulty(rate, Hand.Right)) / 2;
                break;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Adds all modifiers from a mod enum combo
        /// </summary>
        public static void AddModsFromIdentifiers(ModIdentifier mods)
        {
            // Remove all the current mods that we have on.
            ModManager.RemoveAllMods();

            for (var i = 0; i <= Math.Log((long)mods, 2); i++)
            {
                var mod = (ModIdentifier)((long)Math.Pow(2, i));

                if (!mods.HasFlag(mod))
                {
                    continue;
                }

                try
                {
                    ModManager.AddMod(mod);
                }
                catch (Exception e)
                {
                    Logger.Error(e, LogType.Runtime);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Applies mods to the map.
        /// </summary>
        /// <param name="mods">a list of mods to apply</param>
        public void ApplyMods(ModIdentifier mods)
        {
            if (mods.HasFlag(ModIdentifier.NoLongNotes))
            {
                ReplaceLongNotesWithRegularNotes();
            }

            if (mods.HasFlag(ModIdentifier.Inverse))
            {
                ApplyInverse();
            }

            // FullLN is NLN followed by Inverse.
            if (mods.HasFlag(ModIdentifier.FullLN))
            {
                ReplaceLongNotesWithRegularNotes();
                ApplyInverse();
            }

            if (mods.HasFlag(ModIdentifier.Mirror))
            {
                MirrorHitObjects();
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Checks if a gameplayModifier is currently activated.
 /// </summary>
 /// <param name="modIdentifier"></param>
 /// <returns></returns>
 public static bool IsActivated(ModIdentifier modIdentifier) => CurrentModifiersList.Exists(x => x.ModIdentifier == modIdentifier);
Ejemplo n.º 18
0
 /// <summary>
 ///     For multiplayer
 /// </summary>
 /// <param name="map"></param>
 /// <param name="mods"></param>
 /// <param name="multiplayerProcessor"></param>
 public ScoreProcessor(Qua map, ModIdentifier mods, ScoreProcessorMultiplayer multiplayerProcessor) : this(map, mods)
 {
     MultiplayerProcessor           = multiplayerProcessor;
     MultiplayerProcessor.Processor = this;
 }
Ejemplo n.º 19
0
        /// <inheritdoc />
        /// <summary>
        ///     Ctor
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="type"></param>
        /// <param name="username"></param>
        /// <param name="judgements"></param>
        /// <param name="avatar"></param>
        /// <param name="mods"></param>
        /// <param name="score"></param>
        /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException"></exception>
        internal ScoreboardUser(GameplayScreen screen, ScoreboardUserType type, string username, List <Judgement> judgements, Texture2D avatar, ModIdentifier mods, Score score = null)
        {
            Screen          = screen;
            LocalScore      = score;
            Judgements      = judgements;
            UsernameRaw     = username;
            RatingProcessor = new RatingProcessorKeys(MapManager.Selected.Value.DifficultyFromMods(mods));
            Type            = type;
            Size            = new ScalableVector2(260, 50);

            // Set position initially to offscreen
            X = -Width - 10;

            // The alpha of the tect - determined by the scoreboard user type.
            float textAlpha;

            // Set props based on the type of scoreboard user this is.
            switch (Type)
            {
            case ScoreboardUserType.Self:
                Image     = SkinManager.Skin.Scoreboard;
                Alpha     = 1f;
                textAlpha = 1f;
                break;

            case ScoreboardUserType.Other:
                Image     = SkinManager.Skin.ScoreboardOther;
                Alpha     = 0.75f;
                textAlpha = 0.65f;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (Screen.Map.Mode)
            {
            case GameMode.Keys4:
            case GameMode.Keys7:
                Processor = Type == ScoreboardUserType.Other ? new ScoreProcessorKeys(Screen.Map, mods) : Screen.Ruleset.ScoreProcessor;
                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            // Create avatar
            Avatar = new Sprite()
            {
                Parent    = this,
                Size      = new ScalableVector2(Height, Height),
                Alignment = Alignment.MidLeft,
                Image     = avatar,
            };

            if (Type != ScoreboardUserType.Self)
            {
                if (LocalScore != null && LocalScore.IsOnline)
                {
                    // Check to see if we have a Steam avatar for this user cached.
                    if (SteamManager.UserAvatars.ContainsKey((ulong)LocalScore.SteamId))
                    {
                        Avatar.Image = SteamManager.UserAvatars[(ulong)LocalScore.SteamId];
                    }
                    else
                    {
                        Avatar.Alpha = 0;
                        Avatar.Image = UserInterface.UnknownAvatar;

                        // Otherwise we need to request for it.
                        SteamManager.SteamUserAvatarLoaded += OnAvatarLoaded;
                        SteamManager.SendAvatarRetrievalRequest((ulong)LocalScore.SteamId);
                    }
                }
                else
                {
                    Avatar.Image = UserInterface.UnknownAvatar;
                }
            }

            // Create username text.
            Username = new SpriteText(Fonts.Exo2Bold, GetUsernameFormatted(), 13)
            {
                Parent    = this,
                Alignment = Alignment.TopLeft,
                Alpha     = textAlpha,
                X         = Avatar.Width + 10,
            };

            // Create score text.
            Score = new SpriteTextBitmap(FontsBitmap.AllerRegular, "0.00")
            {
                Parent    = this,
                Alignment = Alignment.TopLeft,
                Alpha     = textAlpha,
                Y         = Username.Y + Username.Height + 2,
                X         = Username.X,
                FontSize  = 18
            };

            // Create score text.
            Combo = new SpriteTextBitmap(FontsBitmap.AllerRegular, $"{Processor.Combo:N0}x")
            {
                Parent    = this,
                Alignment = Alignment.MidRight,
                Alpha     = textAlpha,
                FontSize  = 18,
                X         = -5
            };
        }
Ejemplo n.º 20
0
 /// <summary>
 ///     For multiplayer
 /// </summary>
 /// <param name="map"></param>
 /// <param name="mods"></param>
 /// <param name="multiplayerProcessor"></param>
 /// <param name="windows"></param>
 public ScoreProcessor(Qua map, ModIdentifier mods, ScoreProcessorMultiplayer multiplayerProcessor, JudgementWindows windows = null)
     : this(map, mods, windows)
 {
     MultiplayerProcessor           = multiplayerProcessor;
     MultiplayerProcessor.Processor = this;
 }
Ejemplo n.º 21
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="map"></param>
 public DifficultyProcessor(Qua map, StrainConstants constants, ModIdentifier mods = ModIdentifier.None) => Map = map;
Ejemplo n.º 22
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="map"></param>
 /// <param name="mods"></param>
 /// <param name="multiplayer"></param>
 /// <param name="windows"></param>
 public ScoreProcessorKeys(Qua map, ModIdentifier mods, ScoreProcessorMultiplayer multiplayer, JudgementWindows windows = null) : base(map, mods, multiplayer, windows)
 {
     TotalJudgements = GetTotalJudgementCount();
     SummedScore     = CalculateSummedScore();
     InitializeHealthWeighting();
 }
Ejemplo n.º 23
0
 public ModsChangedEventArgs(ModIdentifier mods) => Mods = mods;
Ejemplo n.º 24
0
 /// <summary>
 /// </summary>
 /// <param name="args"></param>
 public CalcFolderCommand(string[] args) : base(args)
 {
     BaseFolder = args[1];
     Mods       = (ModIdentifier)Enum.Parse(typeof(ModIdentifier), args[2]);
 }
Ejemplo n.º 25
0
        /// <summary>
        ///     Closes the dialog.
        /// </summary>
        public void Close(bool changeMods = true)
        {
            if (isClosing)
            {
                return;
            }

            if (OnlineManager.CurrentGame != null && changeMods)
            {
                if (ModsWhenDialogOpen != ModManager.Mods)
                {
                    var diffRating = OnlineManager.CurrentGame.DifficultyRating;

                    // Only update the difficulty rating when closing if the selected map is still the same.
                    // If the user switches maps, but changes modifiers, it'll be incorrect.
                    if (MapManager.Selected.Value != null && MapManager.Selected.Value.Md5Checksum == OnlineManager.CurrentGame.MapMd5)
                    {
                        diffRating = MapManager.Selected.Value.DifficultyFromMods(ModManager.Mods);
                    }

                    var rateNow = ModHelper.GetRateFromMods(ModManager.Mods);

                    // Change the global mods of the game
                    var rateMod = (long)ModHelper.GetModsFromRate(rateNow);

                    if (rateMod == -1)
                    {
                        rateMod = 0;
                    }

                    var           activeModsWithoutRate  = (long)ModManager.Mods - rateMod;
                    ModIdentifier hostOnlyMods           = 0L;
                    var           onlyHostChangeableMods = ModManager.CurrentModifiersList.FindAll(x => x.OnlyMultiplayerHostCanCanChange);

                    if (onlyHostChangeableMods.Count != 0)
                    {
                        onlyHostChangeableMods.ForEach(x =>
                        {
                            // ReSharper disable once AccessToModifiedClosure
                            activeModsWithoutRate -= (long)x.ModIdentifier;
                            hostOnlyMods          |= x.ModIdentifier;
                        });
                    }

                    if (activeModsWithoutRate == -1)
                    {
                        activeModsWithoutRate = 0;
                    }

                    // If we're on regular free mod mode, when we change the rate,
                    // ReSharper disable once CompareOfFloatsByEqualityOperator
                    if (OnlineManager.CurrentGame.FreeModType == MultiplayerFreeModType.Regular &&
                        (ModHelper.GetRateFromMods(ModsWhenDialogOpen) != rateNow || hostOnlyMods != 0) &&
                        OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                    {
                        OnlineManager.Client?.MultiplayerChangeGameModifiers(rateMod + (long)hostOnlyMods, diffRating);

                        // Change the mods of ourselves minus the mods rate (gets all other activated modes)
                        OnlineManager.Client?.MultiplayerChangePlayerModifiers(activeModsWithoutRate);
                    }
                    // Free mod is enabled, but we haven't done any rate changing, so just
                    // enable player modifiers for us
                    else if (OnlineManager.CurrentGame.FreeModType != MultiplayerFreeModType.None)
                    {
                        // Free Mod + Free Rate
                        if (OnlineManager.CurrentGame.FreeModType.HasFlag(MultiplayerFreeModType.Regular) &&
                            OnlineManager.CurrentGame.FreeModType.HasFlag(MultiplayerFreeModType.Rate))
                        {
                            if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                            {
                                OnlineManager.Client?.MultiplayerChangeGameModifiers((long)hostOnlyMods, diffRating);
                            }

                            OnlineManager.Client?.MultiplayerChangePlayerModifiers((long)ModManager.Mods);
                        }
                        // Either Free Mod OR Free Rate
                        else
                        {
                            switch (OnlineManager.CurrentGame.FreeModType)
                            {
                            case MultiplayerFreeModType.Regular:
                                OnlineManager.Client?.MultiplayerChangePlayerModifiers(activeModsWithoutRate);

                                if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                                {
                                    OnlineManager.Client?.MultiplayerChangeGameModifiers(rateMod + (long)hostOnlyMods, diffRating);
                                }
                                break;

                            case MultiplayerFreeModType.Rate:
                                OnlineManager.Client?.MultiplayerChangePlayerModifiers((long)ModHelper.GetModsFromRate(rateNow));

                                if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                                {
                                    OnlineManager.Client?.MultiplayerChangeGameModifiers(activeModsWithoutRate + (long)hostOnlyMods, diffRating);
                                }
                                break;
                            }
                        }
                    }
                    // We're host & free mod isn't enabled, so change the global game mods
                    else if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                    {
                        OnlineManager.Client?.MultiplayerChangeGameModifiers((long)ModManager.Mods, diffRating);
                    }
                }
            }

            isClosing = true;
            InterfaceContainer.Animations.Clear();
            InterfaceContainer.Animations.Add(new Animation(AnimationProperty.Y, Easing.OutQuint, InterfaceContainer.Y, InterfaceContainer.Height, 600));
            ThreadScheduler.RunAfter(() => DialogManager.Dismiss(this), 450);
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Gets the audio rate from selected mods.
        /// </summary>
        /// <param name="mods"></param>
        /// <returns></returns>
        public static float GetRateFromMods(ModIdentifier mods)
        {
            // The rate of the audio.
            var rate = 1.0f;

            // Map mods to rate.
            if (mods.HasFlag(ModIdentifier.None))
            {
                rate = 1.0f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed05X))
            {
                rate = 0.5f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed055X))
            {
                rate = 0.55f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed06X))
            {
                rate = 0.6f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed065X))
            {
                rate = 0.65f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed07X))
            {
                rate = 0.7f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed075X))
            {
                rate = 0.75f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed08X))
            {
                rate = 0.8f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed085X))
            {
                rate = 0.85f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed09X))
            {
                rate = 0.9f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed095X))
            {
                rate = 0.95f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed11X))
            {
                rate = 1.1f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed12X))
            {
                rate = 1.2f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed13X))
            {
                rate = 1.3f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed14X))
            {
                rate = 1.4f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed15X))
            {
                rate = 1.5f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed16X))
            {
                rate = 1.6f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed17X))
            {
                rate = 1.7f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed18X))
            {
                rate = 1.8f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed19X))
            {
                rate = 1.9f;
            }
            else if (mods.HasFlag(ModIdentifier.Speed20X))
            {
                rate = 2.0f;
            }

            return(rate);
        }
Ejemplo n.º 27
0
 public double DifficultyFromMods(ModIdentifier mods)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 28
0
Archivo: Map.cs Proyecto: AiAe/Quaver-1
        /// <summary>
        ///     Retrieve the map's difficulty rating from given mods
        /// </summary>
        /// <returns></returns>
        public double DifficultyFromMods(ModIdentifier mods)
        {
            if (mods.HasFlag(ModIdentifier.Speed05X))
            {
                return(Difficulty05X);
            }
            if (mods.HasFlag(ModIdentifier.Speed055X))
            {
                return(Difficulty055X);
            }
            if (mods.HasFlag(ModIdentifier.Speed06X))
            {
                return(Difficulty06X);
            }
            if (mods.HasFlag(ModIdentifier.Speed065X))
            {
                return(Difficulty065X);
            }
            if (mods.HasFlag(ModIdentifier.Speed07X))
            {
                return(Difficulty07X);
            }
            if (mods.HasFlag(ModIdentifier.Speed075X))
            {
                return(Difficulty075X);
            }
            if (mods.HasFlag(ModIdentifier.Speed08X))
            {
                return(Difficulty08X);
            }
            if (mods.HasFlag(ModIdentifier.Speed085X))
            {
                return(Difficulty085X);
            }
            if (mods.HasFlag(ModIdentifier.Speed09X))
            {
                return(Difficulty09X);
            }
            if (mods.HasFlag(ModIdentifier.Speed095X))
            {
                return(Difficulty095X);
            }
            if (mods.HasFlag(ModIdentifier.Speed11X))
            {
                return(Difficulty11X);
            }
            if (mods.HasFlag(ModIdentifier.Speed12X))
            {
                return(Difficulty12X);
            }
            if (mods.HasFlag(ModIdentifier.Speed13X))
            {
                return(Difficulty13X);
            }
            if (mods.HasFlag(ModIdentifier.Speed14X))
            {
                return(Difficulty14X);
            }
            if (mods.HasFlag(ModIdentifier.Speed15X))
            {
                return(Difficulty15X);
            }
            if (mods.HasFlag(ModIdentifier.Speed16X))
            {
                return(Difficulty16X);
            }
            if (mods.HasFlag(ModIdentifier.Speed17X))
            {
                return(Difficulty17X);
            }
            if (mods.HasFlag(ModIdentifier.Speed18X))
            {
                return(Difficulty18X);
            }
            if (mods.HasFlag(ModIdentifier.Speed19X))
            {
                return(Difficulty19X);
            }
            if (mods.HasFlag(ModIdentifier.Speed20X))
            {
                return(Difficulty20X);
            }

            return(Difficulty10X);
        }
Ejemplo n.º 29
0
        /// <summary>
        ///     Adds a gameplayModifier to our list, getting rid of any incompatible mods that are currently in there.
        ///     Also, specifying a speed, if need-be. That is only "required" if passing in ModIdentifier.ManiaModSpeed
        /// </summary>
        public static void AddMod(ModIdentifier modIdentifier)
        {
            IGameplayModifier gameplayModifier;

            // Set the newMod based on the ModType that is coming in
            switch (modIdentifier)
            {
            case ModIdentifier.Speed05X:
            case ModIdentifier.Speed06X:
            case ModIdentifier.Speed07X:
            case ModIdentifier.Speed08X:
            case ModIdentifier.Speed09X:
            case ModIdentifier.Speed11X:
            case ModIdentifier.Speed12X:
            case ModIdentifier.Speed13X:
            case ModIdentifier.Speed14X:
            case ModIdentifier.Speed15X:
            case ModIdentifier.Speed16X:
            case ModIdentifier.Speed17X:
            case ModIdentifier.Speed18X:
            case ModIdentifier.Speed19X:
            case ModIdentifier.Speed20X:
                gameplayModifier = new ModSpeed(modIdentifier);
                break;

            case ModIdentifier.NoSliderVelocity:
                gameplayModifier = new ModNoSliderVelocities();
                break;

            case ModIdentifier.Strict:
                gameplayModifier = new ModStrict();
                break;

            case ModIdentifier.Chill:
                gameplayModifier = new ModChill();
                break;

            case ModIdentifier.Autoplay:
                gameplayModifier = new ModAutoplay();
                break;

            case ModIdentifier.Paused:
                gameplayModifier = new ModPaused();
                break;

            case ModIdentifier.NoFail:
                gameplayModifier = new ModNoFail();
                break;

            case ModIdentifier.NoLongNotes:
                gameplayModifier = new ModNoLongNotes();
                break;

            default:
                return;
            }

            // Remove incompatible mods.
            var incompatibleMods = CurrentModifiersList.FindAll(x => x.IncompatibleMods.Contains(gameplayModifier.ModIdentifier));

            incompatibleMods.ForEach(x => RemoveMod(x.ModIdentifier));

            // Remove the mod if it's already on.
            var alreadyOnMod = CurrentModifiersList.Find(x => x.ModIdentifier == gameplayModifier.ModIdentifier);

            if (alreadyOnMod != null)
            {
                CurrentModifiersList.Remove(alreadyOnMod);
            }

            // Add The Mod
            CurrentModifiersList.Add(gameplayModifier);
            gameplayModifier.InitializeMod();

            ModsChanged?.Invoke(typeof(ModManager), new ModsChangedEventArgs(Mods));
            Logger.Debug($"Added mod: {gameplayModifier.ModIdentifier}.", LogType.Runtime, false);
        }
Ejemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mods"></param>
        /// <returns></returns>
        public static string GetModsString(ModIdentifier mods)
        {
            if (mods <= 0)
            {
                return("None");
            }

            var modStrings = new List <string>();

            foreach (ModIdentifier mod in Enum.GetValues(typeof(ModIdentifier)))
            {
                if (!mods.HasFlag(mod))
                {
                    continue;
                }

                switch (mod)
                {
                case ModIdentifier.NoSliderVelocity:
                    modStrings.Add("NSV");
                    break;

                case ModIdentifier.Speed05X:
                    modStrings.Add("0.5x");
                    break;

                case ModIdentifier.Speed055X:
                    modStrings.Add("0.55x");
                    break;

                case ModIdentifier.Speed06X:
                    modStrings.Add("0.6x");
                    break;

                case ModIdentifier.Speed065X:
                    modStrings.Add("0.65x");
                    break;

                case ModIdentifier.Speed07X:
                    modStrings.Add("0.7x");
                    break;

                case ModIdentifier.Speed075X:
                    modStrings.Add("0.75x");
                    break;

                case ModIdentifier.Speed08X:
                    modStrings.Add("0.8x");
                    break;

                case ModIdentifier.Speed085X:
                    modStrings.Add("0.85x");
                    break;

                case ModIdentifier.Speed09X:
                    modStrings.Add("0.9x");
                    break;

                case ModIdentifier.Speed095X:
                    modStrings.Add("0.95x");
                    break;

                case ModIdentifier.Speed11X:
                    modStrings.Add("1.1x");
                    break;

                case ModIdentifier.Speed12X:
                    modStrings.Add("1.2x");
                    break;

                case ModIdentifier.Speed13X:
                    modStrings.Add("1.3x");
                    break;

                case ModIdentifier.Speed14X:
                    modStrings.Add("1.4x");
                    break;

                case ModIdentifier.Speed15X:
                    modStrings.Add("1.5x");
                    break;

                case ModIdentifier.Speed16X:
                    modStrings.Add("1.6x");
                    break;

                case ModIdentifier.Speed17X:
                    modStrings.Add("1.7x");
                    break;

                case ModIdentifier.Speed18X:
                    modStrings.Add("1.8x");
                    break;

                case ModIdentifier.Speed19X:
                    modStrings.Add("1.9x");
                    break;

                case ModIdentifier.Speed20X:
                    modStrings.Add("2.0x");
                    break;

                case ModIdentifier.Strict:
                    modStrings.Add("ST");
                    break;

                case ModIdentifier.Chill:
                    modStrings.Add("CH");
                    break;

                case ModIdentifier.NoPause:
                    modStrings.Add("NP");
                    break;

                case ModIdentifier.Autoplay:
                    modStrings.Add("AP");
                    break;

                case ModIdentifier.Paused:
                    modStrings.Add("PS");
                    break;

                case ModIdentifier.NoFail:
                    modStrings.Add("NF");
                    break;

                case ModIdentifier.NoLongNotes:
                    modStrings.Add("NLN");
                    break;

                case ModIdentifier.Randomize:
                    modStrings.Add("RND");
                    break;

                case ModIdentifier.Inverse:
                    modStrings.Add("IV");
                    break;

                case ModIdentifier.FullLN:
                    modStrings.Add("FLN");
                    break;

                case ModIdentifier.Mirror:
                    modStrings.Add("MR");
                    break;

                default:
                    throw new ArgumentOutOfRangeException($"Short string for ModIdentifier: {mod} does not exist.");
                }
            }

            return(string.Join(", ", modStrings));
        }