private void SetupArmor() { foreach (Armor.ArmorSlot armorType in Items.Armor.ArmorSlotEnum) { Armor.Add(armorType, new ArmorState()); } }
/// <summary> /// Updates the player inventory: /// </summary> public void UpdateInventory() { Armor.Clear(); ArcaneItems.Clear(); InventoryItem.Clear(); Weapons.Clear(); foreach (var item in _inventory) { if (item.GameItem is ItemArmor) { Armor.Add(item); } if (item.GameItem is ItemArcane) { ArcaneItems.Add(item); } if (item.GameItem is ItemWeapon) { Weapons.Add(item); } if (item.GameItem is ItemInventory) { InventoryItem.Add(item); } } CalculateInventoryValue(); }
private void SetArmorParts(List <SpriteRenderer> renderers, List <Sprite> armor, Color?color) { foreach (var r in renderers) { var mapping = r.GetComponent <SpriteMapping>(); var sprite = armor?.SingleOrDefault(j => mapping.SpriteName == j.name || mapping.SpriteNameFallback.Contains(j.name)); if (sprite != null) { if (Armor == null) { Armor = new List <Sprite>(); } if (sprite.name == mapping.SpriteName) { Armor.RemoveAll(i => i == null || i.name == mapping.SpriteName); } else { Armor.RemoveAll(i => i == null || mapping.SpriteNameFallback.Contains(i.name)); } Armor.Add(sprite); } if (color != null) { r.color = color.Value; } } }
public ViewModel() { String[] names = { "VAAN", "ASHE", "FRAN", "BALTHIER", "BASCH", "PENELO" }; for (uint i = 0; i < names.Length; i++) { Party.Add(new Charactor(0x2210 + i * 456, names[i])); } for (uint i = 0; i < 64; i++) { Consumable.Add(new Item(0xDACC + i * 2, 0x6948, 0)); } for (uint i = 0; i < 200; i++) { Weapon.Add(new Item(0xDB4C + i * 2, 0x69CA, 0x1001)); } for (uint i = 0; i < 140; i++) { Armor.Add(new Item(0xDCDC + i * 2, 0x6B58, 0x10C8)); } for (uint i = 0; i < 120; i++) { Accessorie.Add(new Item(0xDDF4 + i * 2, 0x6C70, 0x1154)); } for (uint i = 0; i < 24; i++) { Technique.Add(new Technique(i)); } for (uint i = 0; i < 81; i++) { Magic.Add(new Magic(i)); } }
// TODO: AddArmorImpl, etc are small enough that they would probably better inline. private IObservable <ArmorViewModel> AddArmorImpl() { var armorVm = new ArmorViewModel(); Armor.Add(armorVm); return(Observable.Return(armorVm)); }
internal void CompChange(bool add, WeaponComponent comp) { if (add) { if (WeaponsIdx.ContainsKey(comp)) { Log.Line($"CompAddFailed:<{comp.MyCube.EntityId}> - comp({comp.MyCube.DebugName}[{comp.MyCube.BlockDefinition.Id.SubtypeName}]) already existed in {MyGrid.DebugName}"); return; } if (comp.HasArmor) { for (int i = 0; i < comp.Platform.Weapons.Length; i++) { var w = comp.Platform.Weapons[i]; if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon) { Armor.Add(w.Comp.MyCube, w); } } Session.ArmorCubes.Add(comp.MyCube, comp); } WeaponsIdx.Add(comp, Weapons.Count); //Session.IdToCompMap.Add(comp.MyCube.EntityId, comp); Weapons.Add(comp); } else { int idx; if (!WeaponsIdx.TryGetValue(comp, out idx)) { Log.Line($"CompRemoveFailed: <{comp.MyCube.EntityId}> - {Weapons.Count}[{WeaponsIdx.Count}]({WeaponBase.Count}) - {Weapons.Contains(comp)}[{Weapons.Count}] - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.ContainsKey(comp.MyCube)} - {Session.GridTargetingAIs[comp.MyCube.CubeGrid].WeaponBase.Count} "); return; } if (comp.HasArmor) { for (int i = 0; i < comp.Platform.Weapons.Length; i++) { var w = comp.Platform.Weapons[i]; if (w.System.Armor != WeaponDefinition.HardPointDef.HardwareDef.ArmorState.IsWeapon) { Armor.Remove(w.Comp.MyCube); } } Session.ArmorCubes.Remove(comp.MyCube); } Weapons.RemoveAtFast(idx); if (idx < Weapons.Count) { WeaponsIdx[Weapons[idx]] = idx; } //Session.IdToCompMap.Remove(comp.MyCube.EntityId); WeaponsIdx.Remove(comp); } }
private void SetupArmor() { foreach (ArmorFactory.ArmorSlot armorType in ArmorFactory.ArmorSlotEnum) { Armor.Add(armorType, new ItemState()); } Armor.OnDictionaryChanged += Armor_OnDictionaryChanged; }
private void SetupArmor() { Weapon = new ItemState(); Weapon.IdChanged += Weapon_IdChanged; foreach (ArmorFactory.ArmorSlot armorType in ArmorFactory.ArmorSlotEnum) { var armorState = new ItemState(); armorState.IdChanged += ArmorState_IdChanged; Armor.Add(armorType, armorState); } Armor.OnDictionaryChanged += Armor_OnDictionaryChanged; }
public bool AddArmor(int a, int q) { if (Armor.Count >= 3) { return(false); } Armor.Add(new ArmorItem { ID = a, Quality = q }); SortEquipment(); return(true); }
private void SetArmorParts(string part, List <Sprite> armor) { var sprite = armor?.SingleOrDefault(j => j.name == part); Armor?.RemoveAll(i => i == null || i.name == part); if (sprite != null) { if (Armor == null) { Armor = new List <Sprite>(); } Armor.Add(sprite); } }
private void SetArmorPart(string part, List <Sprite> armor) { var sprite = armor.Single(j => j.name == part); Armor.RemoveAll(i => i == null); for (var i = 0; i < Armor.Count; i++) { if (Armor[i] != null && Armor[i].name == part) { Armor[i] = sprite; return; } } Armor.Add(sprite); }
// Could use generic type and type checking to only have one func public void BuyItem(Thing item) { // this function takes an item checks if a user can afford it // then type checks it to and adds it to list unless player already owns it // then subtracts cost from gold if (Gold < item.Cost) { LineHelpers.PrintLineWithContinue("You cannot afford this item."); return; } if (item is Weapon) { Weapon weapon = item as Weapon; if (this.Weapons.Contains(weapon)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Weapons.Add(item as Weapon); } else if (item is Armor) { Armor armor = item as Armor; if (this.Armor.Contains(armor)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Armor.Add(armor); } else if (item is Consumable) { Consumable consumable = item as Consumable; if (this.Consumables.Contains(consumable)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Consumables.Add(consumable); } LineHelpers.PrintLineWithContinue("The item has been added to your inventory."); Gold -= item.Cost; }
public void AddItem(WorldObject wo, bool logStats) { // Weapon Properties double missileDefMod = 0.00f; double magicDefMod = 0.00f; double wield = 0.00f; int value = 0; TotalItems++; // Loop depending on how many items you are creating for (int i = 0; i < 1; i++) { var testItem = wo; if (testItem == null) { NullCount++; continue; } switch (testItem.ItemType) { case ItemType.None: break; case ItemType.MeleeWeapon: MeleeWeaponCount++; bool cantrip = false; if (testItem.EpicCantrips.Count > 0) { cantrip = true; } if (testItem.LegendaryCantrips.Count > 0) { cantrip = true; } string strikeType = "N"; if (testItem.WeaponMagicDefense != null) { magicDefMod = testItem.WeaponMagicDefense.Value; } if (testItem.Value != null) { value = testItem.Value.Value; } if (testItem.WeaponMissileDefense != null) { missileDefMod = testItem.WeaponMissileDefense.Value; } if (testItem.WieldDifficulty != null) { wield = testItem.WieldDifficulty.Value; } if (testItem.WeaponSkill == Skill.TwoHandedCombat) { if (logStats) { MeleeWeapons.Add($"{testItem.WeaponSkill},{wield},{testItem.Damage.Value},{strikeType},{testItem.DamageVariance.Value},{testItem.WeaponDefense.Value},{magicDefMod},{missileDefMod},{cantrip},{value},{testItem.EncumbranceVal},{testItem.Name}"); } else { MeleeWeapons.Add($"{testItem.WeaponSkill}\t {wield}\t {testItem.Damage.Value}\t\t {strikeType} \t\t {testItem.DamageVariance.Value}\t\t {testItem.WeaponDefense.Value}\t\t {magicDefMod}\t\t {missileDefMod}\t\t {cantrip}\t{value}\t{testItem.EncumbranceVal} \t {testItem.Name}"); } } else { if ((testItem.W_AttackType & AttackType.TripleStrike) != 0) { strikeType = "3x"; } else if ((testItem.W_AttackType & AttackType.DoubleStrike) != 0) { strikeType = "2x"; } if (logStats) { MeleeWeapons.Add($"{testItem.WeaponSkill},{wield},{testItem.Damage.Value},{strikeType},{testItem.DamageVariance.Value},{testItem.WeaponDefense.Value},{magicDefMod},{missileDefMod},{cantrip},{value},{testItem.EncumbranceVal},{testItem.Name}"); } else { MeleeWeapons.Add($" {testItem.WeaponSkill}\t\t {wield}\t {testItem.Damage.Value}\t\t {strikeType}\t\t {testItem.DamageVariance.Value}\t\t {testItem.WeaponDefense.Value}\t\t {magicDefMod}\t\t {missileDefMod}\t\t {cantrip}\t{value}\t{testItem.EncumbranceVal} \t {testItem.Name}"); } } break; case ItemType.Armor: ArmorCount++; string equipmentSet = "None "; cantrip = false; // float cantripSpells = 0; var epicCantripSpells = testItem.EpicCantrips.Keys; if (testItem.EpicCantrips.Count > 0) { cantrip = true; } if (testItem.LegendaryCantrips.Count > 0) { cantrip = true; } if (testItem.EquipmentSetId != null) { equipmentSet = testItem.EquipmentSetId.ToString(); } if (logStats) { Armor.Add($"{testItem.ArmorLevel},{testItem.ItemDifficulty},{testItem.Value.Value},{testItem.EncumbranceVal},{testItem.EpicCantrips.Count},{testItem.LegendaryCantrips.Count},{equipmentSet},{testItem.Name}"); } else { Armor.Add($" {testItem.ArmorLevel}\t{testItem.ItemDifficulty}\t{testItem.Value.Value}\t{testItem.EncumbranceVal}\t{testItem.EpicCantrips.Count}\t{testItem.LegendaryCantrips.Count}\t{equipmentSet}\t\t\t{testItem.Name}"); } if (testItem.Name.Contains("Sheild")) // typo? { break; } if (testItem.ArmorLevel > MaxAL) { MaxAL = testItem.ArmorLevel.Value; MaxALItem = testItem.Name; } if (testItem.ArmorLevel < MinAL) { MinAL = testItem.ArmorLevel.Value; MinALItem = testItem.Name; } break; case ItemType.Clothing: if (testItem.Name.Contains("Cloak")) { string cloakSet = "None "; if (testItem.EquipmentSetId != null) { cloakSet = testItem.EquipmentSetId.ToString(); } CloakCount++; if (logStats) { Cloaks.Add($"{testItem.ItemMaxLevel},{testItem.WieldDifficulty},{testItem.CloakWeaveProc.Value},{testItem.Value.Value},{cloakSet}"); } else { Cloaks.Add($" {testItem.ItemMaxLevel}\t {testItem.WieldDifficulty}\t {testItem.CloakWeaveProc.Value}\t {testItem.Value.Value}\t {cloakSet}"); } } else { ClothingCount++; } break; case ItemType.Jewelry: JewelryCount++; string jewelrySlot = ""; switch (testItem.ValidLocations) { case EquipMask.NeckWear: JewelryNecklaceCount++; jewelrySlot = "Neck"; break; case EquipMask.WristWear: JewelryBraceletCount++; jewelrySlot = "Brace"; break; case EquipMask.FingerWear: JewelryRingCount++; jewelrySlot = "Ring"; break; case EquipMask.TrinketOne: JewelryTrinketCount++; jewelrySlot = "Trink"; break; default: // Console.WriteLine(testItem.Name); break; } if (logStats) { Jewelry.Add($"{jewelrySlot},{testItem.ItemDifficulty},{testItem.Value}"); } else { Jewelry.Add($" {jewelrySlot}\t {testItem.ItemDifficulty}\t {testItem.Value}"); } break; case ItemType.Creature: break; case ItemType.Food: Food++; break; case ItemType.Money: break; case ItemType.Misc: string spirit = "Spirit"; string potionA = "Philtre"; string potionB = "Elixir"; string potionC = "Tonic"; string potionD = "Brew"; string potionE = "Potion"; string potionF = "Draught"; string potionG = "Tincture"; string healingKits = "Kit"; string spellcompGlyph = "Glyph"; string spellcompInk = "Ink"; string spellcompQuill = "Quill"; if (testItem.Name.Contains(spirit)) { Spirits++; } else if (testItem is PetDevice petDevice) { PetsCount++; int totalRatings = 0; int damage = 0; int damageResist = 0; int crit = 0; int critDamage = 0; int critDamageResist = 0; int critResist = 0; int petLevel = 0; if (petDevice.UseRequiresSkillLevel == 570) { petLevel = 200; } else if (petDevice.UseRequiresSkillLevel == 530) { petLevel = 180; } else if (petDevice.UseRequiresSkillLevel == 475) { petLevel = 150; } else if (petDevice.UseRequiresSkillLevel == 430) { petLevel = 125; } else if (petDevice.UseRequiresSkillLevel == 400) { petLevel = 100; } else if (petDevice.UseRequiresSkillLevel == 370) { petLevel = 80; } else if (petDevice.UseRequiresSkillLevel == 310) { petLevel = 50; } if (petDevice.GearDamage != null) { totalRatings += petDevice.GearDamage.Value; damage = petDevice.GearDamage.Value; } if (petDevice.GearDamageResist != null) { totalRatings += petDevice.GearDamageResist.Value; damageResist = petDevice.GearDamageResist.Value; } if (petDevice.GearCrit != null) { totalRatings += petDevice.GearCrit.Value; crit = petDevice.GearCrit.Value; } if (petDevice.GearCritDamage != null) { totalRatings += petDevice.GearCritDamage.Value; critDamage = petDevice.GearCritDamage.Value; } if (petDevice.GearCritDamageResist != null) { totalRatings += petDevice.GearCritDamageResist.Value; critDamageResist = petDevice.GearCritDamageResist.Value; } if (petDevice.GearCritResist != null) { totalRatings += petDevice.GearCritResist.Value; critResist = petDevice.GearCritResist.Value; } if (logStats) { Pets.Add($"{petLevel},{damage},{damageResist},{crit},{critDamage},{critDamageResist},{critResist},{totalRatings}"); } else { Pets.Add($" {petLevel}\t {damage}\t {damageResist}\t {crit}\t {critDamage}\t {critDamageResist}\t {critResist}\t {totalRatings}"); } if (totalRatings > 99) { PetRatingsOverHundred++; } else if (totalRatings > 89) { PetRatingsOverNinety++; } else if (totalRatings > 79) { PetRatingsOverEighty++; } else if (totalRatings > 69) { PetRatingsOverSeventy++; } else if (totalRatings > 59) { PetRatingsOverSixty++; } else if (totalRatings > 49) { PetRatingsOverFifty++; } else if (totalRatings > 39) { PetRatingsOverForty++; } else if (totalRatings > 29) { PetRatingsOverThirty++; } else if (totalRatings > 19) { PetRatingsOverTwenty++; } else if (totalRatings > 9) { PetRatingsOverTen++; } else if (totalRatings > 0) { PetRatingsEqualOne++; } else if (totalRatings < 1) { PetRatingsEqualZero++; } } else if (testItem.Name.Contains(potionA) || testItem.Name.Contains(potionB) || testItem.Name.Contains(potionC) || testItem.Name.Contains(potionD) || testItem.Name.Contains(potionE) || testItem.Name.Contains(potionF) || testItem.Name.Contains(potionG)) { Potions++; } else if (testItem.Name.Contains(spellcompGlyph) || testItem.Name.Contains(spellcompInk) || testItem.Name.Contains(spellcompQuill)) { LevelEightComp++; } else if (testItem.Name.Contains(healingKits)) { HealingKit++; } else { // Console.WriteLine($"ItemType.Misc Name={testItem.Name}"); Misc++; } break; case ItemType.MissileWeapon: double eleBonus = 0.00f; double damageMod = 0.00f; string missileType = "Other"; if (testItem.AmmoType != null) { switch (testItem.AmmoType.Value) { case AmmoType.None: break; case AmmoType.Arrow: missileType = "Bow"; MissileWeaponCount++; break; case AmmoType.Bolt: missileType = "X Bow"; MissileWeaponCount++; break; case AmmoType.Atlatl: missileType = "Thrown"; MissileWeaponCount++; break; case AmmoType.ArrowCrystal: break; case AmmoType.BoltCrystal: break; case AmmoType.AtlatlCrystal: break; case AmmoType.ArrowChorizite: break; case AmmoType.BoltChorizite: break; case AmmoType.AtlatlChorizite: break; default: break; } } if (testItem.WeaponMagicDefense != null) { magicDefMod = testItem.WeaponMagicDefense.Value; } if (testItem.Value != null) { value = testItem.Value.Value; } if (testItem.WeaponMissileDefense != null) { missileDefMod = testItem.WeaponMissileDefense.Value; } if (testItem.WieldDifficulty != null) { wield = testItem.WieldDifficulty.Value; } if (testItem.ElementalDamageBonus != null) { eleBonus = testItem.ElementalDamageBonus.Value; } if (testItem.DamageMod != null) { damageMod = testItem.DamageMod.Value; } if (missileType == "Other") { DinnerWare++; } else { if (logStats) { MissileWeapons.Add($"{missileType},{wield},{damageMod},{eleBonus},{testItem.WeaponDefense.Value},{magicDefMod},{missileDefMod},{value},{testItem.EncumbranceVal}"); } else { MissileWeapons.Add($"{missileType}\t {wield}\t {damageMod}\t\t{eleBonus}\t\t {testItem.WeaponDefense.Value}\t\t {magicDefMod}\t\t {missileDefMod}\t\t {value}\t {testItem.EncumbranceVal}"); } } break; case ItemType.Container: break; case ItemType.Useless: // Console.WriteLine($"ItemType.Useless Name={testItem.Name}"); break; case ItemType.Gem: string aetheriaColor = "None"; if (Server.Entity.Aetheria.IsAetheria(testItem.WeenieClassId)) { AetheriaCount++; if (testItem.WieldDifficulty == 75) { aetheriaColor = "Blue "; } else if (testItem.WieldDifficulty == 150) { aetheriaColor = "Yellow"; } else if (testItem.WieldDifficulty == 225) { aetheriaColor = "Red "; } if (logStats) { Aetheria.Add($"{aetheriaColor},{testItem.ItemMaxLevel}"); } else { Aetheria.Add($" {aetheriaColor}\t {testItem.ItemMaxLevel}"); } } else { GemCount++; } break; case ItemType.SpellComponents: SpellComponents++; break; case ItemType.Writable: string scrolls = "Scroll"; if (testItem.Name.Contains(scrolls)) { Scrolls++; } else { Console.WriteLine($"ItemType.Writeable Name={testItem.Name}"); } break; case ItemType.Key: Key++; break; case ItemType.Caster: CasterCount++; double eleMod = 0.00f; if (testItem.WeaponMagicDefense != null) { magicDefMod = testItem.WeaponMagicDefense.Value; } if (testItem.Value != null) { value = testItem.Value.Value; } if (testItem.WeaponMissileDefense != null) { missileDefMod = testItem.WeaponMissileDefense.Value; } if (testItem.WieldDifficulty != null) { wield = testItem.WieldDifficulty.Value; } if (testItem.ElementalDamageMod != null) { eleMod = testItem.ElementalDamageMod.Value; } if (testItem.ItemMaxMana != null) { ItemMaxMana = testItem.ItemMaxMana.Value; } if (logStats) { CasterWeapons.Add($"{wield},{eleMod},{testItem.WeaponDefense.Value},{magicDefMod},{missileDefMod},{value},{testItem.EncumbranceVal},{ItemMaxMana}"); } else { CasterWeapons.Add($" {wield}\t {eleMod}\t\t {testItem.WeaponDefense.Value}\t\t {magicDefMod}\t\t {missileDefMod}\t\t {value}\t {testItem.EncumbranceVal} \t {ItemMaxMana}"); } break; case ItemType.Portal: break; case ItemType.Lockable: break; case ItemType.PromissoryNote: break; case ItemType.ManaStone: ManaStone++; break; case ItemType.Service: break; case ItemType.MagicWieldable: break; case ItemType.CraftCookingBase: OtherCount++; break; case ItemType.CraftAlchemyBase: OtherCount++; break; case ItemType.CraftFletchingBase: OtherCount++; break; case ItemType.CraftAlchemyIntermediate: OtherCount++; break; case ItemType.CraftFletchingIntermediate: OtherCount++; break; case ItemType.LifeStone: break; case ItemType.TinkeringTool: OtherCount++; break; case ItemType.TinkeringMaterial: OtherCount++; break; case ItemType.Gameboard: break; case ItemType.PortalMagicTarget: break; case ItemType.LockableMagicTarget: break; case ItemType.Vestements: break; case ItemType.Weapon: break; case ItemType.WeaponOrCaster: break; case ItemType.Item: Console.WriteLine($"ItemType.item Name={testItem.Name}"); break; case ItemType.RedirectableItemEnchantmentTarget: break; case ItemType.ItemEnchantableTarget: break; case ItemType.VendorShopKeep: break; case ItemType.VendorGrocer: break; default: OtherCount++; break; } /*switch (testItem.ItemType) * { * case ItemType.Armor: * break; * case ItemType.MeleeWeapon: * break; * case ItemType.Caster: * break; * case ItemType.MissileWeapon: * break; * case ItemType.Jewelry: * break; * case ItemType.Gem: * break; * case ItemType.Clothing: * break; * default: * break; * }*/ if (testItem.ItemMaxMana != null) { if (testItem.ItemMaxMana > MaxMana) { MaxMana = testItem.ItemMaxMana.Value; } if (testItem.ItemMaxMana < MinMana) { MinMana = testItem.ItemMaxMana.Value; } HasManaCount++; TotalMaxMana += testItem.ItemMaxMana.Value; } if (testItem.Name == null) { Console.WriteLine("*Name is Null*"); continue; } if (testItem.EpicCantrips.Count > 0) { EpicCantripCount++; } if (testItem.LegendaryCantrips.Count > 0) { LegendaryCantripCount++; } } }
private void SetFromPlan(CharacterPlan plan) { EnsureTwentyLevels(plan); CharacterName = plan.Name; Alignment = plan.Alignment; Race = plan.Race; Speed = plan.Speed; Age = plan.Age; HeightFeet = plan.HeightFeet; HeightInches = plan.HeightInches; Weight = plan.Weight; EyeColor = plan.EyeColor; HairColor = plan.HairColor; SkinColor = plan.SkinColor; CharacterBackground = plan.Background; ClassPlan.ClassName = plan.ClassPlan.ClassName; ClassPlan.ArmorProficiencies = string.Join(", ", plan.ClassPlan.ArmorProficiencies ?? new string[0]); ClassPlan.WeaponProficiencies = string.Join(", ", plan.ClassPlan.WeaponProficiencies ?? new string[0]); ClassPlan.ToolProficiencies = string.Join(", ", plan.ClassPlan.ToolProficiencies ?? new string[0]); var saveProfs = plan.ClassPlan.SaveProficiencies ?? new string[0]; foreach (var saveProfVm in ClassPlan.SaveProficiencies) { saveProfVm.IsProficient = saveProfs.Contains(saveProfVm.Ability.Abbreviation); } var skillProfs = plan.ClassPlan.SkillProficiencies ?? new string[0]; foreach (var skillProfVm in ClassPlan.SkillProficiencies) { skillProfVm.IsProficient = skillProfs.Contains(skillProfVm.Skill.SkillName); } LevelPlans.Clear(); foreach (var lp in plan.LevelPlans) { var levelPlanVm = new LevelPlanViewModel { Level = lp.Level }; levelPlanVm.AbilityScoreImprovements.AddRange( Ability.All.Select(a => new AbilityScoreImprovementViewModel { Ability = a, })); foreach (var kvp in lp.AbilityScoreImprovements ?? new Dictionary <string, int>()) { var asiVm = levelPlanVm.AbilityScoreImprovements.First(asivm => asivm.Ability.Abbreviation == kvp.Key); asiVm.Improvement = kvp.Value; } foreach (var feature in lp.FeaturePlans ?? new FeaturePlan[0]) { var featureVm = new FeaturePlanViewModel() { FeatureName = feature.Name, Description = feature.Description, }; levelPlanVm.NewFeatures.Add(featureVm); } LevelPlans.Add(levelPlanVm); } Armor.Clear(); foreach (var armor in plan.Armor ?? new Armor[0]) { Armor.Add(new ArmorViewModel() { ArmorName = armor.Name, ArmorClass = armor.ArmorClass, ProficiencyGroup = armor.ProficiencyGroup, MaximumDexterityModifier = armor.MaximumDexterityModifier }); } Weapons.Clear(); foreach (var weapon in plan.Weapons ?? new Weapon[0]) { Weapons.Add(new WeaponViewModel { Name = weapon.Name, ProficiencyGroup = weapon.ProficiencyGroup, DamageDice = weapon.DamageDice, DamageType = weapon.DamageType, NormalRange = weapon.NormalRange, MaximumRange = weapon.MaximumRange, HasAmmunition = weapon.HasAmmunition, IsLight = weapon.IsLight }); } // Set snapshot level last so that the SnapshotMarkdown property is // set correctly. Otherwise it will try to render at a level that // isn't in the list yet. SnapshotLevel = plan.SnapshotLevel; }