public static void Start(Entities db, Game game)
        {
            game.HasStarted = true;
            game.GamePlayers.PickRandom().PrivateTeamID = 2; // secretly change one player onto the aliens team

            game.LoadCards(db);
            var firstPlayer = game.SetupPlayers();
            game.StartTurn(firstPlayer, 1);
        }
        public static GamePlayer JoinGame(Game game, string currentUserID, string name)
        {
            GamePlayer player = new GamePlayer();
            player.Name = name;
            player.Game = game;
            player.Notes = string.Empty;
            player.Position = 0;
            player.PublicTeamID = player.PrivateTeamID = 1; // humans, default team
            player.UserID = currentUserID;

            game.GamePlayers.Add(player);

            return player;
        }
        public static void ProcessEndOfTurn(Game game)
        {
            // end the current turn
            var currentTurn = game.GameTurns.OrderByDescending(gt => gt.Number).First();
            EndTurn(currentTurn);

            // either end the game or start the next turn
            if (game.ShouldEndGame())
                game.EndGame();
            else
            {
                var nextPlayer = game.GetNextPlayer(currentTurn.ActivePlayer);
                StartTurn(game, nextPlayer, currentTurn.Number + 1);
            }
        }
        public static Game CreateGame(CreateViewModel model, string hostUserID)
        {
            var game = new Game();
            game.Name = model.Name;
            game.NumPlayers = model.NumPlayers;

            if (model.Private)
                game.Password = HashPassword(model.Password);

            game.HostedByUserID = hostUserID;
            game.HasStarted = false;
            game.HasFinished = false;
            game.CreatedOn = DateTime.Now;

            return game;
        }
 public static bool CheckPassword(string password, Game game)
 {
     return HashPassword(password) == game.Password;
 }