jonesguy14 / footballcoach

Android App for playing/simulating/recruiting as a college football coach
Other
34 stars 8 forks source link

Updates to clock subtraction and failed 4th down (and misc stuff) #30

Closed destilla closed 8 years ago

destilla commented 8 years ago

Basic idea of what I was going for:

In the current code, the clock runs the same for each passing play, whether that play was a sack for yardage loss (the clocks runs), a sack for a safety (clock stops for freekick), an incompletion (drop or bad throw) (clock stops after the play is dead), a catch for a TD (clock stops for the XP try) or a catch (which so far we're assuming is always in bounds, so the clock runs).

I wanted to suggest a change to allow the clock to run differently depending on the outcome. In doing this, I noticed that when a play is run, "5th down is checked" (aka did you just fail a fourth down), and if you did, possession is changed and the down is set to 1. (glassesref joke goes here) However, the yards to go remained, and the yard line variable didn't change.

Because the game uses 100 yards, instead of the "your own 1-49, the 50, the opp 49-1" system, if USC stops ASU on the 40 yard line in the game, they would then take over --on their own 40--. The analogy to real life is if USC stopped ASU on 4th and 3 from the ASU 40 yard line, USC would get the ball with 1st and 3 to go, on the USC 40 yard line.

I updated the code to set the yards to go to 10 so that the defense that just got the 4th down stop gives their offense the ball with 1st and 10 to go instead of 1st and whatever-the-other-team-had-left. I also set gameYardLine = 100 - gameYardLine to reflect the fact that the ball is now moving in the other direction, and counting up to 100. (I flat out stole this from getFumble).


List of changes:

Updated getEventPrefix to use "gameDownAdj" in the return string instead of "gameDown". This allows for us to print out that a team failed a 4th down try, and not have the game log read "5 and 3" in the event a team turns over on 4th down.

Tested that turnover on downs worked properly by having a log added that reported the 4th down failure and the subsequent 1st down take over by the other team. (If I can figure out how to attach a screenshot I'll show the result). I got rid of the 1st down take over but thought you might like a 4th down failure message log, so I left it in but commented. Updated turnover on downs logic to reset to 1st and 10 for the new team and flip the direction the ball is moving (put them on the right yardline)

Changed a dropped ball to take up less time (because the ball was dropped and now the clock shouldn't run after the play), update passattempt, and then exit (return;) and move on.

If the WR escapes for a TD (vs just having his play be long enough for a TD), previously he got a flat 100 yard gain. Updated the code to give him the rest of the yardage that was left in the drive instead of the flat 100.

If a pass is incomplete (WR didn't drop it, but didn't catch it either), the clock decrements the time of the play, runs passAttempts, then exits.

If the pass is caught, but then fumbled, or run all the way for a TD, the clock loses the time that would burn off during the play, and then stops for either the change of possession or the XP and kickoff (and on kickoff, more time is decremented as part of the kickoff ...function? method? whatever the vocabulary is)

Previously, if the QB was sacked, no time ran off the clock (because the play simply ran qbSack(offense) and then exited, and qbSack didn't subtract any time). Updated qbSack to take up some time and stop the clock if the result was a safety (clock stops for change of possession) and take the equivalent of a rushing play if the sack is just a regular sack (because at that point it -is- a rushing), minus 5 static seconds because it's a short rushing play.


Finally, if the play is a catch but not a TD or a fumble, then the clock decrements as it previously did on every passing play that didn't exit early (sack or interception).

destilla commented 8 years ago

image

Screenshot of the turnover on downs game log that has been commented out. The first down message directly below it was for testing and was removed. (It says KTY gets the ball in that message because I'm referencing "offense.abbr" which never updated, since runPlay is still in it's same execution) This is what the turnover on downs message looks like if you uncomment it. (And oh my god, NO ONE fails on 4th down, even on aggressive. It took 3 seasons to get this)

jonesguy14 commented 8 years ago

Wow, well I guess this is why its good to have someone look over your code! I can't believe the whole turnover on downs thing was so out of whack in regards to the yardage. I guess since it happens so infrequently I never noticed, but its still a big oversight.

And I do love the turnover on downs log, it was in the back of my mind as something to add and you have it exactly how I would've as well. So you can uncomment that for sure (the turnover on downs part, I agree that a 1st down message isn't necessary). It will be very nice in close games down the stretch so players can see how close they were to that game winning TD.

Also, for the WR gaining 100 yards thing, you can see a few lines down that it doesn't matter either way, I subtract extra yards past the 100 yard line:

//add yardage
gameYardLine += yardsGain;
if ( gameYardLine >= 100 ) { //TD!
     yardsGain -= gameYardLine - 100;
     gameYardLine = 100 - yardsGain;

I merged the pull request, I just have one question. Why did you remove the gameDown++ line on the qbSack(..) function? I couldn't see if you incremented the game down elsewhere when a sack happens.

destilla commented 8 years ago

It happens so rarely that I thought it would be neat to have it note "Hey, a defense got this pretty big stop"; I'm glad you felt the same way too! I basically got the formatting idea by looking at how you worded onside kicks and thinking of play by plays I've read.

For the WR gaining 100 yards thing, I think that was me being really new at this more than anything. My brain didn't fully process everything correctly and it just said "Oh man it just adds 100 yards and that's the end of that" despite there not being a return, and there being more code afterwards.

For the qbSack function not having gameDown++ --- haha the only explanation I have is that I removed it first, intending to put it in after the play had processed, after the time was decremented, because my brain wanted it to progress like IRL football. And then I got sidetracked figuring out how to layer/structure things and....welp. Oops. Like you said, this is why someone should look over code, especially if they're new to this, haha.

I'll submit a new pull with the mistakes reverted and the log uncommented. Thanks for the feedback!

destilla commented 8 years ago

Oh, just wanted to also: All the major features that you plan to implement from the subreddit sidebar, such as red shirting, injuries, etc -- I'm staying away adding stuff like that because I'm sure you have an idea in mind for how you want to address these things, and I'd rather contribute in places where I know I won't be stepping on your toes, or suggesting/adding things that you don't want to or aren't ready to add/support yet.

I'm still getting used to the idea of making any sort of contributions to someone's project and you've been really cool about being open to ideas and giving great feedback, so I want to make sure I stick to things where I know I won't be "intruding" (lacking a better word)

jonesguy14 commented 8 years ago

All your changes have been great so far and I appreciate your help! I get what you are saying about the feature list, some of the stuff I kinda have an idea for so it makes sense that you shouldn't start on them yet.

In the other pull request thread I mentioned the College OT rules, which is a bit more "objective" in the sense that its just a set of rules to implement. So if you are really looking for a challenge that could be a goal.