예제 #1
0
        /// <summary>
        /// Adds a defeat to the given player for his previous role.
        /// </summary>
        /// <param name="m_Profile_Name">Profile name of the the loser of the game.</param>
        /// <param name="m_Role">His role: attacker or defender.</param>
        public void Add_Defeat(string m_Profile_Name, Player_Role m_Role)
        {
            //Checking if connection not already opened
            if (connection != null && connection.State == System.Data.ConnectionState.Closed)
            {
                //Opening the SQL connection
                this.connection.Open();
            }

            //Creating the querry
            MySqlCommand cmd = this.connection.CreateCommand();

            if (m_Role == Player_Role.Attacker)
            {
                cmd.CommandText = "UPDATE Tablut.profile SET Lost_Attack = Lost_Attack + 1 WHERE Name=(@m_Name)";
            }
            else
            {
                cmd.CommandText = "UPDATE Tablut.profile SET Lost_Defence = Lost_Defence + 1 WHERE Name=(@m_Name)";
            }

            //Inserting the parameter
            cmd.Parameters.AddWithValue("@m_Name", m_Profile_Name);

            //Executes query
            cmd.ExecuteNonQuery();

            //Closes connection
            this.connection.Close();
        }
예제 #2
0
 /// <summary>
 /// Constructor. Sets the player.
 /// </summary>
 /// <param name="m_Name">The player's name.</param>
 /// <param name="m_Pawn_Left">Initial number of pawn (attack = 12, defence = 9).</param>
 /// <param name="m_Role">The role of the player (Attacker or Defender).</param>
 public Player(string m_Name, int m_Pawn_Left, Player_Role m_Role)
 {
     this.Name        = m_Name;
     this.Total_Moves = 0;
     this.Total_Enemy_Pawn_Eliminated = 0;
     this.Pawn_Left = m_Pawn_Left;
     this.Role      = m_Role;
 }