public void AddFeat(string feat) { IFeat tFeat = IFeat.FactoryMethod(feat); model.PlayerFeats.Add(tFeat); if (tFeat.FeatProficiencyEffect.Count > 0) { model.PlayerProficiencies.UnionWith(tFeat.FeatProficiencyEffect); } }
public List <string> FeatOptions() { List <string> featOptions = new List <string>(); foreach (var t in IFeat.allFeats) { bool ProfPreReq = true; bool ASPreReq = true; bool ClassPreReq = true; IFeat temp = IFeat.FactoryMethod(t.Name); if (temp.FeatProficiencyPreReq.Count > 0) { ProfPreReq = false; foreach (string prof in temp.FeatProficiencyPreReq) { if (model.PlayerProficiencies.Contains(prof)) { ProfPreReq = true; break; } } } if (temp.FeatAbilityScorePreReq.Count > 0) { ASPreReq = false; foreach (string ability in temp.FeatAbilityScorePreReq) { if (model.PlayerAbilityScore[ability] >= 13) { ASPreReq = true; break; } } } if (temp.FeatClassPreReq.Count > 0) { ClassPreReq = false; if (temp.FeatClassPreReq.Contains(model.PlayerClass.ClassName)) { ClassPreReq = true; } } if (ProfPreReq && ASPreReq && ClassPreReq && !model.PlayerFeats.Any(x => x.FeatName == temp.FeatName)) { featOptions.Add(t.Name); } } return(featOptions); }
private void ASI_Feat_LM(object sender, RoutedEventArgs e) { StackPanel featStackPanel = (sender as Button).Parent as StackPanel; ComboBox featSelectionComboBox = featStackPanel.Children[1] as ComboBox; if (featSelectionComboBox.SelectedItem is null) { return; } if (featSelectionComboBox.SelectedItem.Equals(null)) { return; } IFeat feat = IFeat.FactoryMethod(featSelectionComboBox.SelectedItem.ToString()); MessageBox.Show(feat.ToString()); }
private void Feat_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox featSelection = sender as ComboBox; StackPanel featStackPanel = featSelection.Parent as StackPanel; StackPanel featASIStackPanel = featStackPanel.Children[3] as StackPanel; if (featSelection.SelectedItem is null) { return; } if (featSelection.SelectedItem.Equals(null)) { return; } IFeat feat = IFeat.FactoryMethod(featSelection.SelectedItem.ToString()); if (feat.FeatAbilityScoreEffect.Count > 0) { featASIComboBoxes.Add(featASIStackPanel.Children[1] as ComboBox); HashSet <string> ASChecker = new HashSet <string>(feat.FeatAbilityScoreEffect); HashSet <string> ASOptions = new HashSet <string>(); foreach (string ability in ASChecker) { if (tempScores[ability] < 20) { ASOptions.Add(ability); } } if (ASChecker.Count > 0) { featASIStackPanel.IsEnabled = true; featASIStackPanel.Visibility = Visibility.Visible; (featASIStackPanel.Children[1] as ComboBox).ItemsSource = ASOptions; } } else { featASIComboBoxes.Remove(featASIStackPanel.Children[1] as ComboBox); featASIStackPanel.IsEnabled = false; featASIStackPanel.Visibility = Visibility.Hidden; (featASIStackPanel.Children[1] as ComboBox).SelectedIndex = -1; } UpdateText(); Feat_ComboBoxItems(); }
private void ASI_ComboBoxItems() { foreach (ComboBox cb in asiComboBoxes) { HashSet <string> options = new HashSet <string>(); foreach (KeyValuePair <string, int> kv in tempScores) { if (kv.Value < 20) { options.Add(kv.Key); } else { options.Remove(kv.Key); } } if (!(cb.SelectedItem is null)) { options.Add(cb.SelectedItem.ToString()); } cb.ItemsSource = options; } foreach (ComboBox cb in featASIComboBoxes) { StackPanel featStackPanel = (cb.Parent as StackPanel).Parent as StackPanel; IFeat feat = IFeat.FactoryMethod((featStackPanel.Children[1] as ComboBox).SelectedItem.ToString()); HashSet <string> options = new HashSet <string>(feat.FeatAbilityScoreEffect); foreach (string item in cb.Items) { if (!(cb.SelectedItem is null)) { if (cb.SelectedItem.Equals(item)) { break; } } if (tempScores[item] >= 20) { options.Remove(item); } } cb.ItemsSource = options; } }