public IActionResult PlayersTurn(int attk) { int PlayerId = (int)HttpContext.Session.GetInt32("PlayerId"); Player Player1 = _context.player.SingleOrDefault(p => p.PlayerId == PlayerId); int? enconId = HttpContext.Session.GetInt32("EncounterId"); Encounters encounter = _context.encounters.SingleOrDefault(e => e.EncountersId == enconId); Enemies monster = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).First(); Story newStory = new Story(); Story newStory2 = new Story(); if (Player1.Class == "mage") { Mage Player = _context.mage.SingleOrDefault(p => p.PlayerId == PlayerId); if (attk == 1) { int attackVal = Player.Attack(monster); attackVal.ToString(); newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 2) { Player.Heal(); newStory.storyBook = "You used heal"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 4; } else if (attk == 3) { int attackVal = Player.Fireball(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 4) { int attackVal = Player.FrostBolt(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } } if (Player1.Class == "hunter") { Hunter Player = _context.hunter.SingleOrDefault(p => p.PlayerId == PlayerId); if (attk == 1) { int attackVal = Player.Attack(monster); attackVal.ToString(); newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 2) { Player.Mend(); newStory.storyBook = "You were mended fight on Hunter."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 4; } else if (attk == 3) { int attackVal = Player.Snipe(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 4) { int attackVal = Player.Silencing_Shot(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } } if (Player1.Class == "samurai") { Samurai Player = _context.samurai.SingleOrDefault(p => p.PlayerId == PlayerId); if (attk == 1) { int attackVal = Player.Attack(monster); attackVal.ToString(); newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 2) { Player.Meditate(); newStory.storyBook = "You used meditate."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 4; } else if (attk == 3) { int attackVal = Player.Smash(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 4) { int attackVal = Player.Death_Blow(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } } if (Player1.Class == "ninja") { Ninja Player = _context.ninja.SingleOrDefault(p => p.PlayerId == PlayerId); if (attk == 1) { int attackVal = Player.Attack(monster); attackVal.ToString(); newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 2) { Player.Hide(); newStory.storyBook = "You hide from the enemies."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 4; } else if (attk == 3) { int attackVal = Player.Backstab(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 4) { int attackVal = Player.Rend(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } } if (Player1.Class == "priest") { Priest Player = _context.priest.SingleOrDefault(p => p.PlayerId == PlayerId); if (attk == 1) { int attackVal = Player.Attack(monster); attackVal.ToString(); newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage."; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 2) { Player.Holy_Heal(); newStory.storyBook = "You healed yourself"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 4; } else if (attk == 3) { int attackVal = Player.Holy_Light(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } else if (attk == 4) { int attackVal = Player.Smight(monster); newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage"; SetTemp(0); newStory.created_at = DateTime.Now; newStory.PlayerId = PlayerId; newStory.flag = 2; } } _context.Add(newStory); _context.SaveChanges(); if (monster.health <= 0) { monster.health = 0; monster.life = false; newStory2.storyBook = "You killed a " + monster.name; SetTemp(-10); newStory2.created_at = DateTime.Now; newStory2.PlayerId = PlayerId; newStory2.flag = 2; _context.Add(newStory2); _context.SaveChanges(); } List <Enemies> enemyCount = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).ToList(); if (enemyCount.Count() > 0) { return(RedirectToAction("EnemiesTurn")); } int level = (int)HttpContext.Session.GetInt32("Level"); level++; HttpContext.Session.SetInt32("Level", level); return(RedirectToAction("firstEncounter")); }