Exemplo n.º 1
0
        /// <summary>
        /// Creates an instance of <see cref="RaceViewModel"/>
        /// </summary>
        public RaceViewModel(RaceModel raceModel)
        {
            _raceModel = raceModel;

            _size  = _raceModel.Size != CreatureSize.None ? _stringService.GetString(_raceModel.Size) : "Unknown";
            _speed = raceModel.WalkSpeed.ToString() + " ft.";
            if (_raceModel.FlySpeed > 0)
            {
                _speed += ", Fly" + _raceModel.FlySpeed.ToString() + " ft.";
            }

            if (_raceModel.Abilities.Count > 0)
            {
                List <string> abilities = new List <string>();
                foreach (KeyValuePair <Ability, int> pair in _raceModel.Abilities)
                {
                    abilities.Add(_stringService.GetString(pair.Key) + " " + _statService.AddPlusOrMinus(pair.Value));
                }
                _abilities = String.Join(", ", abilities);
            }
            else
            {
                _abilities = "None";
            }

            foreach (TraitModel trait in _raceModel.Traits)
            {
                _traits.Add(new TraitViewModel(trait));
            }
        }
Exemplo n.º 2
0
 private void Initialize()
 {
     if (_monsterModel.Size != CreatureSize.None && !String.IsNullOrWhiteSpace(_monsterModel.Type) && !String.IsNullOrWhiteSpace(_monsterModel.Alignment))
     {
         string sizeString = _stringService.GetString(_monsterModel.Size);
         _details = _stringService.CapitalizeWords(sizeString + " " + _monsterModel.Type + ", " + _monsterModel.Alignment);
     }
     else if (_monsterModel.Size != CreatureSize.None && !String.IsNullOrWhiteSpace(_monsterModel.Type))
     {
         string sizeString = _stringService.GetString(_monsterModel.Size);
         _details = _stringService.CapitalizeWords(sizeString + " " + _monsterModel.Type);
     }
     else if (_monsterModel.Size != CreatureSize.None)
     {
         _details = _stringService.GetString(_monsterModel.Size);
     }
     else if (!String.IsNullOrWhiteSpace(_monsterModel.Type))
     {
         _details = _monsterModel.Type;
     }
     else
     {
         _details = "Unknown";
     }
 }
Exemplo n.º 3
0
        private void Initialize()
        {
            _details = "None";

            if (_backgroundModel.Skills.Count > 0)
            {
                _details = String.Join(", ", _backgroundModel.Skills.Select(x => _stringService.GetString(x)));
            }
            else if (_backgroundModel.SkillsTraitIndex > -1 &&
                     _backgroundModel.SkillsTraitIndex < _backgroundModel.Traits.Count)
            {
                TraitModel trait = _backgroundModel.Traits[_backgroundModel.SkillsTraitIndex];
                _details = trait.TextCollection[0].Trim();
            }
            else if (_backgroundModel.StartingTraitIndex > -1 &&
                     _backgroundModel.StartingTraitIndex < _backgroundModel.Traits.Count)
            {
                foreach (string text in _backgroundModel.Traits[_backgroundModel.StartingTraitIndex].TextCollection)
                {
                    if (text.Contains("Skills: "))
                    {
                        _details = text.Replace("Skills: ", "").Trim();
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Creates an instance of <see cref="BackgroundViewModel"/>
        /// </summary>
        public BackgroundViewModel(BackgroundModel backgroundModel)
        {
            _backgroundModel = backgroundModel;

            _skills = "None";

            if (_backgroundModel.Skills.Count > 0)
            {
                _skills = String.Join(", ", _backgroundModel.Skills.Select(x => _stringService.GetString(x)));
            }
            else if (_backgroundModel.SkillsTraitIndex > -1 &&
                     _backgroundModel.SkillsTraitIndex < _backgroundModel.Traits.Count)
            {
                TraitModel trait = _backgroundModel.Traits[_backgroundModel.SkillsTraitIndex];
                _skills = trait.TextCollection[0].Trim();
            }
            else if (_backgroundModel.StartingTraitIndex > -1 &&
                     _backgroundModel.StartingTraitIndex < _backgroundModel.Traits.Count)
            {
                foreach (string text in _backgroundModel.Traits[_backgroundModel.StartingTraitIndex].TextCollection)
                {
                    if (text.Contains("Skills: "))
                    {
                        _skills = text.Replace("Skills: ", "").Trim();
                        break;
                    }
                }
            }

            foreach (TraitModel trait in _backgroundModel.Traits)
            {
                _traits.Add(new TraitViewModel(trait));
            }
        }
        private void Initialize()
        {
            if (_raceModel.Abilities.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < _raceModel.Abilities.Count; ++i)
                {
                    KeyValuePair <Ability, int> pair = _raceModel.Abilities.ElementAt(i);

                    string abilityString = _stringService.GetString(pair.Key);
                    stringBuilder.Append(abilityString);
                    if (pair.Value > 0)
                    {
                        stringBuilder.Append(" +");
                    }
                    else
                    {
                        stringBuilder.Append(" ");
                    }
                    stringBuilder.Append(pair.Value);

                    if (i + 1 < _raceModel.Abilities.Count)
                    {
                        stringBuilder.Append(", ");
                    }
                }

                _abilities = stringBuilder.ToString();
            }
            else
            {
                _abilities = "None";
            }
        }
Exemplo n.º 6
0
        public void GetStringTest()
        {
            var expected = "Hello, World!";

            var service = new StringService();
            var actual  = service.GetString();

            Assert.AreEqual(expected, actual);
        }
        private void Initialize()
        {
            int numCharacters = _encounterModel.Creatures.Where(x => x is EncounterCharacterModel).Count();
            int numMonsters   = _encounterModel.Creatures.Where(x => x is EncounterMonsterModel).Select(x => ((EncounterMonsterModel)x).Quantity).Sum();

            _description = $"{numCharacters} Characters, {numMonsters} Monsters, Challenge ";

            _description += _stringService.GetString(_encounterModel.EncounterChallenge);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new instance of <see cref="AbilityModel"/>
        /// </summary>
        public AbilityModel(Ability ability, int saveBonus, int checkBonus, bool proficient)
        {
            _ability    = ability;
            _saveBonus  = saveBonus;
            _checkBonus = checkBonus;
            _proficient = proficient;

            _abilityString = _stringService.GetString(ability);
        }
Exemplo n.º 9
0
        private void Initialize()
        {
            List <string> abilities = new List <string>();

            foreach (Ability ability in _classModel.AbilityProficiencies)
            {
                abilities.Add(_stringService.GetString(ability));
            }

            _abilities = String.Join(", ", abilities);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes creation options
        /// </summary>
        public void InitializeOptions()
        {
            foreach (ClassModel classModel in _compendium.Classes)
            {
                _classOptions.Add(new KeyValuePair <ClassModel, string>(classModel, classModel.Name));
            }

            if (_spellbookModel.Class != null)
            {
                _selectedClassOption = _classOptions.FirstOrDefault(x => x.Key != null && x.Key.Id == _spellbookModel.Class.Id);
            }

            if (_selectedClassOption.Equals(default(KeyValuePair <ClassModel, string>)) && _classOptions.Any())
            {
                _selectedClassOption  = _classOptions[0];
                _spellbookModel.Class = _selectedClassOption.Key;

                KeyValuePair <Ability, string> pair = _abilityOptions.FirstOrDefault(x => x.Key == _spellbookModel.Class.SpellAbility);
                if (!pair.Equals(default(KeyValuePair <Ability, string>)))
                {
                    _selectedAbilityOption  = pair;
                    _spellbookModel.Ability = pair.Key;
                    OnPropertyChanged(nameof(Ability));
                    OnPropertyChanged(nameof(SelectedAbilityOption));
                }
            }

            foreach (RaceModel raceModel in _compendium.Races)
            {
                _raceOptions.Add(new KeyValuePair <RaceModel, string>(raceModel, raceModel.Name));
            }

            if (_spellbookModel.Race != null)
            {
                _selectedRaceOption = _raceOptions.FirstOrDefault(x => x.Key != null && x.Key.Id == _spellbookModel.Race.Id);
            }

            if (_selectedRaceOption.Equals(default(KeyValuePair <RaceModel, string>)) && _raceOptions.Any())
            {
                _selectedRaceOption = _raceOptions[0];
            }

            _abilityOptions.Add(new KeyValuePair <Ability, string>(Ability.None, "None"));
            foreach (Ability ability in Enum.GetValues(typeof(Ability)))
            {
                if (ability != Ability.None)
                {
                    _abilityOptions.Add(new KeyValuePair <Ability, string>(ability, _stringService.GetString(ability)));
                }
            }

            _selectedAbilityOption = _abilityOptions.FirstOrDefault(x => x.Key == _spellbookModel.Ability);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates and instance of <see cref="LevelEditViewModel"/>
        /// </summary>
        public LevelEditViewModel(LevelModel levelModel)
        {
            _levelModel = levelModel;

            _level        = _levelModel.Level;
            _levelOfClass = _levelModel.LevelOfClass;

            foreach (ClassModel classModel in _compendium.Classes)
            {
                _classes.Add(new Tuple <Guid, string>(classModel.Id, classModel.Name));
            }

            _class = _levelModel.Class.Id;

            foreach (FeatModel featModel in _levelModel.Feats)
            {
                _feats.Add(new FeatEditViewModel(featModel));
            }

            _hitDieResult = _levelModel.HitDieResult;
            _hitDieUsed   = _levelModel.HitDieUsed;
            _additionalHP = _levelModel.AdditionalHP;

            foreach (KeyValuePair <Ability, int> abilityScore in _levelModel.AbilityScoreImprovements)
            {
                _abilityScoreImprovements.Add(new AbilityScoreEditViewModel(abilityScore.Key, abilityScore.Value));
            }

            foreach (Ability a in Enum.GetValues(typeof(Ability)))
            {
                if (a != Ability.None)
                {
                    _abilities.Add(new Tuple <Ability, string>(a, _stringService.GetString(a)));
                }
            }

            _viewClassCommand          = new RelayCommand(obj => true, obj => ViewClass());
            _viewFeatureCommand        = new RelayCommand(obj => true, obj => ViewFeature((FeatureViewModel)obj));
            _viewFeatCommand           = new RelayCommand(obj => true, obj => ViewFeat((FeatEditViewModel)obj));
            _addAbilityScoreCommand    = new RelayCommand(obj => true, obj => AddAbilityScore());
            _deleteAbilityScoreCommand = new RelayCommand(obj => true, obj => DeleteAbilityScore((AbilityScoreEditViewModel)obj));
            _addFeatCommand            = new RelayCommand(obj => true, obj => AddFeat());
            _deleteFeatCommand         = new RelayCommand(obj => true, obj => DeleteFeat((FeatEditViewModel)obj));

            foreach (FeatModel featModel in _compendium.Feats)
            {
                _availableFeats.Add(new Tuple <Guid, string>(featModel.Id, featModel.Name));
            }

            UpdateFeatures();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates an instance of <see cref="ItemSearchInput"/>
        /// </summary>
        public ItemSearchInput(StringService stringService)
        {
            _stringService = stringService;

            foreach (ItemSortOption sort in Enum.GetValues(typeof(ItemSortOption)))
            {
                _sortOptions.Add(new KeyValuePair <ItemSortOption, string>(sort, sort.ToString().Replace("_", " ")));
            }

            _types.Add(new KeyValuePair <ItemType, string>(Enums.ItemType.None, "Any Item Type"));
            foreach (ItemType itemType in Enum.GetValues(typeof(ItemType)))
            {
                if (itemType != Enums.ItemType.None)
                {
                    _types.Add(new KeyValuePair <ItemType, string>(itemType, _stringService.GetString(itemType)));
                }
            }

            _magicOptions.Add(new KeyValuePair <bool?, string>(null, "Any Magic"));
            _magicOptions.Add(new KeyValuePair <bool?, string>(true, "Magic"));
            _magicOptions.Add(new KeyValuePair <bool?, string>(false, "Non-Magic"));

            _rarities.Add(new KeyValuePair <Rarity, string>(Enums.Rarity.None, "Any Rarity"));
            foreach (Rarity rarity in Enum.GetValues(typeof(Rarity)))
            {
                if (rarity != Enums.Rarity.None)
                {
                    _rarities.Add(new KeyValuePair <Rarity, string>(rarity, _stringService.GetString(rarity)));
                }
            }

            _attunementOptions.Add(new KeyValuePair <bool?, string>(null, "Any Attunement"));
            _attunementOptions.Add(new KeyValuePair <bool?, string>(true, "Yes"));
            _attunementOptions.Add(new KeyValuePair <bool?, string>(false, "No"));

            Reset();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes options
        /// </summary>
        public void InitializeOptions()
        {
            _armorTypeOptions.Add(new KeyValuePair <ArmorType, string>(ArmorType.None, "None"));
            _armorTypeOptions.Add(new KeyValuePair <ArmorType, string>(ArmorType.Light_Armor, _stringService.GetString(ArmorType.Light_Armor)));
            _armorTypeOptions.Add(new KeyValuePair <ArmorType, string>(ArmorType.Medium_Armor, _stringService.GetString(ArmorType.Medium_Armor)));
            _armorTypeOptions.Add(new KeyValuePair <ArmorType, string>(ArmorType.Heavy_Armor, _stringService.GetString(ArmorType.Heavy_Armor)));

            KeyValuePair <ArmorType, string> armorType = _armorTypeOptions.FirstOrDefault(x => x.Key == _armorClassModel.ArmorType);

            if (!armorType.Equals(default(KeyValuePair <ArmorType, string>)))
            {
                _selectedArmorTypeOption = armorType;
            }
            else
            {
                _selectedArmorTypeOption = _armorTypeOptions[0];
            }

            _abilityOptions.Add(new KeyValuePair <Ability, string>(Ability.None, "None"));
            foreach (Ability ability in Enum.GetValues(typeof(Ability)))
            {
                if (ability != Ability.None)
                {
                    _abilityOptions.Add(new KeyValuePair <Ability, string>(ability, _stringService.GetString(ability)));
                }
            }

            KeyValuePair <Ability, string> firstAbility = _abilityOptions.FirstOrDefault(x => x.Key == _armorClassModel.FirstAbility);

            if (!firstAbility.Equals(default(KeyValuePair <Ability, string>)))
            {
                _selectedFirstAbilityOption = firstAbility;
            }
            else
            {
                _selectedFirstAbilityOption = _abilityOptions[0];
            }

            KeyValuePair <Ability, string> secondAbility = _abilityOptions.FirstOrDefault(x => x.Key == _armorClassModel.SecondAbility);

            if (!secondAbility.Equals(default(KeyValuePair <Ability, string>)))
            {
                _selectedSecondAbilityOption = secondAbility;
            }
            else
            {
                _selectedSecondAbilityOption = _abilityOptions[0];
            }
        }
Exemplo n.º 14
0
        public RaceSearchInput(Compendium compendium, StringService stringService)
        {
            _compendium    = compendium;
            _stringService = stringService;

            foreach (RaceSortOption sort in Enum.GetValues(typeof(RaceSortOption)))
            {
                _sortOptions.Add(new KeyValuePair <RaceSortOption, string>(sort, sort.ToString().Replace("_", " ")));
            }

            _sizes.Add(new KeyValuePair <CreatureSize, string>(CreatureSize.None, "Any Size"));
            foreach (CreatureSize size in Enum.GetValues(typeof(CreatureSize)))
            {
                if (size != CreatureSize.None)
                {
                    _sizes.Add(new KeyValuePair <CreatureSize, string>(size, _stringService.GetString(size)));
                }
            }

            _abilities.Add(new KeyValuePair <Ability, string>(Enums.Ability.None, "Any Ability"));
            foreach (Ability ability in Enum.GetValues(typeof(Ability)))
            {
                if (ability != Enums.Ability.None)
                {
                    _abilities.Add(new KeyValuePair <Ability, string>(ability, _stringService.GetString(ability)));
                }
            }

            _languages.Add(new KeyValuePair <LanguageModel, string>(null, "Any Language"));
            foreach (LanguageModel languageModel in _compendium.Languages)
            {
                _languages.Add(new KeyValuePair <LanguageModel, string>(languageModel, languageModel.Name));
            }

            Reset();
        }
Exemplo n.º 15
0
        public SpellSearchInput()
        {
            foreach (SpellSortOption sort in Enum.GetValues(typeof(SpellSortOption)))
            {
                _sortOptions.Add(new KeyValuePair <SpellSortOption, string>(sort, sort.ToString().Replace("_", " ")));
            }

            _levels.Add(new KeyValuePair <int?, string>(null, "Any Level"));
            _levels.Add(new KeyValuePair <int?, string>(-1, "Unknown"));
            _levels.Add(new KeyValuePair <int?, string>(0, "Cantrip"));
            _levels.Add(new KeyValuePair <int?, string>(1, "Level 1"));
            _levels.Add(new KeyValuePair <int?, string>(2, "Level 2"));
            _levels.Add(new KeyValuePair <int?, string>(3, "Level 3"));
            _levels.Add(new KeyValuePair <int?, string>(4, "Level 4"));
            _levels.Add(new KeyValuePair <int?, string>(5, "Level 5"));
            _levels.Add(new KeyValuePair <int?, string>(6, "Level 6"));
            _levels.Add(new KeyValuePair <int?, string>(7, "Level 7"));
            _levels.Add(new KeyValuePair <int?, string>(8, "Level 8"));
            _levels.Add(new KeyValuePair <int?, string>(9, "Level 9"));

            _schools.Add(new KeyValuePair <SpellSchool, string>(SpellSchool.None, "Any School"));
            foreach (SpellSchool school in Enum.GetValues(typeof(SpellSchool)))
            {
                if (school != SpellSchool.None)
                {
                    _schools.Add(new KeyValuePair <SpellSchool, string>(school, _stringService.GetString(school)));
                }
            }

            foreach (ClassModel classModel in _compendium.Classes)
            {
                _classes.Add(new KeyValuePair <string, string>(classModel.Name, classModel.Name));
            }
            _classes.Insert(0, new KeyValuePair <string, string>(null, "Any Class"));

            _concentrationOptions.Add(new KeyValuePair <bool?, string>(null, "Any Concentration"));
            _concentrationOptions.Add(new KeyValuePair <bool?, string>(false, "No"));
            _concentrationOptions.Add(new KeyValuePair <bool?, string>(true, "Yes"));

            _ritualOptions.Add(new KeyValuePair <bool?, string>(null, "Any Ritual"));
            _ritualOptions.Add(new KeyValuePair <bool?, string>(false, "No"));
            _ritualOptions.Add(new KeyValuePair <bool?, string>(true, "Yes"));

            Reset();
        }
        private void Initialize()
        {
            string level = String.Empty;

            if (_spellModel.Level == -1)
            {
                level = "Unknown Level";
            }
            else if (_spellModel.Level == 0)
            {
                level = "Cantrip";
            }
            else
            {
                level = "Level " + _spellModel.Level.ToString();
            }

            _details = level + ", " + (_spellModel.SpellSchool != SpellSchool.None ? _stringService.GetString(_spellModel.SpellSchool) : "Unknown School");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Creates a new instance of <see cref="SkillModel"/>
        /// </summary>
        public SkillModel(Skill skill, int bonus, bool proficient, bool expertise)
        {
            _skill      = skill;
            _bonus      = bonus;
            _proficient = proficient;
            _expertise  = expertise;

            _skillString = _stringService.GetString(skill);

            _skillAbilityString = _skillString;
            if (skill != Skill.None)
            {
                Ability ability = _statService.GetSkillAbility(skill);
                if (ability != Ability.None)
                {
                    string abrev = _stringService.GetAbbreviationString(ability).ToUpper();
                    _skillAbilityString = $"{_skillString} ({abrev})";
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates an instance of <see cref="SpellViewModel"/>
        /// </summary>
        public SpellViewModel(SpellModel spellModel)
        {
            _spellModel = spellModel;

            if (_spellModel.Level == -1)
            {
                _level = "Unknown";
            }
            else if (_spellModel.Level == 0)
            {
                _level = "Cantrip";
            }
            else
            {
                _level = _spellModel.Level.ToString();
            }
            _school     = _spellModel.SpellSchool != SpellSchool.None ? _stringService.GetString(_spellModel.SpellSchool) : "Unknown";
            _range      = !String.IsNullOrWhiteSpace(_spellModel.Range) ? _spellModel.Range : "Unknown";
            _ritual     = _spellModel.IsRitual ? "Yes" : "No";
            _time       = !String.IsNullOrWhiteSpace(_spellModel.CastingTime) ? _spellModel.CastingTime : "Unknown";
            _components = !String.IsNullOrWhiteSpace(_spellModel.Components) ? _spellModel.Components : "None";
            _duration   = !String.IsNullOrWhiteSpace(_spellModel.Duration) ? _spellModel.Duration : "Unknown";
            _classes    = !String.IsNullOrWhiteSpace(_spellModel.Classes) ? _spellModel.Classes : "Unknown";

            List <string> text = new List <string>();

            foreach (string s in _spellModel.TextCollection)
            {
                text.Add(s.Replace("\t", "").Trim());
            }
            _text = String.Join(Environment.NewLine + Environment.NewLine, text);

            _rolls = new List <string>(_spellModel.Rolls);

            _rollCommand = new RelayCommand(obj => true, obj => Roll((string)obj));
        }
Exemplo n.º 19
0
        private bool HasTool(BackgroundModel backgroundModel, Enum tool)
        {
            bool hasTool = tool == null;

            if (tool != null)
            {
                string toolString = _stringService.GetString(tool).ToLower();

                if (backgroundModel.ToolsTraitIndex > -1 &&
                    backgroundModel.ToolsTraitIndex < backgroundModel.Traits.Count)
                {
                    TraitModel trait = backgroundModel.Traits[backgroundModel.ToolsTraitIndex];
                    hasTool = trait.Text.ToLower().Contains(toolString);
                }
                else if (backgroundModel.StartingTraitIndex > -1 &&
                         backgroundModel.StartingTraitIndex < backgroundModel.Traits.Count)
                {
                    TraitModel trait = backgroundModel.Traits[backgroundModel.StartingTraitIndex];
                    hasTool = trait.Text.ToLower().Contains(toolString);
                }
            }

            return(hasTool);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Creates an instance of <see cref="ItemViewModel"/>
        /// </summary>
        public ItemViewModel(ItemModel itemModel)
        {
            _itemModel = itemModel;

            _type  = _stringService.GetString(_itemModel.Type);
            _magic = _itemModel.Magic ? "Yes" : "No";
            _requiresAttunement = _itemModel.RequiresAttunement ? "Yes" : "No";

            if (String.IsNullOrWhiteSpace(_itemModel.Value))
            {
                _value = "Unknown";
            }
            else if (itemModel.Value.Any(x => Char.IsLetter(x)))
            {
                _value = _itemModel.Value;
            }
            else
            {
                _value = _itemModel.Value + " g";
            }

            _weight = !String.IsNullOrWhiteSpace(_itemModel.Weight) ? _itemModel.Weight + " lbs" : "Unknown";

            if (!String.IsNullOrWhiteSpace(_itemModel.Dmg1) &&
                !String.IsNullOrWhiteSpace(_itemModel.Dmg2))
            {
                _damage = _itemModel.Dmg1 + " / " + _itemModel.Dmg2;
            }
            else if (!String.IsNullOrWhiteSpace(_itemModel.Dmg1))
            {
                _damage = _itemModel.Dmg1;
            }
            else if (!String.IsNullOrWhiteSpace(_itemModel.Dmg2))
            {
                _damage = _itemModel.Dmg2;
            }
            else
            {
                _damage = "None";
            }

            if (!String.IsNullOrWhiteSpace(_itemModel.DmgType))
            {
                _damageType = _itemModel.DmgType;
            }
            else
            {
                _damageType = "None";
            }

            if (!String.IsNullOrWhiteSpace(_itemModel.Properties))
            {
                _properties = _itemModel.Properties;
            }
            else
            {
                _properties = "None";
            }

            if (_itemModel.Rarity != CritCompendiumInfrastructure.Enums.Rarity.None)
            {
                _rarity = _stringService.GetString(_itemModel.Rarity);
            }
            else
            {
                _rarity = "Unknown";
            }

            if (!String.IsNullOrWhiteSpace(_itemModel.AC))
            {
                _ac = _itemModel.AC;
            }
            else
            {
                _ac = "None";
            }

            if (!String.IsNullOrWhiteSpace(_itemModel.StrengthRequirement))
            {
                _strengthRequirement = _itemModel.StrengthRequirement;
            }
            else
            {
                _strengthRequirement = "None";
            }

            _stealthDisadvantage = _itemModel.StealthDisadvantage ? "Yes" : "No";

            if (!String.IsNullOrWhiteSpace(_itemModel.Range))
            {
                _range = _itemModel.Range;
            }
            else
            {
                _range = "None";
            }

            _text = String.Join(Environment.NewLine + Environment.NewLine, _itemModel.TextCollection.Where(x => !String.IsNullOrWhiteSpace(x)));

            if (String.IsNullOrWhiteSpace(_text))
            {
                _text = "Unknown";
            }
            else
            {
                _text = _text.Replace("\t", "").Trim();
            }

            _rolls = new List <string>(itemModel.Rolls);

            _rollCommand = new RelayCommand(obj => true, obj => Roll((string)obj));
        }
Exemplo n.º 21
0
        public ClassSearchInput(StringService stringService)
        {
            _stringService = stringService;

            foreach (ClassSortOption sort in Enum.GetValues(typeof(ClassSortOption)))
            {
                _sortOptions.Add(new KeyValuePair <ClassSortOption, string>(sort, sort.ToString().Replace("_", " ")));
            }

            _abilities.Add(new KeyValuePair <Ability, string>(Enums.Ability.None, "Any Ability"));
            foreach (Ability ability in Enum.GetValues(typeof(Ability)))
            {
                if (ability != Enums.Ability.None)
                {
                    _abilities.Add(new KeyValuePair <Ability, string>(ability, _stringService.GetString(ability)));
                }
            }

            _armors.Add(new KeyValuePair <ArmorType, string>(ArmorType.None, "Any Armor"));
            foreach (ArmorType armor in Enum.GetValues(typeof(ArmorType)))
            {
                if (armor != ArmorType.None)
                {
                    _armors.Add(new KeyValuePair <ArmorType, string>(armor, _stringService.GetString(armor)));
                }
            }

            _weapons.Add(new KeyValuePair <WeaponType, string>(WeaponType.None, "Any Weapon"));
            foreach (WeaponType weapon in Enum.GetValues(typeof(WeaponType)))
            {
                if (weapon != WeaponType.None)
                {
                    _weapons.Add(new KeyValuePair <WeaponType, string>(weapon, _stringService.GetString(weapon)));
                }
            }

            foreach (ArtisanTool tool in Enum.GetValues(typeof(ArtisanTool)))
            {
                if (tool != ArtisanTool.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(tool, _stringService.GetString(tool)));
                }
            }
            foreach (GamingSet game in Enum.GetValues(typeof(GamingSet)))
            {
                if (game != GamingSet.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(game, _stringService.GetString(game)));
                }
            }
            foreach (Kit kit in Enum.GetValues(typeof(Kit)))
            {
                if (kit != Kit.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(kit, _stringService.GetString(kit)));
                }
            }
            foreach (MusicalInstrument instrument in Enum.GetValues(typeof(MusicalInstrument)))
            {
                if (instrument != MusicalInstrument.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(instrument, _stringService.GetString(instrument)));
                }
            }
            foreach (Tool tool in Enum.GetValues(typeof(Tool)))
            {
                if (tool != Enums.Tool.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(tool, _stringService.GetString(tool)));
                }
            }
            foreach (Vehicle vehicle in Enum.GetValues(typeof(Vehicle)))
            {
                if (vehicle != Vehicle.None)
                {
                    _tools.Add(new KeyValuePair <Enum, string>(vehicle, _stringService.GetString(vehicle)));
                }
            }
            _tools = _tools.OrderBy(x => x.Value).ToList();
            _tools.Insert(0, new KeyValuePair <Enum, string>(null, "Any Tool"));

            _skills.Add(new KeyValuePair <Skill, string>(Enums.Skill.None, "Any Skill"));
            foreach (Skill skill in Enum.GetValues(typeof(Skill)))
            {
                if (skill != Enums.Skill.None)
                {
                    _skills.Add(new KeyValuePair <Skill, string>(skill, _stringService.GetString(skill)));
                }
            }

            Reset();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes options
        /// </summary>
        public void InitializeOptions()
        {
            foreach (StatModificationOption statOption in Enum.GetValues(typeof(StatModificationOption)))
            {
                _modificationOptions.Add(new KeyValuePair <StatModificationOption, string>(statOption, _stringService.GetString(statOption)));
            }

            KeyValuePair <StatModificationOption, string> selected = _modificationOptions.FirstOrDefault(x => x.Key == _statModificationModel.ModificationOption);

            if (!selected.Equals(default(KeyValuePair <StatModificationOption, string>)))
            {
                _selectedModificationOption = selected;
            }
            else
            {
                _selectedModificationOption = _modificationOptions[0];
            }
        }
        /// <summary>
        /// Creates an instance of <see cref="ConvertMoneyViewModel"/>
        /// </summary>
        public ConvertMoneyViewModel(BagModel bagModel)
        {
            _bagModel = bagModel;

            foreach (Currency currency in Enum.GetValues(typeof(Currency)))
            {
                if (currency != Currency.None)
                {
                    _currencyOptions.Add(new KeyValuePair <Currency, string>(currency, _stringService.GetString(currency)));
                }
            }

            _selectedFromCurrencyOption = _currencyOptions[0];
            _selectedToCurrencyOption   = _currencyOptions[0];

            UpdateConversionResults();
        }
Exemplo n.º 24
0
 private bool HasSkill(ClassModel classModel, Skill skill)
 {
     return(skill == Skill.None ||
            classModel.SkillProficiencies.ToLower().Contains(_stringService.GetString(skill).ToLower()));
 }
Exemplo n.º 25
0
 private void Initialize()
 {
     _details = _stringService.GetString(_itemModel.Type) + (_itemModel.Magic ? ", Magic" : ", Non-Magic");
 }
Exemplo n.º 26
0
        /// <summary>
        /// Creates an instance of <see cref="MonsterViewModel"/>
        /// </summary>
        public MonsterViewModel(MonsterModel monsterModel)
        {
            _monsterModel = monsterModel;

            _size      = _monsterModel.Size != CreatureSize.None ? _stringService.GetString(_monsterModel.Size) : "Unknown";
            _alignment = !String.IsNullOrWhiteSpace(_monsterModel.Alignment) ? _stringService.CapitalizeWords(_monsterModel.Alignment) : "Unknown";
            _ac        = !String.IsNullOrWhiteSpace(_monsterModel.AC) ? _stringService.CapitalizeWords(_monsterModel.AC) : "Unknown";
            _hp        = !String.IsNullOrWhiteSpace(_monsterModel.HP) ? _monsterModel.HP : "Unknown";
            _type      = !String.IsNullOrWhiteSpace(_monsterModel.Type) ? _stringService.CapitalizeWords(_monsterModel.Type) : "Unknown";

            if (!String.IsNullOrWhiteSpace(_monsterModel.CR))
            {
                string xp = _stringService.CRXPString(_monsterModel.CR);
                if (!String.IsNullOrWhiteSpace(xp))
                {
                    _cr = String.Format("{0} ({1} XP)", _monsterModel.CR, xp);
                }
                else
                {
                    _cr = _monsterModel.CR;
                }
            }
            else
            {
                _cr = "Unknown";
            }

            _passivePerception = _monsterModel.PassivePerception.ToString();
            _speed             = !String.IsNullOrWhiteSpace(_monsterModel.Speed) ? _stringService.CapitalizeWords(_monsterModel.Speed) : "Unknown";

            _strength     = _monsterModel.Strength.ToString();
            _dexterity    = _monsterModel.Dexterity.ToString();
            _constitution = _monsterModel.Constitution.ToString();
            _intelligence = _monsterModel.Intelligence.ToString();
            _wisdom       = _monsterModel.Wisdom.ToString();
            _charisma     = _monsterModel.Charisma.ToString();

            _strengthBonus     = _statService.GetStatBonusString(_monsterModel.Strength);
            _dexterityBonus    = _statService.GetStatBonusString(_monsterModel.Dexterity);
            _constitutionBonus = _statService.GetStatBonusString(_monsterModel.Constitution);
            _intelligenceBonus = _statService.GetStatBonusString(_monsterModel.Intelligence);
            _wisdomBonus       = _statService.GetStatBonusString(_monsterModel.Wisdom);
            _charismaBonus     = _statService.GetStatBonusString(_monsterModel.Charisma);

            _strengthSave     = _monsterModel.Saves.ContainsKey(Ability.Strength) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Strength]) : _strengthBonus;
            _dexteritySave    = _monsterModel.Saves.ContainsKey(Ability.Dexterity) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Dexterity]) : _dexterityBonus;
            _constitutionSave = _monsterModel.Saves.ContainsKey(Ability.Constitution) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Constitution]) : _constitutionBonus;
            _intelligenceSave = _monsterModel.Saves.ContainsKey(Ability.Intelligence) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Intelligence]) : _intelligenceBonus;
            _wisdomSave       = _monsterModel.Saves.ContainsKey(Ability.Wisdom) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Wisdom]) : _wisdomBonus;
            _charismaSave     = _monsterModel.Saves.ContainsKey(Ability.Charisma) ? _statService.AddPlusOrMinus(_monsterModel.Saves[Ability.Charisma]) : _charismaBonus;

            foreach (KeyValuePair <Skill, int> skillPair in _monsterModel.Skills)
            {
                string skillString = _stringService.GetString(skillPair.Key);
                string skillRoll   = _statService.AddPlusOrMinus(skillPair.Value);
                _skills[skillString] = skillRoll;
            }

            _vulnerabilities     = !String.IsNullOrWhiteSpace(_monsterModel.Vulnerabilities) ? _stringService.CapitalizeWords(_monsterModel.Vulnerabilities) : "None";
            _resistances         = !String.IsNullOrWhiteSpace(_monsterModel.Resistances) ? _stringService.CapitalizeWords(_monsterModel.Resistances) : "None";
            _immunities          = !String.IsNullOrWhiteSpace(_monsterModel.Immunities) ? _stringService.CapitalizeWords(_monsterModel.Immunities) : "None";
            _conditionImmunities = !String.IsNullOrWhiteSpace(_monsterModel.ConditionImmunities) ? _stringService.CapitalizeWords(_monsterModel.ConditionImmunities) : "None";
            _senses      = !String.IsNullOrWhiteSpace(_monsterModel.Senses) ? _stringService.CapitalizeWords(_monsterModel.Senses) : "None";
            _languages   = _monsterModel.Languages.Count > 0 ? _stringService.CapitalizeWords(String.Join(", ", _monsterModel.Languages)) : "None";
            _environment = !String.IsNullOrWhiteSpace(_monsterModel.Environment) ? _stringService.CapitalizeWords(_monsterModel.Environment) : "Unknown";

            _description = _monsterModel.Description;

            foreach (TraitModel traitModel in _monsterModel.Traits)
            {
                _traits.Add(new TraitViewModel(traitModel));
            }

            foreach (MonsterActionModel monsterAction in _monsterModel.Actions)
            {
                _actions.Add(new MonsterActionViewModel(monsterAction));
            }

            foreach (MonsterActionModel monsterAction in _monsterModel.Reactions)
            {
                _reactions.Add(new MonsterActionViewModel(monsterAction));
            }

            foreach (MonsterActionModel monsterAction in _monsterModel.LegendaryActions)
            {
                _legendaryActions.Add(new MonsterActionViewModel(monsterAction));
            }

            _spellSlots = new List <string>(_monsterModel.SpellSlots);
            while (_spellSlots.Count < 9)
            {
                _spellSlots.Add("0");
            }

            _spells = new List <string>(_monsterModel.Spells);

            _rollAbilityBonusCommand = new RelayCommand(obj => true, obj => RollAbilityBonus((Ability)obj));
            _rollAbilitySaveCommand  = new RelayCommand(obj => true, obj => RollAbilitySave((Ability)obj));
            _rollSkillCommand        = new RelayCommand(obj => true, obj => RollSkill((string)obj));
            _rollAttackToHitCommand  = new RelayCommand(obj => true, obj => RollAttackToHit((MonsterAttackViewModel)obj));
            _rollAttackDamageCommand = new RelayCommand(obj => true, obj => RollAttackDamage((MonsterAttackViewModel)obj));
            _showSpellDialogCommand  = new RelayCommand(obj => true, obj => ShowSpellDialog((string)obj));
        }
        private bool IsAlignment(MonsterModel monsterModel, Alignment alignment)
        {
            string alignmentString = _stringService.GetString(alignment).ToLower();

            return(alignment == Alignment.None || monsterModel.Alignment.ToLower() == alignmentString);
        }
        /// <summary>
        /// Creates an instance of <see cref="RandomEncounterDialogViewModel"/>
        /// </summary>
        public RandomEncounterDialogViewModel(List <EncounterCharacterModel> encounterCharacters)
        {
            _encounterCharacters = encounterCharacters;

            foreach (EncounterChallenge encounterChallenge in Enum.GetValues(typeof(EncounterChallenge)))
            {
                if (encounterChallenge != EncounterChallenge.Unknown)
                {
                    _difficultyOptions.Add(new KeyValuePair <EncounterChallenge, string>(encounterChallenge, _stringService.GetString(encounterChallenge)));
                }
            }
            _selectedDifficultyOption = _difficultyOptions.FirstOrDefault();

            _environmentOptions.Add(new KeyValuePair <string, string>(null, "Any Environment"));
            foreach (MonsterModel monster in _compendium.Monsters)
            {
                if (!String.IsNullOrWhiteSpace(monster.Environment))
                {
                    foreach (string environmentSplit in monster.Environment.Split(new char[] { ',' }))
                    {
                        string environment = environmentSplit.Trim();
                        if (!_environmentOptions.Any(x => x.Value.ToLower() == environment.ToLower()))
                        {
                            _environmentOptions.Add(new KeyValuePair <string, string>(environment, _stringService.CapitalizeWords(environment)));
                        }
                    }
                }
            }
            _selectedEnvironmentOption = _environmentOptions.FirstOrDefault();

            _minMonsters = 1;
            _maxMonsters = 10;

            _acceptCommand             = new RelayCommand(obj => true, obj => OnAccept());
            _rejectCommand             = new RelayCommand(obj => true, obj => OnReject());
            _generateMonstersCommand   = new RelayCommand(obj => true, obj => GenerateMonsters());
            _viewMonsterDetailsCommand = new RelayCommand(obj => true, obj => ViewMonsterDetails((EncounterMonsterViewModel)obj));
        }
Exemplo n.º 29
0
        /// <summary>
        /// Creates an instance of <see cref="ClassViewModel"/>
        /// </summary>
        public ClassViewModel(ClassModel classModel)
        {
            _classModel = classModel;

            _hitDie = "d" + _classModel.HitDie.ToString();

            List <string> abilities = new List <string>();

            for (int i = 0; i < _classModel.AbilityProficiencies.Count; ++i)
            {
                abilities.Add(_stringService.GetString(_classModel.AbilityProficiencies[i]));
            }
            _abilities = String.Join(", ", abilities);

            _spellAbility = _classModel.SpellAbility == Ability.None ? "None" : _stringService.GetString(_classModel.SpellAbility);

            _spellTableVisible = _classModel.SpellAbility != Ability.None && _classModel.SpellSlots.Any();

            int max = 0;

            foreach (string spellSlot in _classModel.SpellSlots)
            {
                max = Math.Max(max, spellSlot.Split(new char[] { ',' }).Length);
            }

            if (max > 0)
            {
                _spellTableHeaders.Add("Lvl");
                _spellTableHeaders.Add("C");
                for (int i = 1; i < max; ++i)
                {
                    _spellTableHeaders.Add(NumberToOrdinal(i));
                }

                for (int i = 0; i < _classModel.SpellSlots.Count; ++i)
                {
                    List <string> slotsAtLevel = new List <string>();

                    slotsAtLevel.Add((_classModel.SpellStartLevel + i).ToString());

                    string[] slotStrings = _classModel.SpellSlots[i].Split(new char[] { ',' });
                    for (int j = 0; j < max; ++j)
                    {
                        if (j < slotStrings.Length)
                        {
                            string slot = slotStrings[j].Trim();
                            slotsAtLevel.Add(String.IsNullOrWhiteSpace(slot) ? "0" : slot);
                        }
                        else
                        {
                            slotsAtLevel.Add("0");
                        }
                    }

                    _spellSlotTable.Add(slotsAtLevel);
                }
            }

            foreach (AutoLevelModel autoLevel in _classModel.AutoLevels)
            {
                if (autoLevel.Features.Count > 0)
                {
                    List <FeatureViewModel> features = new List <FeatureViewModel>();
                    foreach (FeatureModel featureModel in autoLevel.Features.OrderBy(x => x.Name))
                    {
                        features.Add(new FeatureViewModel(featureModel));
                    }

                    if (!_featuresByLevel.ContainsKey(autoLevel.Level))
                    {
                        _featuresByLevel[autoLevel.Level] = features;
                    }
                    else
                    {
                        _featuresByLevel[autoLevel.Level].AddRange(features);
                    }

                    _featuresByLevel[autoLevel.Level] = _featuresByLevel[autoLevel.Level].OrderBy(x => x.Name).ToList();
                }
            }

            foreach (FeatureModel featureModel in _classModel.TableFeatures)
            {
                string        name   = featureModel.Name;
                List <string> values = new List <string>();
                foreach (string value in featureModel.Text.Split(new char[] { ',' }))
                {
                    values.Add(value);
                }
                while (values.Count < 20)
                {
                    values.Add("-");
                }

                _tableFeatures.Add(new Tuple <string, List <string> >(name, values));
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates an instance of <see cref="MonsterSearchInput"/>
        /// </summary>
        public MonsterSearchInput(Compendium compendium, StringService stringService, StatService statService)
        {
            _compendium    = compendium;
            _stringService = stringService;
            _statService   = statService;

            foreach (MonsterSortOption sort in Enum.GetValues(typeof(MonsterSortOption)))
            {
                _sortOptions.Add(new KeyValuePair <MonsterSortOption, string>(sort, sort.ToString().Replace("_", " ")));
            }

            _sizes.Add(new KeyValuePair <CreatureSize, string>(CreatureSize.None, "Any Size"));
            foreach (CreatureSize size in Enum.GetValues(typeof(CreatureSize)))
            {
                if (size != CreatureSize.None)
                {
                    _sizes.Add(new KeyValuePair <CreatureSize, string>(size, _stringService.GetString(size)));
                }
            }

            _alignments.Add(new KeyValuePair <Alignment, string>(Enums.Alignment.None, "Any Alignment"));
            foreach (Alignment alignment in Enum.GetValues(typeof(Alignment)))
            {
                if (alignment != Enums.Alignment.None)
                {
                    _alignments.Add(new KeyValuePair <Alignment, string>(alignment, _stringService.GetString(alignment)));
                }
            }

            foreach (MonsterModel monster in _compendium.Monsters)
            {
                if (!_types.Any(x => x.Value.ToLower() == monster.Type.ToLower()))
                {
                    _types.Add(new KeyValuePair <string, string>(monster.Type, _stringService.CapitalizeWords(monster.Type)));
                }

                int number = 0;
                if (!_crs.Any(x => x.Value == monster.CR) && (monster.CR.Contains("/") || Int32.TryParse(monster.CR, out number)))
                {
                    _crs.Add(new KeyValuePair <string, string>(monster.CR, monster.CR));
                }

                if (!String.IsNullOrWhiteSpace(monster.Environment))
                {
                    foreach (string environmentSplit in monster.Environment.Split(new char[] { ',' }))
                    {
                        string environment = environmentSplit.Trim();
                        if (!_environments.Any(x => x.Value.ToLower() == environment.ToLower()))
                        {
                            _environments.Add(new KeyValuePair <string, string>(environment, _stringService.CapitalizeWords(environment)));
                        }
                    }
                }
            }

            _types = _types.OrderBy(x => x.Value).ToList();
            _types.Insert(0, new KeyValuePair <string, string>(null, "Any Type"));

            _crs = _crs.OrderBy(x => _statService.CRToFloat(x.Value)).ToList();
            _crs.Insert(0, new KeyValuePair <string, string>("-", "Unknown"));
            _crs.Insert(0, new KeyValuePair <string, string>(null, "Any CR"));

            _environments = _environments.OrderBy(x => x.Value).ToList();
            _environments.Insert(0, new KeyValuePair <string, string>(null, "Any Environment"));

            Reset();
        }