コード例 #1
0
        private async Task Client_Ready()
        {
            DisplayGame = new DisplayGame();
            await client.SetGameAsync(DisplayGame.RandomDisplay);

            await handler.LoadAdditionals();

            foreach (SocketGuild guild in client.Guilds)
            {
                UserCount += guild.Users.Count;
            }

            SpecialUsers = new List <ulong>();
            SpecialUsers.Add(ME);

            IReadOnlyCollection <IGuildUser> mainServerUsers = await((IGuild)client.GetGuild(279715709792288775)).GetUsersAsync();

            foreach (IGuildUser user in mainServerUsers)
            {
                foreach (ulong roleID in user.RoleIds)
                {
                    if (roleID == 350980878605877250)
                    {
                        SpecialUsers.Add(user.Id);
                        break;
                    }
                }
            }

            BotReady = true;
        }
コード例 #2
0
 public DisplayGame GetGameByID(Guid gameID)
 {
     using (var connection = new SQLiteConnection(connectionString))
     {
         connection.Open();
         var command = connection.CreateCommand();
         command.CommandText = "SELECT " +
                               "GameId, BlueScore,RedScore,GameTime, BlueDefense,BDFirst, BDLast,BlueOffense, BOFirst,BOLast,RedDefense,RDFirst,RDLast,RedOffense,ROFirst,ROLast " +
                               "From(SELECT * FROM Games " +
                               "LEFT JOIN(SELECT PlayerId as BDId,FirstName as BDFirst,LastName as BDLast from Players) ON BlueDefense = BDId " +
                               "LEFT JOIN(SELECT PlayerId as BOId,FirstName as BOFirst,LastName as BOLast from Players) ON BlueOffense = BOId " +
                               "LEFT JOIN(SELECT PlayerId as RDId,FirstName as RDFirst,LastName as RDLast from Players) ON RedDefense = RDId " +
                               "LEFT JOIN(SELECT PlayerId as ROId,FirstName as ROFirst, LastName as ROLast from Players) ON RedOffense = ROId)" +
                               "WHERE GameId = @Id; ";
         command.Parameters.Add(new SQLiteParameter("@Id", gameID));
         var reader = command.ExecuteReader();
         var game   = new DisplayGame();
         while (reader.Read())
         {
             game.GameID          = new Guid(reader.GetString(0));
             game.BlueScore       = reader.GetInt32(1);
             game.RedScore        = reader.GetInt32(2);
             game.GameTime        = DateTime.Parse(reader.GetString(3));
             game.BlueDefense     = new Guid(reader.GetString(4));
             game.BlueDefenseName = reader.GetValue(5).ToString() + " " + reader.GetValue(6).ToString();
             game.BlueOffense     = new Guid(reader.GetString(7));
             game.BlueOffenseName = reader.GetValue(8).ToString() + " " + reader.GetValue(9).ToString();
             game.RedDefense      = new Guid(reader.GetString(10));
             game.RedDefenseName  = reader.GetValue(11).ToString() + " " + reader.GetValue(12).ToString();
             game.RedOffense      = new Guid(reader.GetString(13));
             game.RedOffenseName  = reader.GetValue(14).ToString() + " " + reader.GetValue(15).ToString();
         }
         return(game);
     }
 }
コード例 #3
0
        /// <summary>
        /// Updates all non-DIHMT-specific fields of the
        /// game in the database
        /// </summary>
        /// <param name="dGame">The game to be updated</param>
        /// <param name="includeGenres">Indicates whether or not the DbGameGenres-table should be updated, too</param>
        private static void UpdateGameFromGb(DisplayGame dGame, bool includeGenres = false)
        {
            var gbGame = GbGateway.GetGame(dGame.Id);
            var dbGame = CreateDbGameObjectWithoutNavigation(gbGame);

            dbGame.IsRated           = dGame.IsRated;
            dbGame.Basically         = dGame.Basically;
            dbGame.RatingExplanation = dGame.RatingExplanation;
            dbGame.RatingLastUpdated = dGame.RatingLastUpdated;
            dbGame.LastUpdated       = DateTime.UtcNow;

            DbAccess.SaveGame(dbGame);

            var dbGamePlatforms = CreateDbGamePlatformsListWithoutNavigation(gbGame);

            DbAccess.SaveGamePlatforms(dbGamePlatforms);

            if (!includeGenres || gbGame.Genres == null || !gbGame.Genres.Any())
            {
                return;
            }

            var dbGameGenres = CreateDbGameGenresListWithoutNavigation(gbGame);

            DbAccess.SaveGameGenres(dbGameGenres);
        }
コード例 #4
0
 private void Navigate_To_HangmanGame(DisplayGame game)
 {
     this.Frame.Navigate(typeof(HangmanGamePage), game, new SlideNavigationTransitionInfo()
     {
         Effect = SlideNavigationTransitionEffect.FromRight
     });
 }
コード例 #5
0
        private async void GetWordForGame(DisplayGame item)
        {
            while (true)
            {
                var dialog = new ContentDialog
                {
                    Title             = "Set Hangman Word",
                    Content           = new TextBox(),
                    PrimaryButtonText = "Set Word"
                };

                // Finally, show the dialog
                var result = await dialog.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    var input = (TextBox)dialog.Content;
                    var text  = input.Text;

                    if (Regex.IsMatch(text, "^([a-zA-Z]+([- ])?)+[a-zA-Z]+$"))
                    {
                        ViewModel.SetWordForGame(item.GameId, input.Text);
                        return;
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates a DisplayGame object based on the information stored
        /// in the database.
        /// </summary>
        /// <param name="id">Id of the game to retrieve</param>
        /// <returns></returns>
        public static DisplayGame CreateDisplayGameObject(int id)
        {
            var dbGameView = DbAccess.GetDbGameView(id);

            DisplayGame result = null;

            if (dbGameView != null)
            {
                result = new DisplayGame(dbGameView);
            }

            return(result);
        }
コード例 #7
0
 private void AddGame(DisplayGame displayGame)
 {
     if (displayGame.GameStatus == GameStatus.Created)
     {
         CreatedGames.Add(displayGame);
     }
     else if (displayGame.GameStatus == GameStatus.Started)
     {
         StartedGames.Add(displayGame);
     }
     else
     {
         FinishedGames.Add(displayGame);
     }
 }
 public HangmanGameViewModel(DisplayGame displayGame, HangmanGamePage hangmanGamePage)
 {
     GetHangmanGameFromAPI(displayGame.GameId);
     HangmanGamePage = hangmanGamePage;
 }