internal static BodyData GetDefaultOrRandomBody(ChaControl chaControl) { string uncensorKey = DisplayNameToBodyGuid(chaControl.sex == 0 ? DefaultMaleBody.Value : DefaultFemaleBody.Value); //None/default body if (uncensorKey == UncensorKeyNone) { return(null); } //Random if (uncensorKey == UncensorKeyRandom) { return(GetRandomBody(chaControl)); } //Return the default body if specified if (BodyDictionary.TryGetValue(uncensorKey, out BodyData defaultBody)) { return(defaultBody); } //Something was selected but can no longer be found if (chaControl.sex == 0 && MaleBodyDefaultValue == UncensorKeyNone) { return(null); } if (chaControl.sex == 1 && FemaleBodyDefaultValue == UncensorKeyNone) { return(null); } return(GetRandomBody(chaControl)); }
private void registerCelestialBody(CelestialBody CB) { AllBodies.AddLast(CB); if (!BodyDictionary.ContainsKey(CB.Name)) { BodyDictionary.Add(CB.Name, CB); } }
/// <summary> /// Generate a random number based on character parameters so the same character will generate the same number every time and get a body based on this number. /// </summary> internal static BodyData GetRandomBody(ChaControl chaControl) { var uncensors = BodyDictionary.Where(x => x.Value.Sex == chaControl.sex && 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 a body based on this number. /// </summary> internal static BodyData GetRandomBody(ChaControl chaControl) { var uncensors = BodyDictionary.Where(x => x.Value.Sex == chaControl.sex && 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 BodyData GetDefaultOrRandomBody(ChaControl chaControl) { string uncensorKey = DisplayNameToBodyGuid(chaControl.sex == 0 ? DefaultMaleBody.Value : DefaultFemaleBody.Value); //Return the default body if specified if (BodyDictionary.TryGetValue(uncensorKey, out BodyData defaultBody)) { return(defaultBody); } return(GetRandomBody(chaControl)); }
public static int Main() { try { BodyDictionary obj = new BodyDictionary(); Console.WriteLine("PASS"); return(100); } catch (Exception e) { Console.WriteLine("FAIL: Unexpected exception : " + e); return(101); } }
internal static BodyData GetDefaultOrRandomBody(ChaControl chaControl) { string uncensorKey = DisplayNameToBodyGuid(chaControl.sex == 0 ? DefaultMaleBody.Value : DefaultFemaleBody.Value); //Return the default body if specified if (BodyDictionary.TryGetValue(uncensorKey, out BodyData bodyData)) { return(bodyData); } //Get random if none specified bodyData = GetRandomBody(chaControl); //None available, return the default if (bodyData == null) { BodyDictionary.TryGetValue(chaControl.sex == 0 ? DefaultBodyMaleGUID : DefaultBodyFemaleGUID, out bodyData); } return(bodyData); }
public MyHttpRequest(string requestStr) { //根据回车换行切分字符 先将 \r\n字符替换为 \r 字符 然后在使用 split进行分割 var lines = requestStr.Replace("\r\n", "\r").Split('\r'); string[] arr1 = lines[0].Split(' '); if (arr1.Count() > 1) { HttpMethod = arr1[0]; Url = arr1[1]; HttpVersion = arr1[2]; for (int i = 1; i < lines.Length - 2; i++) { string k, v; k = lines[i].Split(':')[0]; v = lines[i].Split(':')[1]; HeaderDictionary.Add(k, v); } } //body处理 BodyDictionary.Add("body", lines.Last().ToString()); }