I'm having trouble understanding whats going wrong here. Instead of outputting one random phrase, like it seems it should, my program outputs all four of them.
Consider using a look up table instead of multiple if statements.
1 2 3 4 5 6 7 8 9 10 11 12
std::srand( std::time(0) ) ;
constchar* const messages[] =
{
"Enemy uses fire blast! You feel your skin crackle and burn!",
"Enemy uses spinning kick! Your chest erupts with pain as your sternum shatters!",
"Enemy uses whirlwind punch! The world dims as your brain begins to swell!",
"Enemy uses sandstorm! Your insides burn as your lungs drown in sand!"
};
enum { NMESSAGES = sizeof(messages) / sizeof(messages[0]) } ;
std::cout << messages[ std::rand() % NMESSAGES ] << '\n' ;