Baseball game dev diary version 0.4.0.202011242245: hits, extra base hits, walks and runs

  1.  Moved code for plate appearance and set up batter from within event handlers to their own procedures and had the event handlers call them. This is particularly so that the plate appearances can be simmed without having to call the event handlers which gives errors as parameters  are not specified for parameters for calling object and event arguments. Makes sense to do this anyway – ie have event handlers with minimal code. The idea to move code out of event procedures is probably good practice anyway, and definitely ensures that simming games quickly will now be possible quite easily. Quite proud of this idea.
  2. Changed Skip to top of 9th procedure so that it actually sims up to the 9th rather than skipping the innings completely. 
  3. Ensured the Next batter button was disabled at end of game by moving button toggles before the check for winner and disabling next batter button in postgame procedure.
  4. Added a new procedure to checkBases at the end of each pitch. This counts runs scored (players in bases array positions 4-7). Really happy with having planned the baserunning this way. It made the resultant coding very easy to work out.
  5. Added procedures ball4 for walk which moves any runners forward one base. Same code added to hitSingle. Then changed it. This is huge: baserunner movement. Very easy to do. Even remembered before trying it that I would have to sequence the runner code in reverse order (ie start with 4, then 3, 2, 1, batter). Did walks and hits first (simply advance all runners one base).  The result was that the score was still 0-0 after 29 innings, before I gave up and modified the result random number generator case selection so that hits are 4 chances out of 10, not 2.
  6. Then realised doubles, triples and homers would be super simple. Then realised that extra base hits would mean walks may not necessarily force runners as some bases would be empty. So had to rewrite the walk logic with checks for all preceeding runners for runners on 3rd and 2nd. Got it first go.
Here's a sample of the code for points 4 and 6.



Comments

Popular posts from this blog

MLB (Road to) The Show attribute progression

MLB The Show 21: create a stadium prediction & using created stadiums in online games

V1.1.4.202103032300 Basic player creator, line score tidy up and additional play results, including errors