You're using the || operator instead of the && operator. The way you have it set up is if the move does not equal ALL of the possibilities then the loop will keep evaluating to true.
New question: I've created a game in console but am having trouble deciding what symbol to make the player. Is the smiley face (alt+1) a universal symbol? Should I use that as the player symbol? If so how, if not, what should I use?
How can I turn line 4 into something that will test all the elements in the traps array instead of just checking static traps[0], 1, 2, 3, and 4 elements. The number of traps is actually defined to preprocessor as QTY_TRAPS.
1 2 3 4 5 6 7 8 9 10
// Lay treasure and traps on board
if (treasure == place){
symbol = '$';
}elseif (traps[0] == place || traps[1] == place || traps[2] == place || traps[3] == place || traps[4] == place){
symbol = '*';
}elseif (pos_player == place){
symbol = 'u';
}else{
symbol = '.';
}
How can I turn line 4 into something that will test all the elements in the traps array instead of just checking static traps[0], 1, 2, 3, and 4 elements.
Use a for loop.
If you want to test ALL of them rather than ANY of them, use another variable to count how many qualify.