Hey everyone!
My code to a specific function is below.
As a foreword: The goal is very simple.
tile, which is a global integer that is assigned from a rand() (in another function)
is then taken to this function, where it is put up against multiple if statements. Since tile is a single integer, it SHOULD only be possible for one of these statements to be true.
Not the case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
int tileEvent(){
cout << tile << endl;
if (tile == 0||2||4||6||8||10||12||14||16||18||20||22){
cout << "You landed on Opportunity!" << endl;
drawOpportunityCard();
}
if (tile == 1||9||17){
cout << "You landed on Doodads!" << endl;
drawDoodadsCard();
}
if (tile == 3){
cout << "You landed on Charity!" << endl;
drawCharityCard();
}
if (tile == 5||13||21){
cout << "You landed on Pay Check!" << endl;
drawPayCheckCard();
}
if (tile == 7||15||23){
cout << "You landed on Market!" << endl;
drawMarketCard();
}
if (tile == 11){
cout << "You landed on Baby!" << endl;
drawBabyCard();
}
if (tile == 19){
cout << "You landed on Downsized!" << endl;
drawDownsizedCard();
}
else {
cout << "There was an error with tile placement." << endl;
}
|
When this code is executed, tile is cout'd and may be a variety of numbers, but no matter what number it is, it somehow causes most of the functions to pass true...
so my output is
2
You landed on Opportunity!
You drew an Opportunity card
You landed on Doodads!
You drew a Doodads card
You landed on Pay Check!
You drew a Pay Check card
You landed on Market!
You drew a Market card
There was an error with tile placement.
I am using an online ide, but I doubt that is relevant.
I don't know what else needs to be said, since this is painfully simple. I am using C++11 and I am 98% sure other functions are not interfering.