Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions projects/AstroBalance/Assets/Scripts/SaveData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public T GetLastCompleteGameData()
/// <summary>
/// Get data from the last n complete played games.
/// </summary>
/// <param name="nGames">Number of games to retrieve</param>
/// <summary>
/// Get a list of data from the last n complete played games (or as many as have been completed). Game data is stored in chronological order, from earliest to latest (most recent game in final position).
/// </summary>
/// <param name="nGames">Maximum number of games to retrieve</param>
public IEnumerable<T> GetLastNCompleteGamesData(int nGames)
{
List<T> lastCompleteGames = new List<T>();
Expand All @@ -87,7 +90,7 @@ public IEnumerable<T> GetLastNCompleteGamesData(int nGames)
// Start from end of file, and find n complete games
while (lineNo > 0 && lastCompleteGames.Count() < nGames)
{
string line = File.ReadLines(dataPath).ElementAt(lineNo);
string line = csvLines.ElementAt(lineNo);

T gameData = CsvToGameData(header, line);
if (gameData.gameCompleted)
Expand All @@ -97,6 +100,8 @@ public IEnumerable<T> GetLastNCompleteGamesData(int nGames)
lineNo--;
}

lastCompleteGames.Reverse();

return lastCompleteGames;
}

Expand Down