Whenever I fetch data from an array it mixes it with another array and then outputs it, it only seems to mix the first character in the array with another array.
in this image it shows my arrays, whenever I fetch the contents of array (string HP_D) it always mixes it with sledge from the array (string S_A). this is the output, as you can see "Sledge" is not meant to be there
Here is the code:
#include <conio.h>
#include <iostream>
#include <string.h>
#include <random>
using namespace std;
FUNCTION()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1,34);
auto random_integer = uni(rng);
return random_integer;
}
FUNCTION2()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1,14);
auto random_integer2 = uni(rng);
return random_integer2;
}
FUNCTION3()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1,27);
auto random_integer3 = uni(rng);
return random_integer3;
}
FUNCTION4()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1,5);
auto random_integer4 = uni(rng);
return random_integer4;
}
FUNCTION5()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1,35);
auto random_integer5 = uni(rng);
return random_integer5;
}
int main()
{
int Operator_type;
int Player_Count;
int again = 10;
cout << "How Many Players?\n";
cin >> Player_Count;
cin.get();
do
{
cout << "('1' = ATTACKERS)\n('2' = DEFENDERS)\n('3' = SHOTGUN ONLY ATTACKER)\n('4' = SHOTGUN ONLY DEFENDER)\n('5' = HEAVY PISTOL ATTACKER)\n('6' = HEAVY PISTOL DEFENDER)\n";
cin >> Operator_type;
string DEFENDERS[34] = {"Smoke","Mute","Castle","Pulse","Doc","Rook","Kapkan",
"Tchanka","Jaegar","Bandit","Frost","Valkyrie","Caviera","Echo","Mira","Lesion",
"Ela","Vigil","Maestro","Alibi","Clash","Kaid","Mozzie","Warden","Goyo","Wamai",
"Oryx","Melusi","Aruni","Thunderbird","Thorn","Azami","Solis","Fenrir" };
string ATTACKERS[34] = {"Sledge","Thatcher","Ash","Thermite","Twitch","Montagne",
"Glaz","Fuze","Blitz","IQ","Buck","Capitão","Hibana","Jackal","Ying","Dokkaebi",
"Lion","Finka","Maverick","Nomad","Gridlock","Nokk","Amaru","Kali","Iana","Ace",
"Zero","Flores","Osa","Sens","Grim","Brava","Ram"};
string S_A[14] = {"Sledge","Thatcher","Thermite","Twitch","Hibana","Jackal","Ying",
"Dokkaebi","Lion","Finka","Gridlock","Nokk","Ace","Amaru"};
string S_D[27] = {"Smoke","Mute","Castle","Pulse","Doc","Rook","Jaeger","Bandit","Frost",
"Valkyrie","Caviera","Echo","Mira","Lesion","Ela","Vigil","Alibi","Maestro","Clash",
"Kaid","Warden","Goyo","Oryx","Melusi","Thunderbird","Thorn","Azami"};
string HP_A[5] = {"Twitch","Montagne","Blackbeard","Nomad","Nokk"};
string HP_D[5] = {"Doc","Rook","Valkyrie","Kaid","Azami"};
if (Operator_type == 2){
for (int i = 1; i <= Player_Count; ++i ) {
cout << "Player: " << i << " = " << DEFENDERS[FUNCTION()] << "\n";
}
}
if (Operator_type == 1){
for (int i = 1; i <= Player_Count; ++i ) {
cout << "Player: " << i << " = " << ATTACKERS[FUNCTION5()] << "\n";
}
}
if (Operator_type == 3){
for (int i = 1; i <= Player_Count; ++i ) {
cout << "Player: " << i << " = " << S_A[FUNCTION2()] << "\n";
}
}
if (Operator_type == 4){
for (int i = 1; i <= Player_Count; ++i ) {
cout << "Player: " << i << " = " << S_D[FUNCTION3()] << "\n";
}
}
if (Operator_type == 5){
for (int i = 1; i <= Player_Count; ++i) {
cout << "Player: " << i << " = " << HP_A[FUNCTION4()] << "\n";
}
}
if (Operator_type == 6){
for (int i = 1; i <= Player_Count; ++i ) {
cout << "Player: " << i << " = " << HP_D[FUNCTION4()] << "\n";
}
}
cout << "REROLL? (TYPE 9)\n:";
cin >> again;
}
while (again == 9);
this is my code for it. It doesnt mix any other arrays, just of array "S_A" and "HP_D".
I have not thought of any method as I cannot think of a solution that would work.