Missing bit on logic for "baseball event"
Hello -
I've been trying to come up with the most simple, reusable code for handling a hit event in a baseball game. It's related to the batter's hit and the men already on base.
I believe that a loop can handle the men on base going to the next, but I'm stuck on first (here we go, bad pun time! ). Here's what I have come up with (I assume you can figure out what the variables and commands are):
Loop Until TempValue = HitValue
Base4Value = Base3Value
Base3Value = Base2Value
Base2Value = Base1Value
Base1Value = ?
If Base4Value = 1 Then
Runs = Runs +1
Base4Value = 0
End If
TempValue = TempValue + 1
End Loop
HitType would be 1 for single, 2 for double, 3 for triple, 4 for Home Run. So the men would run according to the hit type. Therefore, a previous event will determine what HitType is equal to (just prior to the Loop).
I understand it would be more logical to have the man closest to Home go first so the base would then be filled with the second-closest man and so on.
Based on the above, I am stuck on how the batter can "move" x number of bases.
Any ideas before I strike out on this (groan!)
Thanks, regards.
Comments
I think I got, it but since I am about to go out the door, I'll write it here:
Inside the Loop:
Base1Value = 0
Base1Value = Base1Value + 1
My Blog / App Store / Google Play