Skip to content

Commit

Permalink
Added ability to save scores to text file on start
Browse files Browse the repository at this point in the history
  • Loading branch information
MRumple105 committed Dec 11, 2021
1 parent 5f94c9e commit 7e7f0d0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Revex-VR/Assets/Scripts/Libraries/Scores.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public Scores(string datapath) {
_dir = datapath + "/scores";
_path = datapath + "/scores/scores.rec";
ReadFromFile();
WriteScoresToTextFile();
}

public bool WriteToFile() {
Expand Down Expand Up @@ -74,5 +75,19 @@ public Dictionary<string, int> GetTopScores(int numScores) {
return _scores.OrderByDescending(pair => pair.Value).Take(numScores)
.ToDictionary(pair => pair.Key, pair => pair.Value);
}

public void WriteScoresToTextFile()
{
string scoreFile = "";

int count = 1;
foreach (string key in GetTopScores(1000).Keys)
{
_scores.TryGetValue(key, out int scr);
scoreFile += count + ". " + key + ": " + scr + "\n";
count++;
}

File.WriteAllText(_dir + "/scores.txt", scoreFile);
}
}
Binary file modified Revex-VR/Assets/scores/scores.rec
Binary file not shown.
42 changes: 42 additions & 0 deletions Revex-VR/Assets/scores/scores.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
1. Matt: 35
2. the dude: 33
3. Aidan: 32
4. Zach: 31
5. Aaron: 30
6. Ham: 30
7. Jake from state farm: 30
8. kerway: 30
9. Tyson: 29
10. Sai: 29
11. Michael: 29
12. habib: 29
13. Zack: 28
14. Alex: 28
15. Justin: 28
16. Rajeev: 28
17. mwen: 25
18. Yusuf Jarada: 25
19. Stas: 24
20. Adrin: 23
21. Logan: 22
22. Russell: 22
23. Marc: 21
24. Yourong: 21
25. Lohith: 21
26. Thanos: 20
27. swag is bad: 20
28. Varun: 20
29. uwu: 19
30. Nic: 18
31. Jesse: 18
32. Yug: 18
33. Yigitkan: 17
34. Mitchell: 17
35. Anjali: 17
36. Sam: 16
37. Mohamed: 14
38. Andjey: 14
39. Phil: 12
40. Swag: 9
41. Prajesh: 9
42. Abhi: 8
7 changes: 7 additions & 0 deletions Revex-VR/Assets/scores/scores.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e7f0d0

Please sign in to comment.