# HG changeset patch # User ark # Date 1792509580 -7200 # Node ID 75deda08db9044b56e3f961aef33a3cbe7ee2b41 # Parent 28e1fc486be541e014540a8e78945e783e83a4a9 game debug functions separated into own file; release build option, distribution script diff -r 28e1fc486be5 -r 75deda08db90 config/game.toml --- a/config/game.toml Tue Oct 20 16:06:50 2026 +0200 +++ b/config/game.toml Tue Oct 20 17:19:40 2026 +0200 @@ -300,7 +300,6 @@ show_grid = false show_ranges = false show_hit_areas = false -extra_speeds = [] # added to the game speeds, for example [8] show_stats = false # frame time and entity counts seed = 0 # random seed, 0 picks a new one each run diff -r 28e1fc486be5 -r 75deda08db90 doc/architecture.md --- a/doc/architecture.md Tue Oct 20 16:06:50 2026 +0200 +++ b/doc/architecture.md Tue Oct 20 17:19:40 2026 +0200 @@ -31,7 +31,7 @@ index.html copied from game/, as are style.css and js/ assets/ processed images data/ maps.js, sounds.js, config.js - dist/ zip archives for distribution (ignored) + dist/ tarballs for distribution (ignored) temp/ scratch files, build previews (ignored) generated files carry a header line saying so and naming the script that made @@ -44,8 +44,8 @@ - desktop: open www/index.html directly from disk, or serve the directory with any static web server - tablet: tablets cannot easily open local html files, so the game is served - over http, from a computer on the home network or from a web host. the zip - in dist/ is meant for that + over http, from a computer on the home network or from a web host. the + tarball in dist/ is meant for that - an optional later step makes it installable to the home screen (web app manifest, offline cache). that requires https @@ -129,14 +129,25 @@ with its pivot and footprint 9. game files: copy the files in game/ to www/. a file is copied when its time or size differs from the copy. files no longer in game/ are removed - from www/, apart from www/assets/ and www/data/ + from www/, apart from www/assets/ and www/data/. a release build writes + www/js/debug.js empty a watch mode (`tools/build.py --watch`) reruns the build when a file in config/, art/, art/sounds/ or game/ changes. tuning then means: edit the toml, save, reload the browser. the same goes for changes to the game code: they show in www/ only after the build has copied them. -`tools/publish.py` writes a zip of www/ into dist/, with debug switches off. +`tools/build.py --release` leaves the debug code out: it writes +www/js/debug.js empty and leaves [debug] out of config.js. the game then +runs as with every debug switch off. + +`tools/make_dist.sh` runs a release build and packs www/ into +dist/minor_monsters_VERSION.tar.gz, which unpacks into a directory +minor_monsters. the version comes from `tools/get_version.sh -f`: the +latest tag, with a timestamp appended when the working directory is not +clean or not at the tagged revision. `--debug` builds with the debug code +in place of a release build. www/ keeps the build the script made, so a +plain build afterwards brings the debug code back. balance tools @@ -176,9 +187,10 @@ it loads www/data/config.js, www/data/maps.js and the logic files util.js, assets.js, map.js, monster.js, tower.js, projectile.js, wave.js and game.js, as the browser would, with window set to the global object. -render.js, ui.js, input.js and main.js are left out. MM.audio is the only -stub; assets.js loads unchanged, since sprite sizes come from the config -and images are only loaded by main.js. the debug switches are forced off. +render.js, ui.js, input.js, debug.js and main.js are left out, so the +debug switches have no effect. MM.audio is the only stub; assets.js loads +unchanged, since sprite sizes come from the config and images are only +loaded by main.js. the game advances in steps of 1/60 s, as in the browser; game speed plays no part. each run has its own seed, passed to the game. the players build, @@ -257,8 +269,13 @@ button starts it, and a lost map returns to it - no heart loss - show routes, placement grid, tower ranges, hit areas -- higher game speeds - on-screen frame time and entity counts +- a fixed random seed + +js/debug.js holds the code for all of them. it replaces functions of the +game and the top bar drawing, and render.js calls it to draw over the map +image and over the monsters. main.js takes the start map, wave and seed +from it. without it, as in a release build, nothing of this is left. there is no in-game config editor: values are changed in the toml file. @@ -284,6 +301,7 @@ js/render.js drawing js/ui.js top bar, shop, tower menu, screens js/input.js pointer events + js/debug.js debug switches, empty in a release build js/main.js start-up and main loop game loop: diff -r 28e1fc486be5 -r 75deda08db90 doc/roadmap.md --- a/doc/roadmap.md Tue Oct 20 16:06:50 2026 +0200 +++ b/doc/roadmap.md Tue Oct 20 17:19:40 2026 +0200 @@ -40,7 +40,7 @@ - icons, screens and digits as the drawings arrive (art.md) - voice recordings as they arrive (sound.md) 10. publishing - - publish script, dist/ zip of www/, hosting for tablet play + - tools/make_dist.sh, dist/ tarball of www/, hosting for tablet play 11. help page - a hint page made from game graphics, no text where a picture will do - the tower ranges side by side @@ -238,7 +238,7 @@ counters, right-aligned as before. the buttons run help, pause, speed, sound and early start from the right. pause shows pause_button while the game runs and play_button while it is paused. speed shows the - drawing of the current speed; debug speeds show their number. the early + drawing of the current speed. the early start button shows the countdown on next_wave, without the bonus. the top bar needs about 670 css pixels of width; narrower screens are not handled - numbers: the digit variant of each place depends on the digit and its @@ -251,7 +251,7 @@ to full size over the first half of their time and fade out over the second half. they are dropped when the map ends - debug switches: all from architecture.md. start_coins -1 means the map's own value, seed 0 a new seed per - run + run. the debug tower ranges are drawn under the towers - sound: the play button on the splash screen starts the sound; taps before it leave sound off. later pointer and touch events resume audio if the browser has suspended it. switching sound off mutes the output at diff -r 28e1fc486be5 -r 75deda08db90 game/index.html --- a/game/index.html Tue Oct 20 16:06:50 2026 +0200 +++ b/game/index.html Tue Oct 20 17:19:40 2026 +0200 @@ -25,6 +25,7 @@ + diff -r 28e1fc486be5 -r 75deda08db90 game/js/debug.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/game/js/debug.js Tue Oct 20 17:19:40 2026 +0200 @@ -0,0 +1,123 @@ +// debug switches from [debug] in config/game.toml (architecture.md). this +// file replaces functions of MM.Game and MM.ui, and draws over the map +// for render.js. a release build writes it empty, and the game runs as if +// every switch were off. + +window.MM = window.MM || {}; + +MM.debug = (function () { + "use strict"; + + var cfg = MM.config; + var dbg = cfg.debug; + var INK = "#3a3530"; + var PAPER = "#f6f1e6"; + + // rules: start coins, unlimited coins, no heart loss + var Game = MM.Game; + MM.Game = function (mapIndex, seed, firstWave) { + Game.call(this, mapIndex, seed, firstWave); + if (dbg.start_coins >= 0) this.coins = dbg.start_coins; + }; + MM.Game.prototype = Game.prototype; + + if (dbg.unlimited_coins) { + Game.prototype.canAfford = function () { return true; }; + Game.prototype.pay = function () {}; + } + + if (dbg.no_heart_loss) { + var escape = Game.prototype.escape; + Game.prototype.escape = function (m) { + var hearts = this.hearts; + escape.call(this, m); + this.hearts = hearts; + }; + } + + // placement grid, drawn once per map into a canvas of its own + var gridCache = { map: null, canvas: null }; + + function gridCanvas(map) { + if (gridCache.map === map.index) return gridCache.canvas; + var d = map.data; + var c = document.createElement("canvas"); + c.width = d.width; + c.height = d.height; + var g = c.getContext("2d"); + g.fillStyle = "rgba(40, 160, 40, 0.55)"; + for (var i = 0; i < d.grid.length; i++) { + if (d.grid.charCodeAt(i) !== 49) continue; + g.fillRect((i % d.cols) * d.cell, Math.floor(i / d.cols) * d.cell, d.cell - 1, d.cell - 1); + } + gridCache.map = map.index; + gridCache.canvas = c; + return c; + } + + function drawRoutes(ctx, map) { + var colours = ["#d0009f", "#005aff", "#ff7800", "#00a03c", "#8c00ff", "#00b4c8", "#c82828", "#5a5a5a"]; + map.routes.forEach(function (r, k) { + ctx.beginPath(); + for (var i = 0; i < r.xs.length; i++) ctx.lineTo(r.xs[i], r.ys[i]); + ctx.strokeStyle = colours[k % colours.length]; + ctx.lineWidth = 2; + ctx.stroke(); + }); + } + + // grid, routes and tower ranges, over the map image and under the + // towers. s is the map scale + function drawGround(ctx, game, s) { + var map = game.map; + if (dbg.show_grid) ctx.drawImage(gridCanvas(map), 0, 0); + if (dbg.show_routes) drawRoutes(ctx, map); + if (dbg.show_ranges) { + game.towers.forEach(function (t) { MM.render.drawRange(ctx, t.x, t.y, MM.tower.range(t), s); }); + } + } + + // hit areas, over the monsters + function drawTop(ctx, game, s) { + if (!dbg.show_hit_areas) return; + game.monsters.forEach(function (m) { + MM.render.circle(ctx, m.x, m.y, m.hitRadius, null, "rgba(255, 0, 0, 0.8)", 1 / s); + }); + game.freezes.forEach(function (f) { + MM.render.circle(ctx, f.x, f.y, f.r, null, "rgba(0, 90, 255, 0.8)", 1 / s); + }); + } + + // stats: frame time in ms, smoothed, and entity counts, drawn after the + // top bar, shop and screens + var frameMs = 0; + + function frameTime(ms) { + frameMs = frameMs * 0.9 + ms * 0.1; + } + + if (dbg.show_stats) { + var uiDraw = MM.ui.draw; + MM.ui.draw = function (ctx, game, L, view) { + uiDraw(ctx, game, L, view); + var s = frameMs.toFixed(1) + " ms " + game.monsters.length + " m " + + game.towers.length + " t " + game.projectiles.length + " p seed " + game.seed; + ctx.setTransform(view.dpr, 0, 0, view.dpr, 0, 0); + ctx.font = "bold 14px system-ui, -apple-system, Segoe UI, sans-serif"; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.lineWidth = 4; + ctx.strokeStyle = PAPER; + ctx.strokeText(s, 8, L.h - 14); + ctx.fillStyle = INK; + ctx.fillText(s, 8, L.h - 14); + }; + } + + return { + start: { map: dbg.start_map, wave: dbg.start_wave, seed: dbg.seed }, + drawGround: drawGround, + drawTop: drawTop, + frameTime: frameTime + }; +})(); diff -r 28e1fc486be5 -r 75deda08db90 game/js/game.js --- a/game/js/game.js Tue Oct 20 16:06:50 2026 +0200 +++ b/game/js/game.js Tue Oct 20 17:19:40 2026 +0200 @@ -7,7 +7,6 @@ "use strict"; var cfg = MM.config; - var dbg = cfg.debug; // firstWave counts from 1 function Game(mapIndex, seed, firstWave) { @@ -15,7 +14,7 @@ this.map = new MM.GameMap(mapIndex); this.seed = seed; this.random = MM.util.rng(seed); - this.coins = dbg.start_coins >= 0 ? dbg.start_coins : mc.starting_coins; + this.coins = mc.starting_coins; this.hearts = cfg.hearts.per_map; this.monsters = []; this.towers = []; @@ -27,7 +26,7 @@ this.random); this.time = 0; this.paused = false; - this.speeds = cfg.controls.speeds.concat(dbg.extra_speeds); + this.speeds = cfg.controls.speeds; this.speedIndex = 0; this.result = null; // "won" or "lost" this.splash = false; // splash screen shown over the paused map @@ -74,11 +73,11 @@ }; Game.prototype.canAfford = function (cost) { - return dbg.unlimited_coins || this.coins >= cost; + return this.coins >= cost; }; Game.prototype.pay = function (cost) { - if (!dbg.unlimited_coins) this.coins -= cost; + this.coins -= cost; }; // one simulation step of dt seconds @@ -127,9 +126,7 @@ Game.prototype.escape = function (m) { m.alive = false; MM.audio.play(m.boss ? "boss_exit" : "monster_exit"); - if (!dbg.no_heart_loss) { - this.hearts = Math.max(0, this.hearts - (m.boss ? cfg.hearts.boss : cfg.hearts.monster)); - } + this.hearts = Math.max(0, this.hearts - (m.boss ? cfg.hearts.boss : cfg.hearts.monster)); }; // a freeze splash of radius r at x, y: slows every monster whose hit diff -r 28e1fc486be5 -r 75deda08db90 game/js/main.js --- a/game/js/main.js Tue Oct 20 16:06:50 2026 +0200 +++ b/game/js/main.js Tue Oct 20 17:19:40 2026 +0200 @@ -5,7 +5,6 @@ (function () { "use strict"; - var cfg = MM.config; var STEP = 1 / 60; // most simulation steps per frame and game speed step; the rest of a // long frame is dropped, so the game slows down instead of freezing @@ -15,15 +14,17 @@ var ctx = canvas.getContext("2d"); var game = null; var L = null; - var view = { dpr: 1, now: 0, refused: null, hover: null, stats: { ms: 0 } }; + var view = { dpr: 1, now: 0, refused: null, hover: null }; - // the first map is the debug start map; only it starts at the debug + // the first map, the wave it starts at and the seed, 0 for a new seed + // per map. js/debug.js may set them; only the first map starts at the // start wave - var FIRST = MM.util.clamp(cfg.debug.start_map, 0, MM.maps.length - 1); + var start = MM.debug ? MM.debug.start : { map: 0, wave: 1, seed: 0 }; + var FIRST = MM.util.clamp(start.map, 0, MM.maps.length - 1); function startMap(m) { - var seed = cfg.debug.seed || (Math.random() * 4294967296) >>> 0; - game = new MM.Game(m, seed, m === FIRST ? cfg.debug.start_wave : 1); + var seed = start.seed || (Math.random() * 4294967296) >>> 0; + game = new MM.Game(m, seed, m === FIRST ? start.wave : 1); resize(); } @@ -77,7 +78,7 @@ MM.ui.draw(ctx, game, L, view); MM.render.drawFlights(ctx, game, L, view); - view.stats.ms = view.stats.ms * 0.9 + (performance.now() - t0) * 0.1; + if (MM.debug) MM.debug.frameTime(performance.now() - t0); requestAnimationFrame(frame); } diff -r 28e1fc486be5 -r 75deda08db90 game/js/render.js --- a/game/js/render.js Tue Oct 20 16:06:50 2026 +0200 +++ b/game/js/render.js Tue Oct 20 17:19:40 2026 +0200 @@ -7,27 +7,7 @@ "use strict"; var cfg = MM.config; - var dbg = cfg.debug; var A = MM.assets; - // debug placement grid, drawn once per map into a canvas of its own - var gridCache = { map: null, canvas: null }; - - function gridCanvas(map) { - if (gridCache.map === map.index) return gridCache.canvas; - var d = map.data; - var c = document.createElement("canvas"); - c.width = d.width; - c.height = d.height; - var g = c.getContext("2d"); - g.fillStyle = "rgba(40, 160, 40, 0.55)"; - for (var i = 0; i < d.grid.length; i++) { - if (d.grid.charCodeAt(i) !== 49) continue; - g.fillRect((i % d.cols) * d.cell, Math.floor(i / d.cols) * d.cell, d.cell - 1, d.cell - 1); - } - gridCache.map = map.index; - gridCache.canvas = c; - return c; - } function circle(ctx, x, y, r, fill, stroke, width) { ctx.beginPath(); @@ -43,17 +23,6 @@ } } - function drawRoutes(ctx, map) { - var colours = ["#d0009f", "#005aff", "#ff7800", "#00a03c", "#8c00ff", "#00b4c8", "#c82828", "#5a5a5a"]; - map.routes.forEach(function (r, k) { - ctx.beginPath(); - for (var i = 0; i < r.xs.length; i++) ctx.lineTo(r.xs[i], r.ys[i]); - ctx.strokeStyle = colours[k % colours.length]; - ctx.lineWidth = 2; - ctx.stroke(); - }); - } - // t0 spikes: one p0 per side that faces the path. during an attack each // spike stretches from its base under the tower until its tip reaches // the range, and back @@ -133,20 +102,17 @@ } // draw the map area. L is the layout from ui.js, view holds the canvas - // pixel ratio, wall clock and tap feedback. + // pixel ratio, wall clock and tap feedback. js/debug.js, when it is not + // empty, draws over the map image and over the monsters. function draw(ctx, game, L, view) { var map = game.map, s = L.scale, dpr = view.dpr; ctx.setTransform(dpr * s, 0, 0, dpr * s, dpr * L.ox, dpr * L.oy); ctx.drawImage(A.img(map.name), 0, 0, map.width, map.height); - if (dbg.show_grid) ctx.drawImage(gridCanvas(map), 0, 0); - if (dbg.show_routes) drawRoutes(ctx, map); + if (MM.debug) MM.debug.drawGround(ctx, game, s); game.towers.slice().sort(function (a, b) { return a.y - b.y; }) .forEach(function (t) { drawTower(ctx, t, 1); }); - if (dbg.show_ranges) { - game.towers.forEach(function (t) { drawRange(ctx, t.x, t.y, MM.tower.range(t), s); }); - } if (game.selected) { var t = game.selected; drawRange(ctx, t.x, t.y, MM.tower.range(t), s); @@ -166,14 +132,7 @@ game.monsters.slice().sort(function (a, b) { return a.y - b.y; }) .forEach(function (m) { drawMonster(ctx, m, game.time); }); game.puffs.forEach(function (p) { drawPuff(ctx, p); }); - if (dbg.show_hit_areas) { - game.monsters.forEach(function (m) { - circle(ctx, m.x, m.y, m.hitRadius, null, "rgba(255, 0, 0, 0.8)", 1 / s); - }); - game.freezes.forEach(function (f) { - circle(ctx, f.x, f.y, f.r, null, "rgba(0, 90, 255, 0.8)", 1 / s); - }); - } + if (MM.debug) MM.debug.drawTop(ctx, game, s); game.projectiles.forEach(function (p) { A.draw(ctx, p.kind, p.x, p.y, cfg.scale.sprite, p.angle); @@ -212,5 +171,5 @@ }); } - return { draw: draw, drawFlights: drawFlights }; + return { draw: draw, drawFlights: drawFlights, circle: circle, drawRange: drawRange }; })(); diff -r 28e1fc486be5 -r 75deda08db90 game/js/ui.js --- a/game/js/ui.js Tue Oct 20 16:06:50 2026 +0200 +++ b/game/js/ui.js Tue Oct 20 17:19:40 2026 +0200 @@ -21,9 +21,6 @@ var BUBBLE_FLIP = 400; // ms between the two drawings of the chosen shop item var PULSE = 1.2; // seconds of one pulse of a screen button var WARN_PULSE = 0.5; // seconds of one pulse of an armed sell button - var INK = "#3a3530"; - var PAPER = "#f6f1e6"; - var FONT = "bold 22px system-ui, -apple-system, Segoe UI, sans-serif"; var TOWERS = ["t0", "t1", "t2", "t3"]; // widest usual values of the coin, heart and wave counters var USUAL = ["000", "00", "00/00"]; @@ -209,18 +206,6 @@ return null; } - // system font text, for the debug stats only - function text(ctx, s, x, y, align, size) { - ctx.font = size ? FONT.replace("22px", size + "px") : FONT; - ctx.textAlign = align || "left"; - ctx.textBaseline = "middle"; - ctx.lineWidth = 4; - ctx.strokeStyle = PAPER; - ctx.strokeText(s, x, y); - ctx.fillStyle = INK; - ctx.fillText(s, x, y); - } - // a sprite fitted into a box of w x h centred on x, y, keeping its shape function fit(ctx, name, x, y, w, h) { var s = cfg.sprites[name], k = Math.min(w / s[0], h / s[1]); @@ -269,17 +254,6 @@ number(ctx, s, left + coin + gap, y, PRICE, "left"); } - function box(ctx, b, fill, line) { - ctx.fillStyle = fill; - ctx.strokeStyle = line || INK; - ctx.lineWidth = 2; - ctx.beginPath(); - if (ctx.roundRect) ctx.roundRect(b.x, b.y, b.w, b.h, 10); - else ctx.rect(b.x, b.y, b.w, b.h); - ctx.fill(); - ctx.stroke(); - } - // a screen's button image over the same button in the drawing. it pulses // slowly as a cue to tap; under the mouse it is drawn larger, lifted by // a shadow. @@ -308,14 +282,7 @@ // shows what a tap does: pause while running, play while paused fit(ctx, game.paused ? "play_button" : "pause_button", cx, cy, b.w, b.h); } else if (b.id === "speed") { - // debug speeds have no drawing and show their number - var sp = game.speed(), name = "speed_x" + sp; - if (cfg.sprites[name]) { - fit(ctx, name, cx, cy, b.w, b.h); - } else { - box(ctx, b, PAPER); - number(ctx, sp, cx, cy, DIGIT, "center"); - } + fit(ctx, "speed_x" + game.speed(), cx, cy, b.w, b.h); } else if (b.id === "sound") { fit(ctx, MM.audio.enabled() ? "sound_on" : "sound_off", cx, cy, b.w, b.h); } else if (b.id === "early") { @@ -397,13 +364,6 @@ ctx.drawImage(A.img("tower_popup"), bub.x, bub.y, bub.w, bub.h); } list.forEach(function (b) { drawButton(ctx, game, b, view); }); - - if (cfg.debug.show_stats && view.stats) { - var st = view.stats; - text(ctx, st.ms.toFixed(1) + " ms " + game.monsters.length + " m " + - game.towers.length + " t " + game.projectiles.length + " p seed " + game.seed, - 8, L.h - 14, "left", 14); - } } return { layout: layout, hit: hit, draw: draw, BUBBLE_FLIP: BUBBLE_FLIP }; diff -r 28e1fc486be5 -r 75deda08db90 tools/build.py --- a/tools/build.py Tue Oct 20 16:06:50 2026 +0200 +++ b/tools/build.py Tue Oct 20 17:19:40 2026 +0200 @@ -3,12 +3,14 @@ build the runnable game into www/: the game data from art/ and config/ into www/assets/ and www/data/, and a copy of the hand-written files in game/. -usage: python3 tools/build.py [--force] [--watch] +usage: python3 tools/build.py [--force] [--watch] [--release] steps: sprites, tower levels, maps, masks, sounds, config, checks, previews, game files. a step is skipped when all its outputs are newer than its inputs and the build scripts; --force runs every step. --watch reruns the build whenever a file in art/, art/sounds/, art/digits/, config/ or game/ changes. +--release leaves the debug code and switches out: www/js/debug.js is +written empty and config.js has no [debug] section. requires python 3.11 or later and pillow. """ @@ -397,13 +399,15 @@ return out -def step_config(cfg, force, assets_changed): +def step_config(cfg, force, assets_changed, release): src = CONFIG / "game.toml" dst = DATA / "config.js" - if not stale([src], [dst], force) and not assets_changed: + # a switch between release and debug builds rewrites the file + was_release = dst.exists() and '"debug":' not in dst.read_text() + if not stale([src], [dst], force) and not assets_changed and was_release == release: print("config: up to date") return - out = {k: v for k, v in cfg.items() if k != "map"} + out = {k: v for k, v in cfg.items() if k != "map" and not (release and k == "debug")} out["tower"] = {tid: {k: tower_levels(v) if k in TOWER_BY_LEVEL else v for k, v in tw.items()} for tid, tw in cfg["tower"].items()} @@ -504,22 +508,31 @@ # 9. game files +# debug switches and drawing, left out of a release build +DEBUG_JS = Path("js") / "debug.js" + def game_files(): """the hand-written files in game/, as paths relative to it.""" return sorted(p.relative_to(GAME) for p in GAME.rglob("*") if p.is_file() and p.name != ".DS_Store") -def step_game(force): +def step_game(force, release): """ copy the files in game/ to www/ when they differ in time or size, and remove files from www/ that are no longer in game/. www/assets/ and - www/data/ are left alone, as the other steps write them. + www/data/ are left alone, as the other steps write them. a release + build writes js/debug.js empty. """ files = game_files() copied = 0 for rel in files: src, dst = GAME / rel, WWW / rel + if release and rel == DEBUG_JS: + if force or not dst.exists() or dst.stat().st_size: + write_text(dst, "") + copied += 1 + continue a = src.stat() if not force and dst.exists(): b = dst.stat() @@ -545,7 +558,7 @@ print("game files: up to date") -def build(force): +def build(force, release): warnings.clear() try: cfg = tomllib.loads((CONFIG / "game.toml").read_text()) @@ -558,15 +571,15 @@ step_maps(force) maps, masks_changed = step_masks(cfg, force) step_sounds(cfg, force) - step_config(cfg, force, changed) + step_config(cfg, force, changed, release) step_checks(cfg, maps) step_previews(cfg, maps, force, changed or masks_changed) - step_game(force) + step_game(force, release) print(f"\n{len(warnings)} warning(s)") return True -def watch(): +def watch(release): def snapshot(): files = (list(ART.iterdir()) + list(SOUNDS.glob("*.mp3")) + list(DIGITS.glob("*.png")) + list(CONFIG.iterdir()) + [GAME / p for p in game_files()] + TOOLS) @@ -579,7 +592,7 @@ seen = now print(time.strftime("\n== build %H:%M:%S")) try: - build(False) + build(False, release) except Exception as e: # keep watching after a failed build print("build failed:", e) time.sleep(1) @@ -587,15 +600,16 @@ def main(): args = sys.argv[1:] + release = "--release" in args if "--watch" in args: # show each line at once, also when the output goes to a file sys.stdout.reconfigure(line_buffering=True) try: - watch() + watch(release) except KeyboardInterrupt: pass return 0 - return 0 if build("--force" in args) else 1 + return 0 if build("--force" in args, release) else 1 if __name__ == "__main__": diff -r 28e1fc486be5 -r 75deda08db90 tools/make_dist.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/make_dist.sh Tue Oct 20 17:19:40 2026 +0200 @@ -0,0 +1,43 @@ +#!/bin/sh +USAGE="$0 [--debug] + +build the game and pack www/ into dist/minor_monsters_.tar.gz, +which unpacks into a directory minor_monsters. the version comes from +tools/get_version.sh -f: the latest tag, with a timestamp appended when +the working directory is not clean or not at the tagged revision. + +options: + -h, --help show this help + --debug build with the debug code and switches, not as a release +" + +DEBUG=0 + +while [ "$#" != 0 ] +do + case "$1" in + -h|--help) echo "$USAGE"; exit 0 ;; + --debug) DEBUG=1 ;; + *) + echo "unrecognized option '$1'" >&2 + exit 1 + ;; + esac + shift +done + +# build.py and get_version.sh work on the repository root +cd "$(dirname "$0")/.." && +if [ "$DEBUG" = 1 ] +then + python3 tools/build.py +else + python3 tools/build.py --release +fi && +VERSION=$(tools/get_version.sh -f) && +ARCHIVE="dist/minor_monsters_$VERSION.tar.gz" && +mkdir -p dist && +# www/ is stored as minor_monsters/ +tar --no-xattrs --no-mac-metadata --exclude .DS_Store -s ',^www,minor_monsters,' \ + -czf "$ARCHIVE" www && +echo "wrote $ARCHIVE" diff -r 28e1fc486be5 -r 75deda08db90 tools/simulate.js --- a/tools/simulate.js Tue Oct 20 16:06:50 2026 +0200 +++ b/tools/simulate.js Tue Oct 20 17:19:40 2026 +0200 @@ -94,14 +94,8 @@ vm.runInThisContext(fs.readFileSync(f, "utf8"), { filename: f }); if (i === files.length - 1) countMelee(); if (i === 1) { - var cfg = MM.config; - // debug switches off, whatever the config says - cfg.debug.start_coins = -1; - cfg.debug.unlimited_coins = false; - cfg.debug.no_heart_loss = false; - cfg.debug.extra_speeds = []; if (waves) { - Object.keys(waves).forEach(function (m) { cfg.maps[m].waves = waves[m]; }); + Object.keys(waves).forEach(function (m) { MM.config.maps[m].waves = waves[m]; }); } MM.audio = { play: function () {} }; }