First off, I'd like to say hello to everyone and it's great to be here .
I'm having a particular behavior issue I can't seem to figure out and I've tried searching online for the issue, as well as debugging numerous times with no success.
Here's the code I'm having issues with:
I realize the above code is NOT the best way to do what what is intended. I was just messing around and playing with different coding aspects and nothing more. I just ran into an odd issue I can't figure out so I'm asking for a second pair of eyes. The above code works, but that's where the issue lies oddly enough.
The problem is, in Microsoft VS 2015, when that code runs without debugging, every value for the attributes shown in the console are the same, however, when I run debugger it works as it should and displays different values.
I'm hoping someone can help me see what I'm not seeing.
Thanks in advance.
I'm having a particular behavior issue I can't seem to figure out and I've tried searching online for the issue, as well as debugging numerous times with no success.
Here's the code I'm having issues with:
C#:
int userAnswer = 1; //Set to '1' for debugging purposes -- Convert.ToInt32(Console.ReadLine());
int pHealth = 0, pAttack = 0, pStr = 0, pDefend = 0, pArmor = 0, pDex = 0, pMagic = 0, pLuck = 0;
int[] pAttributes = new int[7];
if(userAnswer == 1)
{
for(int i = 0; i < 7; i++)
{
pAttributes[i] = Roll();
}
//set attributes randomly. NOTE:: BaseAttributes is an ENUM from another class with default values of 10 for all attributes.
pHealth = (int)BaseAttributes.baseHealth + pAttributes[0];
pAttack = (int)BaseAttributes.baseAttack + pAttributes[1];
pStr = (int)BaseAttributes.baseStr + pAttributes[2];
pArmor = (int)BaseAttributes.baseArmor + pAttributes[3];
pDex = (int)BaseAttributes.baseDex + pAttributes[4];
pMagic = (int)BaseAttributes.baseMagic + pAttributes[5];
pLuck = (int)BaseAttributes.baseLuck + pAttributes[6];
}
Console.WriteLine("-------------");
Console.WriteLine("Health: {0}\nStrength: {1}\nDexterity {2}\nAttack: {3}\nArmor: {4}\nMagic: {5}\nLuck: {6}",
pHealth, pStr, pDex, pAttack, pArmor, pMagic, pLuck);
Console.ReadKey();
}
public static int Roll()
{
Random rand = new Random();
int randomRoll = rand.Next(1, 20);
return randomRoll;
}
}
I realize the above code is NOT the best way to do what what is intended. I was just messing around and playing with different coding aspects and nothing more. I just ran into an odd issue I can't figure out so I'm asking for a second pair of eyes. The above code works, but that's where the issue lies oddly enough.
The problem is, in Microsoft VS 2015, when that code runs without debugging, every value for the attributes shown in the console are the same, however, when I run debugger it works as it should and displays different values.
I'm hoping someone can help me see what I'm not seeing.
Thanks in advance.