public IActionResult CompleteContract(int gameId, int id, string weapon) { var db = new AssassinContext(); Game thisGame = db.games.Find(gameId); Player thisPlayer = db.players.Find(id); Contract thisContract = db.contracts.Where(c => c.assassin_id == thisPlayer.assassin_id && c.is_fulfilled == 0 && thisPlayer.is_alive == 1).FirstOrDefault(); thisContract.CloseContract(thisContract.id, thisPlayer.id, weapon); thisContract.KillTarget(thisContract.id); return(RedirectToAction("Index", new { gameId = thisGame.id, id = thisPlayer.id })); }
public IActionResult StartGame(int gameId, int id) { var db = new AssassinContext(); Game thisGame = db.games.Find(gameId); Player.AssignAssassinId(gameId); thisGame.BeginGame(); Player thisPlayer = db.players.Find(id); return(RedirectToAction("Index", new { gameId = thisGame.id, id = thisPlayer.id })); }
public IActionResult Consent(int gameId, int id) { var db = new AssassinContext(); Game thisGame = db.games.Find(gameId); Player thisPlayer = db.players.Find(id); Dictionary <string, object> model = new Dictionary <string, object> { { "game", thisGame }, { "player", thisPlayer } }; return(View(model)); }
public IActionResult CreatePlayer(string name, string email, string password, string phoneNumber, string agentName, int gameId) { var db = new AssassinContext(); var player = new Player { is_alive = 1, name = name, password = password, email = email, code_name = agentName, game_id = gameId, spoon_score = 0, sock_score = 0, phone_number = phoneNumber, is_admin = 0 }; var foundGame = db.games.Find(gameId); db.players.Add(player); db.SaveChanges(); return(RedirectToAction("Consent", new { gameId = player.game_id, id = player.id })); }
public IActionResult Index(int gameId, int id) { var db = new AssassinContext(); Game thisGame = db.games.Find(gameId); List <Player> deathList = thisGame.DailyStats(); Player thisPlayer = db.players.Find(id); Contract thisContract = db.contracts.Where(c => c.assassin_id == thisPlayer.assassin_id && c.is_fulfilled == 0 && thisPlayer.is_alive == 1 && c.game_id == thisGame.id).LastOrDefault(); Dictionary <string, object> model = new Dictionary <string, object> { { "game", thisGame }, { "player", thisPlayer }, { "contract", thisContract }, { "deathList", deathList } }; return(View(model)); }
public IActionResult Authenticate(string userName, string uPassword) { var db = new AssassinContext(); Player thisPlayer = db.players.Where(p => p.email == userName && p.password == uPassword).FirstOrDefault(); if (thisPlayer == null) { return(RedirectToAction("TryAgain")); } else { return(RedirectToAction("Index", "Players", new { gameId = thisPlayer.game_id, id = thisPlayer.id })); } }
public IActionResult Create(string gameName, string gamePassword, string name, string email, string password, string phoneNumber, string agentName) { var db = new AssassinContext(); var game = new Game { team_name = gameName, password = gamePassword, is_start = 0, is_end = 0 }; db.games.Add(game); db.SaveChanges(); var player = new Player { is_alive = 1, name = name, password = password, email = email, code_name = agentName, game_id = game.id, spoon_score = 0, sock_score = 0, phone_number = phoneNumber, is_admin = 1 }; db.players.Add(player); db.SaveChanges(); return(RedirectToAction("Consent", "Players", new { gameId = game.id, id = player.id })); }
public IActionResult AuthenticateGroup(string gameName, string gamePassword) { var db = new AssassinContext(); Game thisGame = db.games.Where(g => g.team_name == gameName && g.password == gamePassword).FirstOrDefault(); if (thisGame == null) { List <string> model = new List <string> { "The team name and/or password is incorrect", "Try again." }; return(View("New", model)); } else { List <Game> GameList = new List <Game> { thisGame }; return(View("New", GameList)); } }