Exemple #1
0
        public careerStats getOldCareerStats(int ID)
        {
            careerStats oldStats = null;

            if (ID != -1)
            {
                MySqlCommand queryCommand = new MySqlCommand();

                queryCommand.Connection  = conn;
                queryCommand.CommandText = "SELECT pawnsEaten, pawnsLost, finalScore from careerStats WHERE ID = @ID";
                queryCommand.Prepare();
                queryCommand.Parameters.AddWithValue("@ID", ID);
                try
                {
                    MySqlDataReader reader = queryCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        oldStats = new careerStats(ID, (int)reader["pawnsEaten"], (int)reader["pawnsLost"], (int)reader["finalScore"]);
                    }
                    return(oldStats);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
            return(oldStats);
        }
Exemple #2
0
        public careerStats getNewCareerStats(gameStats y, careerStats x)
        {
            careerStats combinedStats = new careerStats(y.getID(), (y.getpawnsEaten() + x.getpawnsEaten()),
                                                        (y.getPawnsLost() + x.getPawnsLost()), (y.getFinalScore() + x.getFinalScore()));

            return(combinedStats);
        }
Exemple #3
0
 public String afterGameInsert(gameStats x)
 {
     if (x.getID() != -1 && x.getPassed() == 1)
     {
         checkUnlockMap(x);
         careerStats oldStats            = getOldCareerStats(x.getID());
         careerStats combinedCareerStats = getNewCareerStats(x, oldStats);
         insertCareerStats(combinedCareerStats);
     }
     return("Stats saved post-game!");
 }
Exemple #4
0
        public void insertCareerStats(careerStats combinedStats)
        {
            MySqlCommand queryCommand = new MySqlCommand();

            queryCommand.Connection  = conn;
            queryCommand.CommandText = "UPDATE playerStats SET  pawnsEaten = @pawnsEaten, pawnsLost = @pawnsLost, finalScore = @finalScore" +
                                       "WHERE personID= @personID";
            queryCommand.Prepare();
            queryCommand.Parameters.AddWithValue("@personID", combinedStats.getID());
            queryCommand.Parameters.AddWithValue("@pawnsEaten", combinedStats.getpawnsEaten());
            queryCommand.Parameters.AddWithValue("@pawnsLost", combinedStats.getPawnsLost());
            queryCommand.Parameters.AddWithValue("@finalScore", combinedStats.getFinalScore());
            try
            {
                MySqlDataReader reader = queryCommand.ExecuteReader();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
            }
        }