public Character(String name, string gender, DndRace dndRace, DndClass dndClass) { this.name = name; this.gender = gender; this.dndRace = dndRace; this.dndClass = dndClass; }
public async Task <ActionResult> ShowClass(string id) { var dndClass = new DndClass(id); var newModel = await _helper.GetClassData(dndClass); newModel.Spells = GetSpellNames(dndClass.Name); return(View(newModel)); }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder .Entity <CombatProficiencies>() .HasKey(e => e.Value); builder .Entity <CharacterSheet>() .Property(e => e.WeaponAndArmorProficiencies) .HasConversion( v => CombatProficiencies.FlagListToInt(v.ToList()), v => CombatProficiencies.IntToFlagList(v)); builder .Entity <CharacterSheet>() .Property(e => e.Race) .HasConversion( v => v.Value, v => RaceEnum.FromValue(v)); builder .Entity <CharacterSheet>() .Property(e => e.Subrace) .HasConversion( v => v.Value, v => SubraceEnum.FromValue(v)); builder .Entity <CharacterSheet>() .Property(e => e.Class) .HasConversion( v => v.Value, v => DndClass.FromValue(v)); builder .Entity <CharacterSheet>() .Property(e => e.Gender) .HasConversion( v => v.Value, v => GenderEnum.FromValue(v)); builder .Entity <Comment>() .HasOne(e => e.Parent as Commentable) .WithMany() .OnDelete(DeleteBehavior.NoAction); builder .Entity <Commentable>() .HasOne(e => e.Author) .WithMany() .OnDelete(DeleteBehavior.NoAction); }
public void GetClassByIdTestSpellcaster() { DndClass expected = new DndClass() { Name = "Wizard", HitDie = 6, Spellcaster = true }; DndApi api = new DndApi(); var actual = api.GetClassById(12); Assert.That(actual.Name, Is.EqualTo(expected.Name)); Assert.That(actual.HitDie, Is.EqualTo(expected.HitDie)); Assert.That(actual.Spellcaster, Is.EqualTo(expected.Spellcaster)); }
public void GetClassByIdTest() { DndClass expected = new DndClass() { Name = "Barbarian", HitDie = 12, Spellcaster = false }; DndApi api = new DndApi(); var actual = api.GetClassById(1); Assert.That(actual.Name, Is.EqualTo(expected.Name)); Assert.That(actual.HitDie, Is.EqualTo(expected.HitDie)); Assert.That(actual.Spellcaster, Is.EqualTo(expected.Spellcaster)); }
public async Task <DndClass> GetClassData(DndClass myClass) { var url = $"classes/{myClass.Name.ToLower()}"; using (HttpResponseMessage response = await ApiClient.GetAsync(ApiClient.BaseAddress + url)) { if (response.IsSuccessStatusCode) { var data = await response.Content.ReadAsAsync <DndClass>(); // myClass = await response.Content.ReadAsAsync<DndClass>(); myClass.Hit_Die = data.Hit_Die; myClass.SpellCasting = data.SpellCasting; return(myClass); } else { throw new Exception(response.ReasonPhrase); } } }