public static void ApplySpecialAbility(Hero hero, SpecialAbility ability, DnDContext context) { if (ability.AblityType == SpecialAbilityType.Attack) { hero.SpecialAbilities.Add(ability); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; hero.AttackPower += ability.Power; hero.SpecialAbilities.Add(ability); context.SaveChanges(); Utility.PhaseTyper($"Your Attack power increased by {ability.Power}"); Utility.PhaseTyper($"Total Attack Power: {hero.AttackPower}"); Console.WriteLine(); Utility.PhaseTyper("Press any key to continue..."); Console.ReadKey(); } else if (ability.AblityType == SpecialAbilityType.Deffence) { hero.SpecialAbilities.Add(ability); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; hero.DeffencePower += ability.Power; hero.SpecialAbilities.Add(ability); context.SaveChanges(); Utility.PhaseTyper($"Your Deffence power increased by {ability.Power}"); Utility.PhaseTyper($"Total Defece Power: {hero.DeffencePower}"); Console.WriteLine(); Utility.PhaseTyper("Press any key to continue..."); Console.ReadKey(); } }
public static void Show(Hero hero) { Console.Clear(); Console.WriteLine("Items:"); Console.WriteLine(); Console.WriteLine("Press ESCAPE to go back to the Main Menu."); Console.WriteLine(); var context = new DnDContext(); var abilities = hero.SpecialAbilities.ToList(); foreach (var item in abilities) { Console.WriteLine($"Name: {item.Name}. This Ability would give you {item.Power} {item.AblityType}"); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press any key to go back to battle mode"); var key = Console.ReadKey(); switch (key.Key.ToString()) { case "Escape": MainMenu.Show(hero); break; } }
public RoomListModel(DnDContext context, IHttpContextAccessor http, ISecurityManager security) { _context = context; _http = http; _security = security; Rooms = _context.Rooms.Select(x => x).ToList(); }
public IActionResult Index() { var classLevel = DnDContext.GetClassLevel("Fighter", 2); ViewBag.className = classLevel.ClassName; ViewBag.level = classLevel.Level; ViewBag.hitDice = classLevel.HitDice; ViewBag.features = classLevel.Features; return(View()); }
public static void Main(string[] args) { // changes here DnDContext context = new DnDContext(); Console.WindowHeight = 50; Console.BufferHeight = 50; Console.WindowWidth = 160; Console.BufferWidth = 160; Utility.StartGame(); HeroSelection.Show(context); }
public static void Show(Hero hero) { Console.Clear(); Utility.PhaseTyper("Your game is over"); Utility.PhaseTyper($"Your hero was {hero.Name}"); Console.WriteLine(); Console.WriteLine(); Utility.PhaseTyper("Killed Dragons"); Console.WriteLine(); foreach (var item in hero.KilledDragons) { Utility.PhaseTyper($"{item.Name}, {item.Description}"); } var context = new DnDContext(); context.Database.Delete(); Environment.Exit(0); }
public ClassLevelsController(DnDContext context) { _context = context; }
// JGet: public JsonResult Get(int?page, int?limit, string sortBy, string direction, string name, int Hp, int MaxHp) { List <Character> records; int total; using (DnDContext context = _context) { var query = context.Character.Select(p => new Character { CharacterId = p.CharacterId, CharacterName = p.CharacterName, Initiative = p.Initiative, Hp = p.Hp, MaxHp = p.MaxHp, Int = p.Int, Cha = p.Cha, Con = p.Con, Dex = p.Dex, Str = p.Str, Wis = p.Wis }); if (!string.IsNullOrWhiteSpace(name)) { query = query.Where(q => q.CharacterName.Contains(name)); } if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction)) { if (direction.Trim().ToLower() == "asc") { switch (sortBy.Trim().ToLower()) { case "name": query = query.OrderBy(q => q.CharacterName); break; case "Hp": query = query.OrderBy(q => q.Hp); break; case "initiative": query = query.OrderByDescending(q => q.Initiative); break; } } else { switch (sortBy.Trim().ToLower()) { case "name": query = query.OrderByDescending(q => q.CharacterName); break; case "Hp": query = query.OrderByDescending(q => q.Hp); break; case "MaxHp": query = query.OrderByDescending(q => q.MaxHp); break; case "initiative": query = query.OrderBy(q => q.Initiative); break; } } } else { query = query.OrderBy(q => q.CharacterName); } total = query.Count(); if (page.HasValue && limit.HasValue) { int start = (page.Value - 1) * limit.Value; records = query.Skip(start).Take(limit.Value).ToList(); } else { records = query.ToList(); } } return(Json(new { records, total })); }
public CharactersController(DnDContext context) { _context = context; }
public SecurityManager(IHttpContextAccessor http, DnDContext context) { _http = http; _context = context; }
public PostsController(DnDContext context) { _context = context; }
public BlogsController(DnDContext context) { _context = context; }
public InformationsController(DnDContext context) { this._context = context; }
public static void Initialize(DnDContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Blogs.Any()) { return; // DB has been seeded } //var students = new Student[] //{ //new Student{FirstMidName="Carson",LastName="Alexander",EnrollmentDate=DateTime.Parse("2005-09-01")}, //new Student{FirstMidName="Meredith",LastName="Alonso",EnrollmentDate=DateTime.Parse("2002-09-01")}, //new Student{FirstMidName="Arturo",LastName="Anand",EnrollmentDate=DateTime.Parse("2003-09-01")}, //new Student{FirstMidName="Gytis",LastName="Barzdukas",EnrollmentDate=DateTime.Parse("2002-09-01")}, //new Student{FirstMidName="Yan",LastName="Li",EnrollmentDate=DateTime.Parse("2002-09-01")}, //new Student{FirstMidName="Peggy",LastName="Justice",EnrollmentDate=DateTime.Parse("2001-09-01")}, //new Student{FirstMidName="Laura",LastName="Norman",EnrollmentDate=DateTime.Parse("2003-09-01")}, //new Student{FirstMidName="Nino",LastName="Olivetto",EnrollmentDate=DateTime.Parse("2005-09-01")} //}; //foreach (Student s in students) //{ // context.Students.Add(s); //} //context.SaveChanges(); //var courses = new Course[] //{ //new Course{CourseID=1050,Title="Chemistry",Credits=3}, //new Course{CourseID=4022,Title="Microeconomics",Credits=3}, //new Course{CourseID=4041,Title="Macroeconomics",Credits=3}, //new Course{CourseID=1045,Title="Calculus",Credits=4}, //new Course{CourseID=3141,Title="Trigonometry",Credits=4}, //new Course{CourseID=2021,Title="Composition",Credits=3}, //new Course{CourseID=2042,Title="Literature",Credits=4} //}; //foreach (Course c in courses) //{ // context.Courses.Add(c); //} //context.SaveChanges(); //var enrollments = new Enrollment[] //{ //new Enrollment{StudentID=1,CourseID=1050,Grade=Grade.A}, //new Enrollment{StudentID=1,CourseID=4022,Grade=Grade.C}, //new Enrollment{StudentID=1,CourseID=4041,Grade=Grade.B}, //new Enrollment{StudentID=2,CourseID=1045,Grade=Grade.B}, //new Enrollment{StudentID=2,CourseID=3141,Grade=Grade.F}, //new Enrollment{StudentID=2,CourseID=2021,Grade=Grade.F}, //new Enrollment{StudentID=3,CourseID=1050}, //new Enrollment{StudentID=4,CourseID=1050}, //new Enrollment{StudentID=4,CourseID=4022,Grade=Grade.F}, //new Enrollment{StudentID=5,CourseID=4041,Grade=Grade.C}, //new Enrollment{StudentID=6,CourseID=1045}, //new Enrollment{StudentID=7,CourseID=3141,Grade=Grade.A}, //}; //foreach (Enrollment e in enrollments) //{ // context.Enrollments.Add(e); //} context.SaveChanges(); }
public NpcsController(DnDContext context) { _context = context; }
public static void Show(DnDContext context) { Console.WindowHeight = 50; Console.BufferHeight = 50; Console.WindowWidth = 160; Console.BufferWidth = 160; Console.Clear(); Utility.PhaseTyper("First you need to choose your hero!"); Console.WriteLine(); foreach (Hero hero in context.Heroes) { Utility.PhaseTyper($"NAME: {hero.Name}, Description: {hero.Description}"); } var heroes = context.Heroes.ToList(); int pageSize = heroes.Count(); int pointer = 1; while (true) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("First you need to choose your hero!"); int current = 1; foreach (var hero in context.Heroes) { if (current == pointer) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine($"NAME: {hero.Name}, Description: {hero.Description}"); current++; } var key = Console.ReadKey(); switch (key.Key.ToString()) { case "Enter": var currentHero = heroes.Skip(pointer - 1).First(); Rooms.FirstRoom(currentHero, context); return; case "UpArrow": if (pointer > 1) { pointer--; } break; case "DownArrow": if (pointer < pageSize) { pointer++; } break; default: break; } } }
public MonstersController(DnDContext context) { _context = context; _context.Database.EnsureCreated(); }
public Rooms(DnDContext context) { _context = context; }
public LocationsController(DnDContext context) { _context = context; }
public CitiesController(DnDContext context) { _context = context; }
public static void Show(Hero hero) { Console.Clear(); Console.WindowHeight = 50; Console.BufferHeight = 50; Console.WindowWidth = 160; Console.BufferWidth = 160; List <string> lines = new List <string>(); string firstLine = "Continue"; string secondLine = "How to play"; string thirdLine = "Inventory"; string fourthLine = "Exit"; lines.Add(firstLine); lines.Add(secondLine); lines.Add(thirdLine); lines.Add(fourthLine); int pointer = 1; int pageSize = 4; while (true) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("Welcome to the Main Menu of the game"); Console.WriteLine(); int current = 1; foreach (var line in lines) { { if (current == pointer) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine(line); current++; } } var key = Console.ReadKey(); switch (key.Key.ToString()) { case "Enter": if (pointer == 1) { return; } if (pointer == 2) { HowToPlay.Show(hero); return; } if (pointer == 3) { ItemsMenu.Show(hero); return; } if (pointer == 4) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; Console.Clear(); Console.WriteLine("Thank you for playing Dragons and Dungeons! Press any key to Exit the Game"); DnDContext context = new DnDContext(); context.Database.Delete(); Console.ReadKey(); Console.Clear(); Environment.Exit(0); } return; case "UpArrow": if (pointer > 1) { pointer--; } break; case "DownArrow": if (pointer < pageSize) { pointer++; } break; default: break; } } }
public static void Show(Hero hero, DnDContext context) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("Choose Item:"); Console.WriteLine(); Console.WriteLine("Press ESCAPE to go back to the Main Menu."); Console.WriteLine("To apply the ability press ENTER."); Console.WriteLine(); int pointer = 1; var abilities = context.SpecialAbilities.ToList(); foreach (var item in abilities) { Console.WriteLine($"Name: {item.Name}. This Ability would give you {item.Power} {item.AblityType}"); } Console.WriteLine("Back to Main Menu"); while (true) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("After each killed Dragon, You can choose one of these Items:"); Console.WriteLine(); Console.WriteLine("Press ENTER to select the Ability."); Console.WriteLine(); int current = 1; foreach (var item in abilities) { if (current == pointer) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; } else { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine($"Name: {item.Name}. This Item would give you {item.Power} {item.AblityType}"); current++; } Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); current++; Console.WriteLine(); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; var key = Console.ReadKey(); switch (key.Key.ToString()) { case "DownArrow": if (pointer < 7) { pointer++; } break; case "UpArrow": if (pointer > 1) { pointer--; } break; case "Enter": Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; if (pointer == 1) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "Dragon Hunter Axe"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 2) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "Heavens Shield"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 3) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "Sword Of Balance"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 4) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "Dragon's Tooth Sword"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 5) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "A Bucket Helmet"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 6) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "The One Ring"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } if (pointer == 7) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var ability = context.SpecialAbilities.FirstOrDefault(c => c.Name == "Lightsaber"); if (ability.Heroes.Count > 0) { Utility.PhaseTyper("You allready have this Item! ................"); break; } ApplySpecialAbility(hero, ability, context); return; } break; } } }
public ClassFeaturesController(DnDContext context) { _context = context; }
public CampaignsController(DnDContext context) { _context = context; }
public BuildingsController(DnDContext context) { _context = context; }
public CharactersController(DnDContext context) { _repository = new CharRepository(context); }