jonesguy14 / footballcoach

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

Add News Stories to Week 0 for Cursed/Blessed Programs #43

Closed destilla closed 8 years ago

destilla commented 8 years ago

Best place I could think to submit this idea, it seems GitHub lacks a feature suggestion forum:

Basically if a team is cursed maybe randomly choose one of a few stories, like:

" TEAMNAME hit with two year probation after investigation finds program committed minor infractions"

"Long time coach of TEAMNAME, (build a player name), announces sudden retirement effectively immediately"

"An anonymous benefactor has completely covered the cost of new training facilities for TEAMNAME, resulting in large scale improvements to the program's infrastructure"

"TEAMNAME has hired former alumnus and professional football coach, (build a player name), in hopes of revitalizing the program"

As usual, I'm not married to or suggesting the specific flavor text, but just something to denote the change in prestige and make it kind of interesting.

destilla commented 8 years ago

Also wanted to add that I'm taking some time to familiarize myself with parts of the code that aren't just "League.java" and "Game.java", but as of right now I have no idea how activities/context/intent/etc work, so I have no idea if this is simple and feasible or if what I'm suggesting is more than an hour of work. Seems simple in my head but I guess it never stays that way.

jonesguy14 commented 8 years ago

I do like this idea but it would have to change the way a league is saved (meaning just add a couple lines). At the end of each season, advanceSeason is called on the league (which will curse/bless a team) and then the league is saved. So there would need to be a way to save which teams were blessed or cursed. Definitely possible, maybe just add another line somewhere to the save file.

destilla commented 8 years ago

How are the news stories cleared year to year? Looking at advance season I see it sets the week to 0 and then does stuff (bless, curse, set schedules, etc). Would it be an issue of the default "go get 'em champ" week 0 story is hardcoded to be there for week 0, but this would require actual dynamic saving of info and thus would require a change?

(I'm trying to understand what I'm looking at and how all these things work, haha)

jonesguy14 commented 8 years ago

Basically when a user presses Save Game, only some stuff is saved. This is:

So the news stories aren't saved at all right now, they just exist as long as the League object exists. If we wanted to save a particular thing, like who was blessed or cursed, that would just be another line in the save file (which actually isn't too bad).

destilla commented 8 years ago

I think, after way too much time, I'm putting together how this works in my brain. I'm taking a stab at making some news stories. Although it's taking me more than a few lines, so maybe I'm doing something wrong?

I'll explain what I've done when it's actually done, right now I'm still putting the puzzle pieces together.

akeaswaran commented 8 years ago

Here's a thought: could you add a news story containing a random selection of those above bless/curse scenarios (depending on which is happening to the team) to the array of news stories right after you advance seasons? I ask because in the iOS version, I've implemented advanceSeason like so:

screen shot 2016-03-28 at 8 47 58 pm

In theory, I should be able to clear out the news stories array (like I do on lines 601-603) and then just add stories to index 0 like normal. Can something like this be done in the Android version?

destilla commented 8 years ago

That would work in the event that you're playing through seasons without taking a break. However, if you stopped, saved, and reloaded later, (and this is where I'm taking a leap of faith in assuming I understand what's going on) the news stories aren't saved, and therefore can't be loaded.

You have to save the team that's been blessed, save the team that's been cursed, then when the news stories are initialized, create the stories.

At the end of saveLeague(), I write the blessed team's name to sb with all the history and player info, then an "END_BLESS_TEAM" and do the same for curse team:

    public boolean saveLeague(File saveFile) {
        StringBuilder sb = new StringBuilder();
        sb.append((2015+leagueHistory.size())+": " + userTeam.abbr + " (" + (userTeam.totalWins-userTeam.wins) + "-" + (userTeam.totalLosses-userTeam.losses) + ") " +
                    userTeam.totalCCs + " CCs, " + userTeam.totalNCs + " NCs%\n");

        for (int i = 0; i < leagueHistory.size(); ++i) {
            for (int j = 0; j < leagueHistory.get(i).length; ++j) {
                sb.append(leagueHistory.get(i)[j] + "%");
            }
            sb.append("\n");
        }
        sb.append("END_LEAGUE_HIST\n");

        for (int i = 0; i < heismanHistory.size(); ++i) {
            sb.append(heismanHistory.get(i) + "\n");
        }
        sb.append("END_HEISMAN_HIST\n");

        for (Team t : teamList) {
            sb.append(t.conference + "," + t.name + "," + t.abbr + "," + t.teamPrestige + "," +
                    (t.totalWins-t.wins) + "," + (t.totalLosses-t.losses) + "," + t.totalCCs + "," + t.totalNCs + "," + t.rivalTeam + "," +
                    t.totalNCLosses + "," + t.totalCCLosses + "," + t.totalBowls + "," + t.totalBowlLosses + "," +
                    t.teamStratOffNum + "," + t.teamStratDefNum + "," + (t.showPopups ? 1 : 0) + "%\n");
            sb.append(t.getPlayerInfoSaveFile());
            sb.append("END_PLAYERS\n");
        }

        sb.append(userTeam.name + "\n");
        for (String s : userTeam.teamHistory) {
            sb.append(s + "\n");
        }
        sb.append("END_USER_TEAM\n");

        if (userTeam != blessTeam) {
            sb.append(blessTeam.name + "\n");
            sb.append("END_BLESS_TEAM\n");
        }
        if (userTeam != curseTeam) {
            sb.append(curseTeam.name + "\n");
            sb.append("END_CURSE_TEAM\n");
        }

        try (Writer writer = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream(saveFile), "utf-8"))) {
            writer.write(sb.toString());
            return true;
        } catch (Exception e) {
            return false;
        }
    }

Then, when the season is being advanced and the league is being "recreated" essentially for the new season in advanceSeason(), I grab the names of those teams:

            blessedList = new ArrayList<String>();
            while((line = bufferedReader.readLine()) !=null && !line.equals("END_BLESS_TEAM")){
                blessedList.add(line);
            }

            cursedList = new ArrayList<String>();
            while((line = bufferedReader.readLine()) != null && !line.equals("END_CURSE_TEAM")){
                cursedList.add(line);
            }

I think using an ArrayList was unnecessary but really I just wanted to make sure the damn thing worked.

Finally, I print out the news stories along with the inital week 0 stuff:

 // Initialize new stories lists
            newsStories = new ArrayList< ArrayList<String> >();
            for (int i = 0; i < 16; ++i) {
                newsStories.add(new ArrayList<String>());
            }
            newsStories.get(0).add("New Season!>Ready for the new season, coach? Whether the National Championship is " +
                    "on your mind, or just a winning season, good luck!");
            newsStories.get(0).add(blessedList.get(0) + " loving their free prestige!>Yo! Champ in making! Brock likes to use ground type Pokemon and your Pikachu can't handle them. Maybe if he spent a year with " + blessedList.get(0) + " he would be tough enough to go blow for blow.");
            newsStories.get(0).add(cursedList.get(0) + " fans on riot watch!>Yo! Champ in making! That curse you put upon " + cursedList.get(0) + " is destroying the fans.");

In MainActivity, I added simLeague.blessTeam and simleague.curseTeam to the info for the save file, but I can't remember why I did that and I think I can remove that.

Anyway, here was the result:

image

Ignore the names, I changed them in my league.java -- Anyway, USC lost about 20 (after accounting the gains the prev season) and Tulsa gained about 30 (after accounting the losses from the prev season)

akeaswaran commented 8 years ago

Ah ok, so the iOS version saves and repopulates the League object on app start and subsequent restart, so that's why I thought that was possible. Looks like you've figured it out though, nice job!

jonesguy14 commented 8 years ago

Yeah destilla that's exactly how I would do it as well. One thing you need to worry about is trying to read old save files that don't have the Blessed and Cursed teams saved. So you would need to check to see if there are lines after END_USER_TEAM and read them like you do, if not then that means its from an old save file.

Looks really good though, once you confirm that it works with old save files and have the news stories set up with non-filler text, definitely do a pull request!