Learning C++ by writing a Text Adventure
<p>So, I'm trying to get a handle on C++, so started writing a text adventure. I know that I'm making a bunch of stupid mistakes that are gonna trip me up if I actually try to flesh this thing out. Here's the code</p>

<p>It compiles and works like I want, but I want some feedback on how to improve.
I know i should be using a data base for a bunch of it, but we're taking baby steps right?
so whaddya think?</p>

<p>I trimmed the code to show just the really ugly parts
I would like to do something more elegant instead of a huge block of if statements is there a good way to do that here?</p>

<p>The "reduced" case sensetivity on the input by using || is ok, but it there a simple way to just send the string to lowercase and then test against that? </p>

<pre><code>// BEGIN MAIN LOOP
while (run = 1 ) 
{
cout &lt;&lt; "What do you do ?";
getline (cin,keyboard1);

// first set of tests for user input
 if ((keyboard1 == "inv") || (keyboard1 == "INV") || (keyboard1 == "Inv") ||     (keyboard1 == "inventory") || (keyboard1 == "INVENTORY") || (keyboard1 == "Inventory"))inventory(inv); 
if ((keyboard1 == "Q") || (keyboard1 == "q") || (keyboard1 == "quit")){ run = 0; break;}
 if ((keyboard1 == "look") || (keyboard1 == "LOOK") || (keyboard1 == "Look")) look(inv);
 if ((keyboard1 == "help") || (keyboard1 == "HELP") || (keyboard1 == "Help")) help();
 if ((keyboard1 == "N") || (keyboard1 == "n")) inv [10] = 1;
 if ((keyboard1 == "S") || (keyboard1 == "s")) inv [10] = 2; 
 if ((keyboard1 == "E") || (keyboard1 == "e")) inv [10] = 3;
 if ((keyboard1 == "W") || (keyboard1 == "w")) inv [10] = 4; 

// DIAGRAM OF ROOM NUMBERS STORED AS INV[0]
//     1
//   4 0 2 
//     3
//////////////// function to handle movement
/////////////// is a real mess of if statements how can this be streamlined?
//
//  CAN GO THAT WAY
//
// DIRECTION STORED AS INV[10]   1N 2S 3E 4W
//    flag start      flag movement       finalpos  reset flag  print               
if ((inv[0] == 0) &amp;&amp; (inv[10] == 1)) {inv[0] = 1; inv [10] = 0;look (inv);} 
if ((inv[0] == 0) &amp;&amp; (inv[10] == 2)) {inv[0] = 3; inv [10] = 0;look (inv);}
if ((inv[0] == 0) &amp;&amp; (inv[10] == 3)) {inv[0] = 2; inv [10] = 0;look (inv);}
if ((inv[0] == 0) &amp;&amp; (inv[10] == 4)) {inv[0] = 4; inv [10] = 0;look (inv);}
if ((inv[0] == 1) &amp;&amp; (inv[10] == 2)) {inv[0] = 0; inv [10] = 0;look (inv);}
if ((inv[0] == 2) &amp;&amp; (inv[10] == 4)) {inv[0] = 0; inv [10] = 0;look (inv);}
if ((inv[0] == 3) &amp;&amp; (inv[10] == 1)) {inv[0] = 0; inv [10] = 0;look (inv);}
if ((inv[0] == 4) &amp;&amp; (inv[10] == 3)) {inv[0] = 0; inv [10] = 0;look (inv);}

/// can't go that way

if ((inv[0] == 1) &amp;&amp; (inv[10] == 1)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way" &lt;&lt; endl;} 
if ((inv[0] == 1) &amp;&amp; (inv[10] == 3)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 1) &amp;&amp; (inv[10] == 4)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}

if ((inv[0] == 2) &amp;&amp; (inv[10] == 1)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 2) &amp;&amp; (inv[10] == 2)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 2) &amp;&amp; (inv[10] == 3)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}

if ((inv[0] == 3) &amp;&amp; (inv[10] == 2)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 3) &amp;&amp; (inv[10] == 3)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 3) &amp;&amp; (inv[10] == 4)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}

if ((inv[0] == 4) &amp;&amp; (inv[10] == 1)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 4) &amp;&amp; (inv[10] == 2)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
if ((inv[0] == 4) &amp;&amp; (inv[10] == 4)) {inv[10] = 0; cout &lt;&lt; endl &lt;&lt; "you can't go that way"&lt;&lt; endl;}
}
//////////////END OF MAIN LOOP
</code></pre>
