magmacrunch-caldera 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .venv/
7
+ venv/
8
+ dist/
9
+ build/
@@ -0,0 +1,75 @@
1
+ Required Notice: Copyright 2026 magmacrunch media (https://magmacrunch.com)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
@@ -0,0 +1,38 @@
1
+ CALDERA
2
+ Copyright 2026 magmacrunch media
3
+
4
+
5
+ THE LICENCE
6
+
7
+ Everything in this repository -- the game in web/, its terminal version in
8
+ tui/, their tools and the documentation -- is licensed under the PolyForm Noncommercial License 1.0.0, in
9
+ the LICENSE file beside this one.
10
+
11
+ Read it, learn from it, build on it, play with it. Any noncommercial purpose is
12
+ permitted, and that includes personal projects, teaching and research. What is
13
+ not permitted is commercial use: selling the game or a derivative of it,
14
+ shipping it inside a product, or running it as part of a business.
15
+
16
+
17
+ THE GENRE IS NOBODY'S, THE NAME IS NOT THEIRS
18
+
19
+ CALDERA is a vertical climber in the tradition of Icy Tower (Free Lunch Design,
20
+ 2001). It shares that genre's mechanics, which are not anyone's property, and
21
+ none of its name, art, sound or code. It is not affiliated with or endorsed by
22
+ Free Lunch Design.
23
+
24
+ What is reserved: the magmacrunch name and marks. If you want to use them, ask.
25
+
26
+
27
+ THIRD-PARTY COMPONENTS
28
+
29
+ The page loads adenosine-rpg.js, adenosine-score-client.js, score-server.js and
30
+ arcade-base.css from the website's arcade/shared/. Those are part of the
31
+ magmacrunch.com repository and adenosine, and are not copied here.
32
+
33
+ web/js/cast/ holds four character drawings copied from moonlight-drift
34
+ (Dag Henderson, Fire Toad, F. Joel Young King, Vinny Bobarino), by magmacrunch
35
+ media under the same licence.
36
+
37
+ The Press Start 2P font is loaded from Google Fonts under the SIL Open Font
38
+ License 1.1 rather than shipped here.
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.5
2
+ Name: magmacrunch-caldera
3
+ Version: 0.1.0
4
+ Summary: CALDERA - climb the vent, outrun the magma. Terminal version.
5
+ Project-URL: Homepage, https://magmacrunch.com/arcade/caldera/
6
+ Author: magmacrunch media
7
+ License-Expression: PolyForm-Noncommercial-1.0.0
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Keywords: arcade,climber,games,terminal,tui
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: magmacrunch>=0.7.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=7.0; extra == 'dev'
15
+ Requires-Dist: ruff>=0.6; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # CALDERA (terminal)
19
+
20
+ Climb the vent. Outrun the magma. The second version of the game, beside
21
+ `web/`, on the [magmacrunch](https://github.com/magmacrunch-media/magmacrunch)
22
+ engine's terminal backend. It is a cabinet in the magmacrunch arcade and its
23
+ own command, and plays the same either way.
24
+
25
+ ```
26
+ pipx install magmacrunch-caldera
27
+ caldera
28
+ ```
29
+
30
+ For working on it:
31
+
32
+ ```
33
+ pip install -e ".[dev]"
34
+ python -m caldera
35
+ ```
36
+
37
+ ## It is the browser's game, not a remake of it
38
+
39
+ The rules are a line-for-line port of `web/js/tower.js`, `player.js`,
40
+ `score.js` and `game.js`, in world units at 60 Hz, with the same seeded
41
+ generator. `tests/test_oracle.py` runs the real JS through
42
+ `tools/js_oracle.mjs`, replays every input it fed into `caldera/sim.py`, and
43
+ requires the same state back after every frame. Exactly the same, not close:
44
+ both sides are IEEE doubles doing the same operations in the same order, so any
45
+ difference is a transcription error. A tower is a seed on both sides, and a
46
+ score means the same thing on both boards. Scores are filed under `caldera`,
47
+ with the browser's `floor`, `crunch` and `character` fields beside them.
48
+
49
+ The terminal draws at 30 fps and steps the rules twice a frame. Stepping once
50
+ would play the browser's game at half speed without anything looking wrong.
51
+
52
+ ## Running, in a terminal
53
+
54
+ A terminal reports that a key went down and never that it came up, and a held
55
+ key goes quiet for about half a second before it repeats. Read as held state,
56
+ that is a run that will not start and a climber that will not stop on a ledge.
57
+ So **running latches**:
58
+
59
+ | key | |
60
+ |---|---|
61
+ | `←` `→` (or A/D) | run that way, and keep running |
62
+ | `↓` (or S) | stop running; the rock's friction does the rest |
63
+ | `SPACE` `↑` W | jump |
64
+ | `P` | pause |
65
+ | `R` | restart |
66
+ | `Esc` | back to the title (from the title, back to the arcade) |
67
+ | `Q` | quit |
68
+
69
+ Tap the other arrow to turn round mid-run, and the browser's skid does what it
70
+ does for a player who swaps keys. Hit a wall in the air and your heading turns
71
+ with the bounce, which is what a good browser player does with their fingers at
72
+ every wall. Walking into a wall on the ground just stands you there.
73
+
74
+ `tests/test_sim.py` checks that this can play the game: a bot only allowed
75
+ to press keys climbs exactly as far through the latch as the same bot holding
76
+ keys directly.
77
+
78
+ ## The rest
79
+
80
+ ```
81
+ caldera --list-climbers the cast
82
+ caldera --climber king climb as somebody in particular
83
+ caldera --seed 42 the same towers every time
84
+ caldera --play skip the title
85
+ caldera --ascii no block or arrow glyphs
86
+ ```
87
+
88
+ Every glyph it draws is in the engine's degradation table, so a cp1252 or cp437
89
+ terminal gets the same layout in plain characters. `tests/test_app.py` sweeps
90
+ every screen for anything that is not. Under `NO_COLOR` the climber and the
91
+ magma are drawn in glyphs rather than background colour, so they do not vanish
92
+ when colour does.
93
+
94
+ Needs a 40x20 terminal; 80x24 is comfortable and anything wider adds side
95
+ panels for the run's numbers rather than a wider vent.
96
+
97
+ ## Licence
98
+
99
+ [PolyForm Noncommercial 1.0.0](LICENSE), as the rest of this repository. See
100
+ [NOTICE](NOTICE).
@@ -0,0 +1,83 @@
1
+ # CALDERA (terminal)
2
+
3
+ Climb the vent. Outrun the magma. The second version of the game, beside
4
+ `web/`, on the [magmacrunch](https://github.com/magmacrunch-media/magmacrunch)
5
+ engine's terminal backend. It is a cabinet in the magmacrunch arcade and its
6
+ own command, and plays the same either way.
7
+
8
+ ```
9
+ pipx install magmacrunch-caldera
10
+ caldera
11
+ ```
12
+
13
+ For working on it:
14
+
15
+ ```
16
+ pip install -e ".[dev]"
17
+ python -m caldera
18
+ ```
19
+
20
+ ## It is the browser's game, not a remake of it
21
+
22
+ The rules are a line-for-line port of `web/js/tower.js`, `player.js`,
23
+ `score.js` and `game.js`, in world units at 60 Hz, with the same seeded
24
+ generator. `tests/test_oracle.py` runs the real JS through
25
+ `tools/js_oracle.mjs`, replays every input it fed into `caldera/sim.py`, and
26
+ requires the same state back after every frame. Exactly the same, not close:
27
+ both sides are IEEE doubles doing the same operations in the same order, so any
28
+ difference is a transcription error. A tower is a seed on both sides, and a
29
+ score means the same thing on both boards. Scores are filed under `caldera`,
30
+ with the browser's `floor`, `crunch` and `character` fields beside them.
31
+
32
+ The terminal draws at 30 fps and steps the rules twice a frame. Stepping once
33
+ would play the browser's game at half speed without anything looking wrong.
34
+
35
+ ## Running, in a terminal
36
+
37
+ A terminal reports that a key went down and never that it came up, and a held
38
+ key goes quiet for about half a second before it repeats. Read as held state,
39
+ that is a run that will not start and a climber that will not stop on a ledge.
40
+ So **running latches**:
41
+
42
+ | key | |
43
+ |---|---|
44
+ | `←` `→` (or A/D) | run that way, and keep running |
45
+ | `↓` (or S) | stop running; the rock's friction does the rest |
46
+ | `SPACE` `↑` W | jump |
47
+ | `P` | pause |
48
+ | `R` | restart |
49
+ | `Esc` | back to the title (from the title, back to the arcade) |
50
+ | `Q` | quit |
51
+
52
+ Tap the other arrow to turn round mid-run, and the browser's skid does what it
53
+ does for a player who swaps keys. Hit a wall in the air and your heading turns
54
+ with the bounce, which is what a good browser player does with their fingers at
55
+ every wall. Walking into a wall on the ground just stands you there.
56
+
57
+ `tests/test_sim.py` checks that this can play the game: a bot only allowed
58
+ to press keys climbs exactly as far through the latch as the same bot holding
59
+ keys directly.
60
+
61
+ ## The rest
62
+
63
+ ```
64
+ caldera --list-climbers the cast
65
+ caldera --climber king climb as somebody in particular
66
+ caldera --seed 42 the same towers every time
67
+ caldera --play skip the title
68
+ caldera --ascii no block or arrow glyphs
69
+ ```
70
+
71
+ Every glyph it draws is in the engine's degradation table, so a cp1252 or cp437
72
+ terminal gets the same layout in plain characters. `tests/test_app.py` sweeps
73
+ every screen for anything that is not. Under `NO_COLOR` the climber and the
74
+ magma are drawn in glyphs rather than background colour, so they do not vanish
75
+ when colour does.
76
+
77
+ Needs a 40x20 terminal; 80x24 is comfortable and anything wider adds side
78
+ panels for the run's numbers rather than a wider vent.
79
+
80
+ ## Licence
81
+
82
+ [PolyForm Noncommercial 1.0.0](LICENSE), as the rest of this repository. See
83
+ [NOTICE](NOTICE).
File without changes
@@ -0,0 +1,52 @@
1
+ """``python -m caldera`` -- play CALDERA in a terminal."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+
7
+
8
+ def main() -> None:
9
+ parser = argparse.ArgumentParser(
10
+ prog="caldera",
11
+ description="CALDERA - climb the vent, outrun the magma.",
12
+ )
13
+ parser.add_argument("--climber", default=None,
14
+ help="who climbs, by key (see --list-climbers)")
15
+ parser.add_argument("--list-climbers", action="store_true",
16
+ help="print the cast and exit")
17
+ parser.add_argument("--seed", type=int, default=None,
18
+ help="fix the session's towers, for a reproducible one")
19
+ parser.add_argument("--play", action="store_true",
20
+ help="skip the title screen and start climbing")
21
+ parser.add_argument(
22
+ "--ascii", action="store_true", dest="ascii_only",
23
+ help="draw with plain ASCII instead of block and arrow glyphs. "
24
+ "Detected automatically from the terminal's encoding; this "
25
+ "forces it. MAGMACRUNCH_ASCII=1 says the same for every cabinet.",
26
+ )
27
+ args = parser.parse_args()
28
+
29
+ if args.list_climbers:
30
+ # Imported here so --help costs nothing.
31
+ from caldera import config
32
+
33
+ for key in config.CAST_ORDER:
34
+ member = config.CAST[key]
35
+ print(f" {key:<8} {member['name']:<20} {member['role']:<12} "
36
+ f"{member['blurb']}")
37
+ return
38
+
39
+ if args.climber is not None:
40
+ from caldera import config
41
+
42
+ if args.climber not in config.CAST_ORDER and args.climber not in config.CAST_RENAMED:
43
+ parser.error(f"no climber {args.climber!r}; "
44
+ f"choose from {', '.join(config.CAST_ORDER)}")
45
+
46
+ from caldera.app import run
47
+
48
+ run(args.climber, args.seed, args.play, args.ascii_only)
49
+
50
+
51
+ if __name__ == "__main__":
52
+ main()
@@ -0,0 +1,129 @@
1
+ """Wiring -- what outlives a single run, and how the screens reach it.
2
+
3
+ Everything that draws lives in :mod:`caldera.scenes`; everything that decides
4
+ lives in :mod:`caldera.sim`. This holds who is climbing, the high score
5
+ table and the source of seeds.
6
+
7
+ **The terminal is not owned here.** It belongs to a
8
+ :class:`~magmacrunch.engine.core.tui_host.TuiHost`, which this is handed --
9
+ the arrangement every cabinet uses, and what lets CALDERA run as its own
10
+ command or be seated by the arcade without knowing which happened.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import random
16
+ from typing import Any
17
+
18
+ from magmacrunch.engine.scores import ScoreBook
19
+
20
+ from caldera import config, sim
21
+ from caldera.scenes import GameScene, TitleScene
22
+
23
+
24
+ class CalderaApp:
25
+ """A session of CALDERA, drawing on somebody else's terminal."""
26
+
27
+ def __init__(self, host: Any, character: str | None = None,
28
+ seed: int | None = None, scores: ScoreBook | None = None):
29
+ self.host = host
30
+ #: Where each run's tower seed comes from. Seeded, so a whole session
31
+ #: replays from one number; ``--seed`` is how a report becomes a repro.
32
+ self.rng = random.Random(seed)
33
+ self.character = sim.known(character)
34
+ #: Filed under the key the browser posts to, so a shared board later
35
+ #: means one board. Records carry the browser's extra fields too:
36
+ #: ``floor``, ``crunch`` and ``character``.
37
+ self.scores = scores or ScoreBook(config.SCORES_GAME)
38
+ self.initials = "AAA"
39
+ self.last_rank: int | None = None
40
+ #: The first-run hints stop once a CRUNCH has been banked, as on the
41
+ #: web. Per session here: the browser remembers it in localStorage and
42
+ #: this has nowhere it owns to put it.
43
+ self.hints_done = False
44
+ self.root_scene = TitleScene(self)
45
+
46
+ @property
47
+ def renderer(self):
48
+ return self.host.renderer
49
+
50
+ def next_seed(self) -> int:
51
+ return self.rng.randrange(1 << 32)
52
+
53
+ # -- Flow --------------------------------------------------------
54
+
55
+ def start_run(self) -> None:
56
+ self.host.push_scene(GameScene(self))
57
+
58
+ def choose_climber(self, run: GameScene | None = None) -> None:
59
+ """The roster. Given the run it was opened from, choosing restarts it."""
60
+ from caldera.scenes import ClimberScene
61
+
62
+ self.host.push_scene(ClimberScene(self, run=run))
63
+
64
+ def show_scores(self) -> None:
65
+ from caldera.scenes import ScoresScene
66
+
67
+ self.host.push_scene(ScoresScene(self))
68
+
69
+ def show_rules(self) -> None:
70
+ from caldera.scenes import RulesScene
71
+
72
+ self.host.push_scene(RulesScene(self))
73
+
74
+ def enter_initials(self, score: int, extra: dict) -> None:
75
+ from caldera.scenes import InitialsScene
76
+
77
+ self.host.push_scene(InitialsScene(self, score, extra))
78
+
79
+ def set_character(self, character: str) -> None:
80
+ """Climb as somebody else from the next run on."""
81
+ self.character = sim.known(character)
82
+
83
+ def to_title(self) -> None:
84
+ self.host.pop_scene()
85
+
86
+ def leave(self) -> None:
87
+ """Pop the title. Alone that ends the session; seated, it returns to
88
+ the arcade. The game does not need to know which."""
89
+ self.host.pop_scene()
90
+
91
+ # -- Scores ------------------------------------------------------
92
+
93
+ @property
94
+ def best(self) -> int:
95
+ return self.scores.best()
96
+
97
+ def qualifies(self, score: int) -> bool:
98
+ return score > 0 and self.scores.qualifies(score)
99
+
100
+ def record(self, score: int, initials: str | None = None,
101
+ extra: dict | None = None):
102
+ self.initials = initials or self.initials
103
+ result = self.scores.save(self.initials, score, **(extra or {}))
104
+ self.last_rank = result.rank
105
+ return result
106
+
107
+ # -- Introspection, for tests ------------------------------------
108
+
109
+ @property
110
+ def scene(self):
111
+ return self.host.scene
112
+
113
+
114
+ def run(character: str | None = None, seed: int | None = None,
115
+ skip_title: bool = False, ascii_only: bool = False) -> None:
116
+ """Play CALDERA as its own command."""
117
+ from magmacrunch.engine.core.tui_host import TuiHost
118
+ from magmacrunch.engine.ui.glyphs import Glyphs
119
+
120
+ from caldera.arcade import GAME
121
+
122
+ host = TuiHost(title=GAME.info.title, fps=GAME.info.fps,
123
+ hold_ms=GAME.info.hold_ms,
124
+ glyphs=Glyphs.detect(ascii_only=ascii_only))
125
+ app = CalderaApp(host, character, seed)
126
+ host.push_scene(app.root_scene)
127
+ if skip_title:
128
+ host.push_scene(GameScene(app))
129
+ host.run()
@@ -0,0 +1,54 @@
1
+ """What the arcade needs to know to launch this game.
2
+
3
+ The entry point a launcher resolves. Kept tiny and free of imports that cost
4
+ anything: a menu listing several games loads one of these per installed game
5
+ just to draw a card, and it should not pay for the rules or the screens.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+ from magmacrunch.engine.arcade import GameInfo
13
+
14
+ from caldera import config, theme
15
+
16
+ INFO = GameInfo(
17
+ key="caldera",
18
+ title="CALDERA",
19
+ blurb="Climb the vent. Outrun the magma. Bounce off walls to fly.",
20
+ # 30 frames drawn, two sim ticks each. The rules run at the browser's
21
+ # 60 Hz regardless -- see caldera.scenes -- so this only decides how
22
+ # smooth it looks, and 20 is visibly steppy with a camera that never
23
+ # stops moving.
24
+ fps=30,
25
+ # 0, edge semantics, because nothing here reads held state. Running
26
+ # latches and jumping is a press; caldera.controls says why a terminal
27
+ # needs it that way.
28
+ hold_ms=0,
29
+ min_cols=theme.MIN_COLS,
30
+ min_rows=theme.MIN_ROWS,
31
+ score_key=config.SCORES_GAME,
32
+ # The Basalt Vent's glow, which is the colour the game is known by.
33
+ accent=config.CHAMBERS[0]["glow"],
34
+ )
35
+
36
+
37
+ class CalderaGame:
38
+ """Satisfies :class:`magmacrunch.engine.arcade.ArcadeGame`."""
39
+
40
+ info = INFO
41
+
42
+ def start(self, host: Any) -> Any:
43
+ """The title screen, ready to be pushed. Imported here so that listing
44
+ this game in a menu does not drag in its rules or its screens."""
45
+ from caldera.app import CalderaApp
46
+
47
+ return CalderaApp(host).root_scene
48
+
49
+
50
+ #: What the entry point resolves to. Stateless: a session's state belongs to
51
+ #: the CalderaApp that :meth:`CalderaGame.start` creates.
52
+ GAME = CalderaGame()
53
+
54
+ __all__ = ["GAME", "INFO", "CalderaGame"]