private List <Feature> ScanReplace(List <Feature> feats, SkillProficiencyChoiceFeature replacement) { List <Feature> res = new List <Feature>(feats.Count); int count = 0; foreach (Feature f in feats) { if (f is LanguageChoiceFeature) { count += (f as LanguageChoiceFeature).Amount; } else if (f is LanguageProficiencyFeature) { count += (f as LanguageProficiencyFeature).Languages.Where(s => !ConfigManager.SourceInvariantComparer.Equals(s, "Common")).Distinct().Count(); } else { res.Add(f); } } replacement.Amount = count; if (count >= 0) { res.Add(replacement); } return(res); }
private void skillChoiceProficiencyFeatureToolStripMenuItem_Click(object sender, EventArgs e) { SkillProficiencyChoiceFeature f = new SkillProficiencyChoiceFeature(); f = new FeatureForms.SkillProficiencyChoiceFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
private static List <Skill> GetChoices(SkillProficiencyChoiceFeature f, PlayerModel model) { List <Skill> shown; if (f.Skills.Count == 0) { shown = (from s in model.Context.Skills.Values orderby s select s).ToList(); } else { shown = new List <Skill>(from s in f.Skills select model.Context.GetSkill(s, f.Source)); } if (f.OnlyAlreadyKnownSkills) { IEnumerable <Skill> known = model.Context.Player.GetSkillProficiencies(); shown.RemoveAll(e => !known.Any(s => s == e)); } return(shown); }
public static void AddControl(List <System.Windows.Forms.Control> control, int level, SkillProficiencyChoiceFeature f) { List <Skill> shown; if (f.Skills.Count == 0) { shown = (from s in Program.Context.Skills.Values orderby s select s).ToList(); } else { shown = new List <Skill>(from s in f.Skills select Program.Context.GetSkill(s, f.Source)); } if (f.OnlyAlreadyKnownSkills) { IEnumerable <Skill> known = Program.Context.Player.GetSkillProficiencies(); shown.RemoveAll(e => !known.Any(s => s == e)); } if (!spcfboxes.ContainsKey(f)) { spcfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount)); } if (!spcflabels.ContainsKey(f)) { spcflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount)); } List <System.Windows.Forms.ListBox> choiceboxes = spcfboxes[f]; List <System.Windows.Forms.Label> choicelabels = spcflabels[f]; List <String> taken = new List <string>(); int offset = Program.Context.Player.GetChoiceOffset(f, f.UniqueID, f.Amount); for (int c = 0; c < Program.Context.Player.GetChoiceTotal(f.UniqueID); c++) { String counter = ""; if (c > 0) { counter = "_" + c.ToString(); } Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); if (cho != null && cho.Value != "") { taken.Add(cho.Value); } } for (int c = 0; c < f.Amount; c++) { String counter = ""; if (c + offset > 0) { counter = "_" + (c + offset).ToString(); } if (choiceboxes.Count <= c) { choiceboxes.Add(new System.Windows.Forms.ListBox()); System.Windows.Forms.ListBox choicebox = choiceboxes[c]; choicebox.Dock = System.Windows.Forms.DockStyle.Top; choicebox.FormattingEnabled = true; choicebox.Name = f.UniqueID + counter; choicebox.Size = new System.Drawing.Size(472, 95); choicebox.SelectedIndexChanged += new System.EventHandler(Program.MainWindow.Choice_DisplaySkill); choicebox.DoubleClick += new System.EventHandler(Program.MainWindow.Choice_DoubleClick); choicebox.Leave += new System.EventHandler(Program.MainWindow.listbox_Deselect_on_Leave); choicebox.MouseWheel += Program.MainWindow.listbox_MouseWheel; } if (choicelabels.Count <= c) { choicelabels.Add(new System.Windows.Forms.Label()); System.Windows.Forms.Label choicelabel = choicelabels[c]; choicelabel.AutoSize = true; choicelabel.Dock = System.Windows.Forms.DockStyle.Top; choicelabel.Name = f.UniqueID + counter + "_label"; choicelabel.Padding = new System.Windows.Forms.Padding(0, (c > 0 ? 3 : 8), 0, 3); choicelabel.Text = f.Name + (f.Amount > 1 ? " (" + (c + 1) + "/" + f.Amount + ")" : ""); } control.Add(choicelabels[c]); Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); System.Windows.Forms.ListBox cbox = choiceboxes[c]; cbox.Items.Clear(); cbox.ForeColor = System.Drawing.SystemColors.WindowText; if (cho == null || cho.Value == "") { cbox.Items.AddRange((from e in shown where !taken.Exists(t => ConfigManager.SourceInvariantComparer.Equals(t, e.Name + " " + ConfigManager.SourceSeperator + " " + e.Source)) select e).ToArray()); } else { cbox.ForeColor = Config.SelectColor; cbox.Items.Add(Program.Context.GetSkill(cho.Value, f.Source)); } cbox.Height = cbox.Items.Count * cbox.ItemHeight + 10; control.Add(cbox); } }
public SkillProficiencyChoice(PlayerModel model, SkillProficiencyChoiceFeature feature) : base(model, feature.UniqueID, feature.Amount, feature, GetChoices(feature, model)) { }