php combat system: issue with loops
<p>Folks at gamedev shot me down so I'd like to try here. </p>

<p>Here's my problem. Two users have a speed variable, based on who has the faster speed is who hits the most, and first. So here are some imaginary stats:</p>

<blockquote>
  <p>UserA has 2,000 speed</p>
  
  <p>UserB has 4,000 speed</p>
</blockquote>

<p>UserB has 2x the amount of speed, thus would hit first, and would get two hits before UserA gets a shot, so the battle would go as follows:</p>

<pre><code>UserB hits UserA
UserB hits UserA
***UserA hits UserB
UserB hits UserA
UserB hits UserA
***UserA hits UserB
</code></pre>

<p>In that pattern. The concept itself is simple, but I'm having big problems with the execution. I need to loop this so I can do the damage calculations and insert battle events into the database, but how can I - within the loop - tell php who gets to hit this round and how many more hits they get, and so on? </p>

<p>Any ideas?</p>
