private void HandleOnUseCustomRace() { ClearSelectedRace(); SetRaceBonusDictionaryToZero(); HideRacePickerButtons(); _selectedRaceModel = new RaceModel() { Name = "Custom" }; ShowCustomRaceControls(); }
/// <summary> /// Determine if a given race model has bonus stats. If all stats are +0 bonus we can determine that it gets a custom bonus. /// </summary> /// <param name="model"></param> /// <returns>Boolean: Whether or not a model is a race with a custom bonus</returns> private bool RaceHasCustomBonus(IRaceModel model) { var stats = GetStatlineFromRaceModel(model); foreach (var stat in stats) { if (stat.Value != 0) { return(false); } } return(true); }
private static Dictionary <string, int> GetStatlineFromRaceModel(IRaceModel model) { var stats = new Dictionary <string, int> { { StatNames.Strength, model.Strength }, { StatNames.Dexterity, model.Dexterity }, { StatNames.Constitution, model.Constitution }, { StatNames.Intelligence, model.Intelligence }, { StatNames.Wisdom, model.Wisdom }, { StatNames.Charisma, model.Charisma } }; return(stats); }
private void HandleOnSelectedRace(string selected) { HideCustomControls(); ShowRacePickerButtons(); _selectedRaceModel = _raceModelsList.FirstOrDefault(x => x.Name == selected); if (RaceHasCustomBonus(_selectedRaceModel)) { _selectedRaceBonusString = ""; ShowBonusPicker(); } else { HideCustomControls(); _selectedRaceBonusString = $"{GetRaceBonusString(_selectedRaceModel)}"; } PopulateRaceBonusDictionary(_selectedRaceModel); }
private string GetRaceBonusString(IRaceModel model) { var bonusList = new List <string>(); var penaltyList = new List <string>(); var statLine = GetStatlineFromRaceModel(model); //Populate bonuses and penalties foreach (var stat in statLine) { if (stat.Value > 0) { bonusList.Add($"+{stat.Value} {GetStatAbbr(stat)}"); } if (stat.Value < 0) { penaltyList.Add($"{stat.Value} {GetStatAbbr(stat)}"); } } //Build Rreturn string return(PfStringUtils.BuildRaceBonusString(bonusList, penaltyList)); }
private void PopulateRaceBonusDictionary(IRaceModel model) { _currentRacialBonusDictionary = GetStatlineFromRaceModel(model); }
private void ClearSelectedRace() { _selectedRaceBonusString = ""; _selectedRaceModel = new RaceModel(); SetRaceBonusDictionaryToZero(); }