As I can use the function Random
in C # using two functions, the first function is the minimum damage of the player, and the second the maximum damage that a player can do, my idea is to use the function Random
, calling to both functions min. and max. and based on the range of these shows the random number, however it does not work, I attach my code that is a console function.
PS: I left the code that does not work commented.
using System;
namespace ConsoleApp2
{
class Program
{
//Metodos para devolver un valor
static int DanoMinMeleeDistance(int STR, int DEX, int WeaponATK)
{
int DanoMinMeleeDistance = ((STR+DEX)/2)+WeaponATK;
return DanoMinMeleeDistance;
}
static int DanoMaxMelee(int STR, int DEX, int WeaponATK)
{
int DanoMaxMelee = STR+WeaponATK+(DEX/2);
return DanoMaxMelee;
}
/* static int DanoAleatorio(Random rnd, int DanoMaxMelee, int DanoMinMeleeDistance) {
int DanoAleatorio = rnd.Next(DanoMinMeleeDistance, DanoMaxMelee);
return DanoAleatorio;
}*/
// Main el principal
static void Main(string[] args)
{
int STR, DEX, WeaponATK;
Console.Write("INGRESE PRIMER VALOR: ");
STR = int.Parse(Console.ReadLine());
Console.Write("INGRESE SEGUNDO VALOR: ");
DEX = int.Parse(Console.ReadLine());
Console.Write("INGRESE TERCER VALOR: ");
WeaponATK = int.Parse(Console.ReadLine());
Console.Write("1º) Daño Minimo" + "\n" + "2º) Daño Maximo" + "\n" + "3º) Daño Aleatorio <strong>\n");
Console.Write("Seleccione una opción: ");
switch (Console.Read())
{
case '1':
Console.Write("Daño Minimo = " + DanoMinMeleeDistance(STR, DEX, WeaponATK));
// Continuar lógica y extraer métodos //
break;
case '2':
Console.Write("Daño Maximo = " + DanoMaxMelee(STR, DEX, WeaponATK));
// Continuar lógica y extraer métodos //
break;
/*case '3':
Console.Write("El numero aleatorio es" + DanoAleatorio()*/
}
Console.ReadKey(); // Un pausee para presionar la tecla
}
}
}