public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Origin,Description")] Deities deities) { if (id != deities.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(deities); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeitiesExists(deities.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(deities)); }
public static void Reset() { OnEventCallbacks.Clear(); Player = null; Deities.Clear(); MakeDeities(); }
public async Task <IActionResult> Create([Bind("ID,Name,Origin,Description")] Deities deities) { if (ModelState.IsValid) { _context.Add(deities); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(deities)); }
private static void MakeDeities() { MakeLanguage(); var types = System.Reflection.Assembly .GetExecutingAssembly() .GetTypes(); var archetypes = types .Where(t => typeof(DeityArchetype).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) .Select(t => (DeityArchetype)Activator.CreateInstance(t)) .ToList(); var domains = types .Where(t => typeof(DeityDomain).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract) .Select(t => (DeityDomain)Activator.CreateInstance(t)) .ToList(); while (archetypes.Any() && domains.Any() && Deities.Count < 4) { var deity = new Deity { Name = MakeDeityName(), Pronoun = Globals.Random.NextDouble() < 0.5 ? "he" : "she", Archetype = archetypes[Random.Next(archetypes.Count)] }; archetypes.Remove(deity.Archetype); deity.FavorPerTeam["player"] = 0; deity.FavorPerTeam["undead"] = 0; deity.FavorPerTeam["plants"] = 0; while (domains.Any() && deity.Domains.Count < deity.Archetype.NumberOfDomains) { var domain = domains[Random.Next(domains.Count)]; domains.Remove(domain); deity.Domains.Add(domain); } Deities.Add(deity); } foreach (var deity in Deities) { deity.Finalize(Deities); foreach (var material in deity.GetPreferredMaterials()) { deity.Likes.Add($"things made of {material}"); } GD.Print(deity.GetFullTitle()); } }