Skip to content

Commit 7e21cfc

Browse files
fix(scores): move storage under xyzzy
1 parent 3b22ce1 commit 7e21cfc

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Notes:
6161
the Kitty graphics protocol.
6262
- Download Ghostty: <https://ghostty.org/download>
6363
- Download Warp: <https://www.warp.dev/download>
64-
- The top score now persists between runs in `~/.pacman/high_score.txt`; set
65-
`PACMAN_DATA_DIR` to redirect that file for local experiments or tests.
64+
- The top score now persists between runs in `~/.xyzzy/pacman/high_scores.txt`;
65+
set `PACMAN_DATA_DIR` to redirect that file for local experiments or tests.
6666
- If `pacman` is not found after installation, ensure `~/.cargo/bin` is on your
6767
`PATH`.
6868

src/high_scores.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ impl HighScoreTable {
6868

6969
pub fn default_storage_path() -> PathBuf {
7070
if let Some(path) = env::var_os("PACMAN_DATA_DIR") {
71-
return PathBuf::from(path).join("high_score.txt");
71+
return PathBuf::from(path).join("high_scores.txt");
7272
}
7373

7474
if let Some(home) = env::var_os("HOME") {
75-
return PathBuf::from(home).join(".pacman").join("high_score.txt");
75+
return PathBuf::from(home)
76+
.join(".xyzzy")
77+
.join("pacman")
78+
.join("high_scores.txt");
7679
}
7780

78-
PathBuf::from(".pacman-high-score.txt")
81+
PathBuf::from(".xyzzy")
82+
.join("pacman")
83+
.join("high_scores.txt")
7984
}
8085

8186
#[cfg(test)]
@@ -127,7 +132,7 @@ mod tests {
127132
#[test]
128133
fn save_and_load_round_trip_the_top_score() {
129134
let dir = TempDir::new();
130-
let path = dir.path().join("high_score.txt");
135+
let path = dir.path().join("high_scores.txt");
131136
let mut table = HighScoreTable::default();
132137
table.record(23_450);
133138

@@ -158,7 +163,7 @@ mod tests {
158163
std::env::set_var("PACMAN_DATA_DIR", &override_path);
159164
}
160165
let path = default_storage_path();
161-
assert_eq!(path, override_path.join("high_score.txt"));
166+
assert_eq!(path, override_path.join("high_scores.txt"));
162167

163168
// SAFETY: This test sets process environment variables and restores them before exit.
164169
unsafe {
@@ -168,7 +173,7 @@ mod tests {
168173
let path = default_storage_path();
169174
assert_eq!(
170175
path,
171-
PathBuf::from("/tmp/pacman-home/.pacman/high_score.txt")
176+
PathBuf::from("/tmp/pacman-home/.xyzzy/pacman/high_scores.txt")
172177
);
173178

174179
// SAFETY: This test restores process environment variables modified above.

0 commit comments

Comments
 (0)