I am trying to write a program that uses a random number to pick a monster object pointer from an array and place it into an allied monster array. (i am basically assigning random monster teams without repeated monsters on either team.) This is my code for this section. Let me know if you want more code or if there is a problem with my logic (which is what i think is wrong)
1 2 3 4 5 6 7 8 9 10 11 12 13
for(int i = 0; i < teamSize; i++)
{
randomMonsterNum = randomNumberGenerator();
int currentNum = 0;
while (currentNum == randomMonsterNum)
{
randomMonsterNum = randomNumberGenerator();
//allyMonsterArr[i] = MonsterPtrArr[randomMonsterNum];
}
allyMonsterArr[i] = MonsterPtrArr[randomMonsterNum];
currentNum = randomMonsterNum;
}