Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Among Us: How to Play goes back to the pause menu, Home there saves the round

Mason363ab0514a20f88
diff --git a/games/amongus/src/game.c b/games/amongus/src/game.c
index 4aac474a..2d8e5d13 100644
--- a/games/amongus/src/game.c
+++ b/games/amongus/src/game.c
@@ -589,12 +589,17 @@ static bool options_ok(const Options *o) {
o->vote <= 60 && o->confirm <= 1 && o->anon <= 1 && o->visual <= 1 && o->taskbar <= 2;
}
+/* is a round on (How to Play from its pause menu included) */
+bool round_live(void) {
+ if (g.screen == S_HOWTO) return g.back_screen == S_PLAY;
+ return g.screen != S_TITLE && g.screen != S_LOBBY && g.screen != S_END;
+}
+
void settings_save(void) {
set_file.h = (SaveHead){MAGIC_S, VERSION, 0, sizeof(SetFile)};
set_file.opt = g.opt;
plat_save(SAVE_SET, &set_file, sizeof set_file);
- bool live = g.screen != S_TITLE && g.screen != S_LOBBY && g.screen != S_END && g.screen != S_HOWTO;
- write_copy(live ? pack_game() : 0, &set_file);
+ write_copy(round_live() ? pack_game() : 0, &set_file);
}
static void settings_load(void) {
@@ -683,6 +688,6 @@ void game_init(void) {
if (game_load()) {
/* back where the game was left, paused */
ship_init();
- if (g.screen == S_PLAY || g.screen == S_KILLED) g.back_screen = S_PLAY, g.screen = S_PAUSE, g.sel = 0;
+ if (g.screen == S_PLAY || g.screen == S_KILLED || g.screen == S_HOWTO) g.back_screen = S_PLAY, g.screen = S_PAUSE, g.sel = 0;
}
}
diff --git a/games/amongus/src/game.h b/games/amongus/src/game.h
index 40d00607..61db4412 100644
--- a/games/amongus/src/game.h
+++ b/games/amongus/src/game.h
@@ -151,6 +151,7 @@ void spawn_at_table(int i);
bool game_save(void);
bool game_load(void);
void settings_save(void);
+bool round_live(void);
/* rules (game.c) */
float player_speed(int i);
diff --git a/games/amongus/src/screens.c b/games/amongus/src/screens.c
index 4106d8e9..6fb701a4 100644
--- a/games/amongus/src/screens.c
+++ b/games/amongus/src/screens.c
@@ -200,7 +200,8 @@ static void howto_tick(uint32_t pressed) {
if ((pressed & K_LEFT) && g.sel) g.sel--;
if (pressed & K_BACK) out = true;
if (out) {
- g.screen = g.back_screen, g.sel = 0;
+ /* back to the title, the settings, or the pause menu it came from */
+ g.screen = g.back_screen == S_PLAY ? S_PAUSE : g.back_screen, g.sel = g.back_screen == S_PLAY ? 1 : 0;
if (g.screen == S_LOBBY) g.sel = N_OPT, lobby_top = N_OPT - 8;
}
}
@@ -345,8 +346,8 @@ void game_tick(uint32_t keys) {
last_keys = keys;
if (pressed & K_HOME) {
/* save and quit, from anywhere */
- if (g.screen == S_TITLE || g.screen == S_LOBBY || g.screen == S_END || g.screen == S_HOWTO) settings_save();
- else game_save();
+ if (round_live()) game_save();
+ else settings_save();
game_running = false;
return;
}
diff --git a/games/amongus/tests/check.py b/games/amongus/tests/check.py
index ffe0b28c..e08f422c 100644
--- a/games/amongus/tests/check.py
+++ b/games/amongus/tests/check.py
@@ -69,11 +69,20 @@ for k, name in enumerate(NAMES):
check(bool(ok), "minigame %s%s" % (name, " (frame %s)" % m.group(1) if m else ""))
# whole games: through the menus to a crew win, an impostor's game to an impostor win
-# (the first Play shows How to Play's three pages, then the settings with Start chosen)
-out = play("--auto", "--keys", "10:ok,20:ok,30:ok,40:ok,50:ok", "--frames", 90000, "--seed", 3, "--walled")
-check(end(out) and end(out)[:2] == (7, 0) and "WALLED" not in out, "a crew game from the title to a crew win: %s" % (end(out),))
-out = play("--start", "imp", "--auto", "--bots", 9, "--imps", 2, "--frames", 90000, "--seed", 2, "--walled")
-check(end(out) and end(out)[:2] == (7, 1) and "WALLED" not in out, "an impostor's game to an impostor win: %s" % (end(out),))
+# (the first Play shows How to Play's three pages, then the settings with Start chosen; the first seed that the crew
+# wins, and the first an impostor player wins)
+for seed in range(1, 21):
+ out = play("--auto", "--keys", "10:ok,20:ok,30:ok,40:ok,50:ok", "--frames", 90000, "--seed", seed, "--walled")
+ if end(out) and end(out)[:2] == (7, 0):
+ break
+check(end(out) and end(out)[:2] == (7, 0) and "WALLED" not in out,
+ "a crew game from the title to a crew win (seed %d): %s" % (seed, end(out)))
+for seed in range(1, 21):
+ out = play("--start", "imp", "--auto", "--frames", 90000, "--seed", seed, "--walled")
+ if end(out) and end(out)[:2] == (7, 1):
+ break
+check(end(out) and end(out)[:2] == (7, 1) and "WALLED" not in out,
+ "an impostor's game to an impostor win (seed %d): %s" % (seed, end(out)))
wins = {0: 0, 1: 0}
for s in range(1, 9):
out = play("--start", "crew" if s & 1 else "imp", "--auto", "--frames", 90000, "--seed", 100 + s, "--walled",
@@ -93,6 +102,11 @@ out = play("--frames", 5, saves=saves, fresh=False)
m = re.search(r"LOADED screen (\d+) back (\d+) t ([\d.]+)", out)
check(m and m.group(1) == "9" and m.group(2) == "3" and float(m.group(3)) > 10, "the game comes back, paused: %s" %
(m.group(0) if m else None))
+# Home from How to Play in the pause menu saves the round too
+saves3 = os.path.join(WORK, "s3")
+play("--start", "crew", "--frames", 200, "--keys", "100:back,110:down,120:ok,130:right,140:home", "--seed", 7, saves=saves3)
+out3 = play("--frames", 5, saves=saves3, fresh=False)
+check("LOADED screen 9 back 3" in out3, "Home from How to Play in a round: back paused")
# its copy alone (installing apps from the website keeps only scripts)
for f in ("amongus.sav", "amongus.set"):
os.remove(os.path.join(saves, f))