jonesguy14 / footballcoach

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

Completed story about upperclassmen hazing and scaring off recruit #58

Closed destilla closed 8 years ago

destilla commented 8 years ago

Story progresses from Weeks 0 to 2 and essentially goes: Player implicates himself as ring leader and user is informed that one saveCurse's rival's Freshman is a flip commit from saveCurse resulting from the hazing, following week it's reported that no players missed time and the coach is silent, final week (2) there's a 50/50 chance to have the coach release a statement saying nothing or that the team will be responsible for giving back to the community.

Slightly restructured the switch statement for developing stories to allow for more flexibility in having multi week stories (previously you could only have one extra story appear on the week you specified). Stories can now be set to appear whenever by indicating how far beyond the original development the new story should appear.

Finally, introduced Arraylists containing players grouped by class status (FR, SO, JR, etc) for use in stats, news stories, etc. Currently these arraylists are only populated with the player's class, name, and position and exist separately from the arraylists for each position (PlayerQBs, PlayerCBs, etc).

Thoughts: Is there a cleaner way to handle finding specific freshman/sophomore/etc players on a team rather than grouping them together? Or is grouping them fine (i.e. not too expensive and doesn't make the code confusing). Also I'm basically making any variable I need to reference later or in another .java file public. Not sure if this is the correct practice or if there's anything dangerous about this, etc. As usual, noobie coder so I'm not familiar with many best practices.

Extra note: I had the WORST time trying to merge this. I accidentally forgot to pull your changes to my fork before committing mine, so Github wouldn't let me auto merge my new stuff. Sooooo, I had to do all of this by hand. I've double checked for issues but if something even looks kind of strange, please ask if I meant for that.

destilla commented 8 years ago

Screenshots of the new stories:

http://imgur.com/a/bPRCm

http://imgur.com/0OL8AHh

jonesguy14 commented 8 years ago

I just made a really big commit, it doesn't look like there are any conflicts with yours though so that's good.

One thing I would change before we merge is that right now like you said you create a new Player object for all the players in each class, from RS to Sr. This might make the game run slower, since now each team has another 40+ Player objects, and probably isn't needed. Instead, I think you should be able to have lists for each class that store references to already existing player objects. So you could just iterate through all the teamQBs, teamRBs, etc and add the player to the correct list. This is more memory-friendly and better in the long run.

Besides that, I like the story! I hope all these changes you are making encourage people to look at the news stories, we should eventually add more game specific ones too (like X qb throws for 10 TDs or whatever).

My latest commit was pretty big, with injuries and some UI changes, so make sure your code works with it too. (I think it should be fine though). We can probably put out a new version sometime this weekend.

destilla commented 8 years ago

I think I understand the concept you're suggesting, but I want to make sure I know how to do it properly:

The last bullet is what I'm a little fuzzy on. I understand not making a new player object, but I'm having a tough time finding out how to make a reference to an object and put it in a list. Stack Overflow gave me an idea, and it looks like their suggestion was what I said above (new arraylist, add the player object to that list). Not sure if that's equally/more memory intensive than what I originally did and I'm not even sure if it's what you suggested, lol.

I just want to make sure I'm doing the right thing.

And thanks! I'm going to start focusing on working on other things after I put a few more stories in, but the community gave us a lot of great ideas and I don't want to discourage that level of participation by being like "Great idea, but I'm going to ignore the contribution you made that I specifically requested to do something else", plus I felt like I pushed out a half finished version of the original iteration just so we could have something, so I wanted to wrap up what I started.

My hope is that people can look at the stories and that some level of immersion is added and it kind of hides the inner workings of the game a bit. Part of what was great about a game like Half Life 2 the first time I played it was that it was doing all this really awesome stuff. If you don't understand how games are made or how programming works, it might as well be magic, and the immersion is really powerful.

The first time I opened up Hammer (level editor) and started looking at stuff it was kind of like "Oh...less magical." -- So I'm hoping the News can preserve the magic a little bit.

jonesguy14 commented 8 years ago

Yeah the steps you outlined are exactly how you should do it.

teamFRs = new ArrayList<>();
teamSOs = new ArrayList<>();

for (PlayerQB p : teamQBs) {
    if (p.year == 1) teamFRs.add(p);
    if (p.year == 2) teamSOs.add(p);
    // etc
}

You would do this on each teamXX list, or maybe write a function that takes in a List<? extends Player> and iterates through it, adding each player to the correct year list, which you would call on each teamXX list.

The reason that this way is preferred is that no new objects are created, its just storing existing objects in more lists.

But yeah I agree about the News Stories, it makes it feel more real, like your team is an actual participant in a larger league, with real events occurring to other teams.

destilla commented 8 years ago

Added commit 78b608f to change how the players are added based on your suggestion.

For the sake of not needing to change much code, and because what you described sounds efficient, I literally just implemented your suggestion -- Each player position arraylist is looped through, players are added to the student class they belong to, and...well yeah that's it. Then we have new arraylists for each student class, and there aren't a bunch of new objects.

The nice thing about your suggestion is that it still populates the arraylists I created earlier, and I don't need to change the way the newsstories are written, because nothing technically changed as far as they are concerned.

In fact your suggestion gives us a more robust solution, because every attribute the player has can be referenced now, whereas before, I would need to add a line to say "add this attribute from the original player to the new player object" for each thing I wanted to reference.

Thanks for the help!

jonesguy14 commented 8 years ago

Looks good!