Spicy Invaders v.1.0.0
A TUI Space Invader
Loading...
Searching...
No Matches
Ch.Etml.IO.FileManager Class Reference

Manages input / output with the file system. More...

Public Member Functions

 FileManager (string path)
 Initializes a new FileManager.
 
void WriteScore (string username, int score, int wave)
 Writes a score to the scores file. A score in the scores file follows the "username,score,wave" pattern.
 
List<(string, int, int)> GetScores ()
 Gets the 15 best scoresfound in the scores file.
 

Private Attributes

readonly string _path
 Path of the score file.
 

Static Private Attributes

const int INDEX_OF_USERNAME = 0
 Index of the username in a scores file line.
 
const int INDEX_OF_SCORE = 1
 Index of the score in a scores file line.
 
const int INDEX_OF_WAVE = 2
 Index of the wave in a scores file line.
 
const int NB_SCORES_SHOWN = 15
 Number of scores to display in the high scores menu.
 
const char SEPARATOR = ','
 Character used to separate username, score and wave in the score file.
 

Detailed Description

Manages input / output with the file system.

Constructor & Destructor Documentation

◆ FileManager()

Ch.Etml.IO.FileManager.FileManager ( string path)

Initializes a new FileManager.

Parameters
pathLocation of the score file.

Member Function Documentation

◆ GetScores()

List<(string, int, int)> Ch.Etml.IO.FileManager.GetScores ( )

Gets the 15 best scoresfound in the scores file.

Returns
A list of the 15 highest scores, ordered from best to worst.

◆ WriteScore()

void Ch.Etml.IO.FileManager.WriteScore ( string username,
int score,
int wave )

Writes a score to the scores file. A score in the scores file follows the "username,score,wave" pattern.

Parameters
usernameName of the player.
scoreScore achieved by the player.
waveWave achieved by the player.

Member Data Documentation

◆ _path

readonly string Ch.Etml.IO.FileManager._path
private

Path of the score file.

◆ INDEX_OF_SCORE

const int Ch.Etml.IO.FileManager.INDEX_OF_SCORE = 1
staticprivate

Index of the score in a scores file line.

◆ INDEX_OF_USERNAME

const int Ch.Etml.IO.FileManager.INDEX_OF_USERNAME = 0
staticprivate

Index of the username in a scores file line.

◆ INDEX_OF_WAVE

const int Ch.Etml.IO.FileManager.INDEX_OF_WAVE = 2
staticprivate

Index of the wave in a scores file line.

◆ NB_SCORES_SHOWN

const int Ch.Etml.IO.FileManager.NB_SCORES_SHOWN = 15
staticprivate

Number of scores to display in the high scores menu.

◆ SEPARATOR

const char Ch.Etml.IO.FileManager.SEPARATOR = ','
staticprivate

Character used to separate username, score and wave in the score file.


The documentation for this class was generated from the following file: