Exemple #1
0
        static void damage(Player P, int rdam, int gdam) //Static means that this function is one of a kind, void returns nothing.
        {
            double total = 0;
            double r     = (double)rdam; //type cast int rdam and int gdam into doubles.
            double g     = (double)gdam;

            total += r * (3.8);               //This makes it compatible to be manipulated with decimals/make the total more accurate.
            total += g * (7.2);               //If we don't do this, it will round up and decimals won't be used.
            int t             = (int)total;   //Rounds up total to an int so that we can use it for the Next() function.
            int random_number = R.Next(0, t); //The t becomes the max random number in this round that could be selected.

            Console.WriteLine("{0} took {1} damage!", P.get_name(), random_number);
            P.health_change(random_number);
        }