internal static BallsData GetDefaultOrRandomBalls(ChaControl chaControl) { string uncensorKey = DisplayNameToBallsGuid(chaControl.sex == 0 ? DefaultMaleBalls.Value : DefaultFemaleBalls.Value); //None/default balls if (uncensorKey == UncensorKeyNone) { return(null); } //Random if (uncensorKey == UncensorKeyRandom) { return(GetRandomBalls(chaControl)); } //Return the default balls if specified if (BallsDictionary.TryGetValue(uncensorKey, out BallsData defaultBalls)) { return(defaultBalls); } //Something was selected but can no longer be found if (chaControl.sex == 0 && MaleBallsDefaultValue == UncensorKeyNone) { return(null); } if (chaControl.sex == 1 && FemaleBallsDefaultValue == UncensorKeyNone) { return(null); } return(GetRandomBalls(chaControl)); }
/// <summary> /// Generate a random number based on character parameters so the same character will generate the same number every time and get balls based on this number. /// </summary> private static BallsData GetRandomBalls(ChaControl chaControl) { var uncensors = BallsDictionary.Where(x => x.Value.AllowRandom).Select(x => x.Value).ToArray(); if (uncensors.Length == 0) { return(null); } return(uncensors[GetRandomNumber(chaControl, uncensors.Length)]); }
/// <summary> /// Generate a random number based on character parameters so the same character will generate the same number every time and get balls based on this number. /// </summary> internal static BallsData GetRandomBalls(ChaControl chaControl) { var uncensors = BallsDictionary.Where(x => x.Value.AllowRandom).Select(x => x.Value).ToArray(); if (uncensors.Count() == 0) { return(null); } var randomIndex = new System.Random(chaControl.fileParam.birthDay + chaControl.fileParam.personality + chaControl.fileParam.bloodType).Next(uncensors.Count()); return(uncensors[randomIndex]); }
internal static BallsData GetDefaultOrRandomBalls(ChaControl chaControl) { string uncensorKey = DisplayNameToBallsGuid(chaControl.sex == 0 ? DefaultMaleBalls.Value : DefaultFemaleBalls.Value); //Return the default balls if specified if (BallsDictionary.TryGetValue(uncensorKey, out BallsData defaultBalls)) { return(defaultBalls); } return(GetRandomBalls(chaControl)); }
internal static BallsData GetDefaultOrRandomBalls(ChaControl chaControl) { string uncensorKey = DisplayNameToBallsGuid(chaControl.sex == 0 ? DefaultMaleBalls.Value : DefaultFemaleBalls.Value); //Return the default balls if specified if (BallsDictionary.TryGetValue(uncensorKey, out BallsData ballsData)) { return(ballsData); } //Get random if none specified ballsData = GetRandomBalls(chaControl); //None available, return the default if (ballsData == null) { BallsDictionary.TryGetValue(DefaultBallsGUID, out ballsData); } return(ballsData); }