private void CalculateBehavior() { RupeesGiven rupeesGiven = 0; SleepMethod method = 0; KindOfChild kindOfChild = 0; ChildQuestion childQuestion = 0; RadioButton radioButton = ugRupeesGiven.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false); if (radioButton != null) { Enum.TryParse(radioButton.Tag.ToString(), out rupeesGiven); } radioButton = ugSleepMethod.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false); if (radioButton != null) { Enum.TryParse(radioButton.Tag.ToString(), out method); } radioButton = ugKindOfChild.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false); if (radioButton != null) { Enum.TryParse(radioButton.Tag.ToString(), out kindOfChild); } radioButton = ugChildQuestion.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked ?? false); if (radioButton != null) { Enum.TryParse(radioButton.Tag.ToString(), out childQuestion); } CalculatedTotal = ChildBehaviorHelper.GetValue(_gameInfo?.Region ?? GameRegion.US, txtChildName.Text, rupeesGiven, method, childQuestion, kindOfChild); CalculatedBehavior = ChildBehaviorHelper.GetBehavior(CalculatedTotal); if (_gameInfo != null) { _gameInfo.Child = txtChildName.Text; _gameInfo.Behavior = CalculatedTotal; } }
/// <summary> /// Gets the value of the child's behavior based on reponses to questions asked /// </summary> /// <param name="region">The region of the game</param> /// <param name="name">The name of the child</param> /// <param name="rupeesGiven">The number of rupees given</param> /// <param name="sleepMethod">The method used to help the child sleep</param> /// <param name="childsQuestion">The response to the child's question</param> /// <param name="kindOfChild">Kind of child the player was</param> /// <returns></returns> public static byte GetValue(GameRegion region, string name, RupeesGiven rupeesGiven, SleepMethod sleepMethod, ChildQuestion childsQuestion, KindOfChild kindOfChild) { return((byte)(GetValue(region, name, rupeesGiven, sleepMethod) + (int)childsQuestion + (int)kindOfChild)); }
/// <summary> /// Gets the value of the child's behavior based on reponses to questions asked /// </summary> /// <param name="region">The region of the game</param> /// <param name="name">The name of the child</param> /// <param name="rupeesGiven">The number of rupees given</param> /// <param name="sleepMethod">The method used to help the child sleep</param> /// <returns></returns> public static byte GetValue(GameRegion region, string name, RupeesGiven rupeesGiven, SleepMethod sleepMethod) { return((byte)(GetValue(region, name) + (int)rupeesGiven + (int)sleepMethod)); }