private void SetModifierEffectiveValues(NoteOptionModifier modifier) { int effectiveWeight = modifier.Weight; bool effectiveForce = modifier.Force; List <NoteOptionModifier> subModifiers = new List <NoteOptionModifier>(); foreach (var subModifier in modifier.Modifiers.Where(s => DoesModifierApply(s))) { SetModifierEffectiveValues(subModifier); subModifiers.Add(subModifier); } subModifiers = subModifiers.OrderBy(m => m.Priority).Where(m => m.Priority == subModifiers.First().Priority).ToList(); if (subModifiers.Count > 0) { if (subModifiers.Any(m => m.Force)) { effectiveForce = true; } else { effectiveForce = false; } effectiveWeight = (int)Math.Round(subModifiers.Average(m => m.Weight)); } modifier.EffectiveWeight = effectiveWeight; modifier.EffectiveForce = effectiveForce; }
protected override bool DoesModifierApply(NoteOptionModifier modifier) { bool baseApplies = base.DoesModifierApply(modifier); bool match = false; if (RootIdea?.GetType() == typeof(CharacterNote) && modifier.GetType() == typeof(NoteOptionCharacterModifier)) { CharacterNote host = (CharacterNote)RootIdea; NoteOptionCharacterModifier cModifier = (NoteOptionCharacterModifier)modifier; // Does not match if a gender is specified, but the character's gender (or its archetype) doesn't match if (cModifier.Genders.Count > 0 && (host.EffectiveGender == null || (!cModifier.Genders.Contains(host.EffectiveGender.Name) && !cModifier.Genders.Contains(host.EffectiveGender.Archetype)))) return false; else match = true; // Does not match if a race is specified, but the character's race doesn't match if (cModifier.Races.Count > 0) { bool found = false; foreach (var race in cModifier.Races) { if (host.Races.FindOption(race)?.IsChecked == true) found = true; } if (!found) return false; match = true; } // Does not match if an age range is specified, but the character's age is outside the range if (cModifier.MinAge.HasValue && host.AgeYears < cModifier.MinAge) return false; if (cModifier.MaxAge.HasValue && host.AgeYears > cModifier.MaxAge) return false; if (cModifier.MinAge.HasValue || cModifier.MaxAge.HasValue) match = true; } // If the modifier had character-specific conditions which were met, and omits the usual target, it is considered a match if (string.IsNullOrEmpty(modifier.TargetPath) && match) return true; // Otherwise, use the usual matching criteria only. return baseApplies; }
protected override bool DoesModifierApply(NoteOptionModifier modifier) { bool baseApplies = base.DoesModifierApply(modifier); bool match = false; if (RootIdea?.GetType() == typeof(CharacterNote) && modifier.GetType() == typeof(NoteOptionCharacterModifier)) { CharacterNote host = (CharacterNote)RootIdea; NoteOptionCharacterModifier cModifier = (NoteOptionCharacterModifier)modifier; // Does not match if a gender is specified, but the character's gender (or its archetype) doesn't match if (cModifier.Genders.Count > 0 && (host.EffectiveGender == null || (!cModifier.Genders.Contains(host.EffectiveGender.Name) && !cModifier.Genders.Contains(host.EffectiveGender.Archetype)))) { return(false); } else { match = true; } // Does not match if a race is specified, but the character's race doesn't match if (cModifier.Races.Count > 0) { bool found = false; foreach (var race in cModifier.Races) { if (host.Races.FindOption(race)?.IsChecked == true) { found = true; } } if (!found) { return(false); } match = true; } // Does not match if an age range is specified, but the character's age is outside the range if (cModifier.MinAge.HasValue && host.AgeYears < cModifier.MinAge) { return(false); } if (cModifier.MaxAge.HasValue && host.AgeYears > cModifier.MaxAge) { return(false); } if (cModifier.MinAge.HasValue || cModifier.MaxAge.HasValue) { match = true; } } // If the modifier had character-specific conditions which were met, and omits the usual target, it is considered a match if (string.IsNullOrEmpty(modifier.TargetPath) && match) { return(true); } // Otherwise, use the usual matching criteria only. return(baseApplies); }
protected virtual bool DoesModifierApply(NoteOptionModifier modifier) { NoteOption option = FindOption(modifier.TargetPath); return(option?.IsChecked == true); }
private void SetModifierEffectiveValues(NoteOptionModifier modifier) { int effectiveWeight = modifier.Weight; bool effectiveForce = modifier.Force; List<NoteOptionModifier> subModifiers = new List<NoteOptionModifier>(); foreach (var subModifier in modifier.Modifiers.Where(s => DoesModifierApply(s))) { SetModifierEffectiveValues(subModifier); subModifiers.Add(subModifier); } subModifiers = subModifiers.OrderBy(m => m.Priority).Where(m => m.Priority == subModifiers.First().Priority).ToList(); if (subModifiers.Count > 0) { if (subModifiers.Any(m => m.Force)) effectiveForce = true; else effectiveForce = false; effectiveWeight = (int)Math.Round(subModifiers.Average(m => m.Weight)); } modifier.EffectiveWeight = effectiveWeight; modifier.EffectiveForce = effectiveForce; }
protected virtual bool DoesModifierApply(NoteOptionModifier modifier) { NoteOption option = FindOption(modifier.TargetPath); return (option?.IsChecked == true); }