# HG changeset patch # User ark # Date 1792445768 -7200 # Node ID c1c7e4f54bf6abbbf4cb0a48cbd0b816549dbf0d # Parent 7fda634d15ad24b84cf3974f5bb837a9bc592da5 balance work prep diff -r 7fda634d15ad -r c1c7e4f54bf6 config/game.toml --- a/config/game.toml Mon Oct 19 22:50:52 2026 +0200 +++ b/config/game.toml Mon Oct 19 23:36:08 2026 +0200 @@ -97,41 +97,43 @@ min_weight = 0.1 # guess -# towers. damage and range lists are by level 1-5. attack_time is the time +# towers have 5 levels. damage, range, slow and cost give the values at +# level 1 and level 5; the build fills in the levels between in equal steps, +# rounded to whole numbers when both ends are whole. cost is the price of +# building (level 1) or of upgrading to that level. attack_time is the time # between attacks, the same at every level (decided). projectile_speed 0 # means a melee tower: each attack damages every monster in range. -# level n costs cost x n (decided). [tower.t0] -damage = [5, 10, 15, 20, 25] # notes -cost = 5 # notes -range = [60, 63, 66, 69, 72] # level 1: decided (was 45), rest: guess +damage = [5, 25] # notes +cost = [5, 25] # notes, level n was 5 x n (decided) +range = [60, 72] # level 1: decided (was 45), 5: guess attack_time = 1.5 # guess, slower than the others (decided) projectile = "p0" projectile_speed = 0 # notes (melee) [tower.t1] -damage = [3, 7, 13, 17, 23] # notes -cost = 10 # notes -range = [100, 104, 108, 112, 116] # guess +damage = [3, 23] # notes, which had 7 and 17 for levels 2 and 4 +cost = [10, 50] # notes, level n was 10 x n (decided) +range = [100, 116] # guess attack_time = 0.7 # guess projectile = "p1" projectile_speed = 300 # guess [tower.t2] -damage = [1, 3, 5, 7, 9] # 1-4: notes, 5: guess -cost = 20 # notes -range = [90, 94, 98, 102, 106] # guess +damage = [1, 9] # 1: notes, 5: guess +cost = [20, 100] # notes, level n was 20 x n (decided) +range = [90, 106] # guess attack_time = 1.2 # guess projectile = "p2" projectile_speed = 220 # guess -slow = [0.60, 0.55, 0.50, 0.45, 0.40] # guess, share of speed left, by level +slow = [0.60, 0.40] # guess, share of speed left slow_time = 2.0 # guess [tower.t3] -damage = [1, 5, 7, 10, 13] # 1-4: notes, 5: guess -cost = 25 # decided (was 40), may go lower -range = [220, 230, 240, 250, 260] # guess +damage = [1, 13] # 1: notes, 5: guess. notes had 5 for level 2 +cost = [25, 125] # decided (was 40), level n was 25 x n +range = [220, 260] # guess attack_time = 1.3 # decided, amount guessed projectile = "p3" projectile_speed = 800 # guess diff -r 7fda634d15ad -r c1c7e4f54bf6 doc/balance.md --- a/doc/balance.md Mon Oct 19 22:50:52 2026 +0200 +++ b/doc/balance.md Mon Oct 19 23:36:08 2026 +0200 @@ -13,6 +13,10 @@ - guess: a starting value for playtesting, expected to change - derived: calculated from other values +notes and decided values are not fixed either. they come from the original +drawing sheet and the first design rounds, made without experience in game +design, and are all open to change in balancing. + units: distances are in map pixels, that is pixels of the map image as scanned. times are in seconds, speeds in map pixels per second. @@ -118,16 +122,23 @@ towers ------ -towers have 5 levels (decided). the drawing sheet gives five damage values for -t0 and t1, and four for t2 and t3. level 5 of t2 and t3 continues the trend -(guess). +towers have 5 levels (decided). the config sets damage, range, slow and cost +for level 1 and level 5 only. the build fills in the levels between in equal +steps, rounded to whole numbers where both ends are whole. + +the drawing sheet gives five damage values for t0 and t1, and four for t2 and +t3. level 5 of t2 and t3 continues the trend (guess). the equal steps change +three values from the sheet: t1 level 2 from 7 to 8, t1 level 4 from 17 to 18, +and t3 level 2 from 5 to 4 (decided). | tower | damage by level | cost | range by level | attack every | projectile speed | source | |-------|------------------|------|---------------------|--------------|------------------|--------| | t0 | 5,10,15,20,25 | 5 | 60,63,66,69,72 | 1.5 s | none (melee) | damage, cost: notes; range level 1: decided (was 45); rest: guess | -| t1 | 3,7,13,17,23 | 10 | 100,104,108,112,116 | 0.7 s | 300 | as above | -| t2 | 1,3,5,7,9 | 20 | 90,94,98,102,106 | 1.2 s | 220 | damage 1-4, cost: notes; rest: guess | -| t3 | 1,5,7,10,13 | 25 | 220,230,240,250,260 | 1.3 s | 800 | damage 1-4: notes; cost: decided (was 40), may go lower; rest: guess | +| t1 | 3,8,13,18,23 | 10 | 100,104,108,112,116 | 0.7 s | 300 | damage levels 1 and 5, cost: notes; range: guess | +| t2 | 1,3,5,7,9 | 20 | 90,94,98,102,106 | 1.2 s | 220 | damage level 1, cost: notes; rest: guess | +| t3 | 1,4,7,10,13 | 25 | 220,230,240,250,260 | 1.3 s | 800 | damage level 1: notes; cost: decided (was 40), may go lower; rest: guess | + +the cost column is the build cost, level 1. rules: @@ -142,7 +153,8 @@ projectile flies on to the last position and disappears (guess) - towers aim at the monster furthest along its route (guess) -costs (decided: level n costs base cost x n): +costs: the price of building, or of the upgrade to a level. they started as +level n costs base cost x n (decided); the config sets levels 1 and 5: | tower | level 1 (build) | level 2 | level 3 | level 4 | level 5 | total | |-------|-----------------|---------|---------|---------|---------|-------| @@ -167,9 +179,9 @@ | tower | level 1 | level 2 | level 3 | level 4 | level 5 | |-------|---------|---------|---------|---------|---------| | t0 | 3.3 | 6.7 | 10.0 | 13.3 | 16.7 | -| t1 | 4.3 | 10.0 | 18.6 | 24.3 | 32.9 | +| t1 | 4.3 | 11.4 | 18.6 | 25.7 | 32.9 | | t2 | 0.8 | 2.5 | 4.2 | 5.8 | 7.5 | -| t3 | 0.8 | 3.8 | 5.4 | 7.7 | 10.0 | +| t3 | 0.8 | 3.1 | 5.4 | 7.7 | 10.0 | t3 is meant to be weaker than the other towers; its range lets it reach more targets (decided). to keep the gap moderate, its cost went from 40 to 25 and diff -r 7fda634d15ad -r c1c7e4f54bf6 doc/game_design.md --- a/doc/game_design.md Mon Oct 19 22:50:52 2026 +0200 +++ b/doc/game_design.md Mon Oct 19 23:36:08 2026 +0200 @@ -64,7 +64,8 @@ each t*p strip are levels 2-5 the original drawing sheet gives five damage values for t0 (5,10,15,20,25) and t1 (3,7,13,17,23), and four for t2 and t3, as above. level 5 of t2 - and t3 is guessed in balance.md + and t3 is guessed in balance.md. the game fills in the levels between + level 1 and level 5 in equal steps, so some values differ from the sheet - t3 is meant to be weaker than the other towers; its range lets it reach more targets - towers are placed next to the path, never on it. a tap or click snaps to the @@ -77,9 +78,10 @@ - the preview pulses in time with the chosen shop item. some testers took the preview for a built tower - tapping a built tower shows its range and the upgrade and sell buttons -- tower upgrades cost tower base cost * tower level - the level is the new level: building is level 1 and costs the base cost, - the first upgrade (to level 2) costs twice the base cost +- each level has its own cost: building is level 1, an upgrade costs the + price of the new level. the costs started as tower base cost * tower + level, so the first upgrade (to level 2) cost twice the base cost. + balance.md has the current values - upgrades mainly raise damage. range grows slightly, and so does the slowing of t2. attack speed stays the same at all levels - selling a tower refunds half of everything paid for it: the build and all diff -r 7fda634d15ad -r c1c7e4f54bf6 doc/roadmap.md --- a/doc/roadmap.md Mon Oct 19 22:50:52 2026 +0200 +++ b/doc/roadmap.md Mon Oct 19 23:36:08 2026 +0200 @@ -40,6 +40,13 @@ - voice recordings as they arrive (sound.md) 10. publishing - publish script, www/, dist/ zip, 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 + - placing a tower: one tap puts the preview down, a second tap on it + builds + - t0 hitting several monsters with one attack + - t2 slowing a monster, with the blue hp bar debug switches (architecture.md) are added as each step needs them, starting with step 3. diff -r 7fda634d15ad -r c1c7e4f54bf6 game/data/config.js --- a/game/data/config.js Mon Oct 19 22:50:52 2026 +0200 +++ b/game/data/config.js Mon Oct 19 23:36:08 2026 +0200 @@ -88,7 +88,13 @@ 20, 25 ], - "cost": 5, + "cost": [ + 5, + 10, + 15, + 20, + 25 + ], "range": [ 60, 63, @@ -103,12 +109,18 @@ "t1": { "damage": [ 3, - 7, + 8, 13, - 17, + 18, 23 ], - "cost": 10, + "cost": [ + 10, + 20, + 30, + 40, + 50 + ], "range": [ 100, 104, @@ -128,7 +140,13 @@ 7, 9 ], - "cost": 20, + "cost": [ + 20, + 40, + 60, + 80, + 100 + ], "range": [ 90, 94, @@ -151,12 +169,18 @@ "t3": { "damage": [ 1, - 5, + 4, 7, 10, 13 ], - "cost": 25, + "cost": [ + 25, + 50, + 75, + 100, + 125 + ], "range": [ 220, 230, diff -r 7fda634d15ad -r c1c7e4f54bf6 game/js/game.js --- a/game/js/game.js Mon Oct 19 22:50:52 2026 +0200 +++ b/game/js/game.js Mon Oct 19 23:36:08 2026 +0200 @@ -199,7 +199,7 @@ // preview or the tower cannot be afforded. Game.prototype.build = function () { if (!this.shop || !this.preview) return false; - var cost = cfg.tower[this.shop].cost; + var cost = cfg.tower[this.shop].cost[0]; if (!this.canAfford(cost)) return false; this.pay(cost); var pv = this.preview; diff -r 7fda634d15ad -r c1c7e4f54bf6 game/js/input.js --- a/game/js/input.js Mon Oct 19 22:50:52 2026 +0200 +++ b/game/js/input.js Mon Oct 19 23:36:08 2026 +0200 @@ -111,7 +111,7 @@ else if (b.id === "pause") game.togglePause(); else if (b.id === "speed") game.speedIndex = (game.speedIndex + 1) % game.speeds.length; else if (b.id === "early") game.startEarly(); - else if (b.id === "shop" && !game.paused && game.canAfford(MM.config.tower[b.tower].cost)) game.chooseShop(b.tower); + else if (b.id === "shop" && !game.paused && game.canAfford(MM.config.tower[b.tower].cost[0])) game.chooseShop(b.tower); else if (b.id === "upgrade") game.upgrade(); else if (b.id === "sell") game.sell(); return null; diff -r 7fda634d15ad -r c1c7e4f54bf6 game/js/tower.js --- a/game/js/tower.js Mon Oct 19 22:50:52 2026 +0200 +++ b/game/js/tower.js Mon Oct 19 23:36:08 2026 +0200 @@ -26,10 +26,9 @@ }; } - // cost of the next level, null at the top level. level n costs the - // base cost x n. + // cost of the next level, null at the top level function upgradeCost(t) { - return t.level < t.def.damage.length ? t.def.cost * (t.level + 1) : null; + return t.level < t.def.cost.length ? t.def.cost[t.level] : null; } // coins back for selling the tower: half of everything paid for it, diff -r 7fda634d15ad -r c1c7e4f54bf6 game/js/ui.js --- a/game/js/ui.js Mon Oct 19 22:50:52 2026 +0200 +++ b/game/js/ui.js Mon Oct 19 23:36:08 2026 +0200 @@ -273,9 +273,9 @@ var bubble = game.shop !== b.tower ? "shop_bubble" : Math.floor(view.now / BUBBLE_FLIP) % 2 ? "shop_bubble_dark2" : "shop_bubble_dark"; ctx.drawImage(A.img(bubble), b.x, b.y, b.w, b.h); - ctx.globalAlpha = game.canAfford(def.cost) && !game.paused ? 1 : 0.35; + ctx.globalAlpha = game.canAfford(def.cost[0]) && !game.paused ? 1 : 0.35; fit(ctx, b.tower, cx, b.y + 28, 44, 38); - price(ctx, def.cost, cx, b.y + b.h - 15); + price(ctx, def.cost[0], cx, b.y + b.h - 15); ctx.globalAlpha = 1; } else if (b.id === "upgrade") { var cost = MM.tower.upgradeCost(game.selected); diff -r 7fda634d15ad -r c1c7e4f54bf6 tools/build.py --- a/tools/build.py Mon Oct 19 22:50:52 2026 +0200 +++ b/tools/build.py Mon Oct 19 23:36:08 2026 +0200 @@ -71,6 +71,11 @@ ROUTE_DECIMALS = 1 # per map settings used by the mask step MASK_SETTINGS = ("path_half_width", "spawn_distance", "exit_distance") +# tower levels, and the tower settings given as [level 1, last level] +TOWER_LEVELS = 5 +TOWER_BY_LEVEL = ("damage", "range", "cost", "slow") +# number of decimals of tower values filled in between non-whole ends +TOWER_DECIMALS = 3 warnings = [] @@ -336,15 +341,17 @@ for k in ("hp", "coins", "speed"): need(mon, k, float, f"monster.{mid}") for tid, tw in cfg["tower"].items(): - for k in ("damage", "range"): + for k in TOWER_BY_LEVEL: + if k == "slow" and k not in tw: + continue v = need(tw, k, list, f"tower.{tid}") - if len(v) != 5: - raise ConfigError(f"tower.{tid}: {k} needs 5 levels, has {len(v)}") - for k in ("cost", "attack_time", "projectile_speed"): + if len(v) != 2 or not all(isinstance(x, (int, float)) and not isinstance(x, bool) + for x in v): + raise ConfigError(f"tower.{tid}: {k} should be [level 1, level " + f"{TOWER_LEVELS}], is {v!r}") + for k in ("attack_time", "projectile_speed"): need(tw, k, float, f"tower.{tid}") need(tw, "projectile", str, f"tower.{tid}") - if "slow" in tw and len(tw["slow"]) != 5: - raise ConfigError(f"tower.{tid}: slow needs 5 levels") for k in ("speed_variation", "offset", "lean", "wander_step", "fade_in"): need(cfg["movement"], k, float, "movement") for k in ("footprint_radius", "max_gap", "min_tower_distance", "edge_distance", @@ -380,6 +387,21 @@ need(wave["monsters"], mon, int, ww) +def tower_levels(ends): + """ + the values for all tower levels from [level 1, last level], in equal + steps. whole numbers when both ends are whole (halves round up), + otherwise rounded to TOWER_DECIMALS. + """ + first, last = ends + whole = isinstance(first, int) and isinstance(last, int) + out = [] + for i in range(TOWER_LEVELS): + v = first + (last - first) * i / (TOWER_LEVELS - 1) + out.append(math.floor(v + 0.5) if whole else round(v, TOWER_DECIMALS)) + return out + + def sprite_table(): """name -> [width, height] of every image in game/assets/ except maps.""" out = {} @@ -396,6 +418,9 @@ print("config: up to date") return out = {k: v for k, v in cfg.items() if k != "map"} + 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()} out["maps"] = [] for m in range(MAPS): mp = dict(cfg["map"][str(m)])