diff --git a/README.md b/README.md index 13f822f..bd6a31b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Beta. The core game is in place; changes from here are mostly balance and tuning - **Multiplayer Combat:** tag into anyone's fight from the encounter card or the guild roster. - **Weapons:** four styles, one per trade, and anyone can use any of them; the weapon decides your abilities and your role. - Sword and shield (slashing, 2.4s swings, the shield blocks 15% of hits; + Sword and shield (slashing, 2.5s swings, the shield blocks 15% of hits; swords from Smithing, shields from Construction), warhammer (blunt, Smithing; slow, heavy, twice the crits), staff (magic, Herblore; accurate) and bow (piercing, Leatherworking; fast, strikes first). The diff --git a/combat.py b/combat.py index ea5890f..c7e387d 100644 --- a/combat.py +++ b/combat.py @@ -804,7 +804,10 @@ def _swing(state: dict, unit: dict, t: float, rng: random.Random) -> None: target = state["units"].get(unit["target"] or "") if not target or not _alive(target): return - unit["next"] = t + unit["interval"] + # A player's swing keeps what the slice rounded off, or every swing time would round up to + # a quarter second and most haste would do nothing. After a cast or stun the clock restarts. + on_time = unit["side"] == "party" and t - unit["next"] < STEP + unit["next"] = (unit["next"] if on_time else t) + unit["interval"] if unit["side"] == "party": top = max(2, round(unit["base"] * _affinity(target, unit["damage"]))) if rng.random() >= hit_chance(unit["accuracy"], target["evasion"]): diff --git a/game.py b/game.py index 891f779..1b25198 100644 --- a/game.py +++ b/game.py @@ -343,15 +343,15 @@ PROSPECT = ["stone", "iron_ore", "coal", "mithril_ore", "adamantite_ore", "runit JEWEL_GROUPS = {"ring": "Rings", "amulet": "Amulets", "trinket": "Trinkets"} # key, slot, noun, stat, bonus by tier, bands, gems, shards, level above the tier, glyph JEWELLERY = [ - ("haste", "ring", "ring of haste", "haste", [5, 7, 8, 9, 10, 11], 1, 1, 1, 2, "diamond-ring"), - ("fury", "ring", "ring of fury", "crit", [2, 3, 5, 6, 8, 10], 1, 1, 1, 2, "big-diamond-ring"), + ("haste", "ring", "ring of haste", "haste", [5, 7, 9, 11, 13, 15], 1, 1, 1, 2, "diamond-ring"), + ("fury", "ring", "ring of fury", "crit", [3, 4, 5, 6, 8, 10], 1, 1, 1, 2, "big-diamond-ring"), ("might", "ring", "ring of might", "power", [2, 4, 6, 9, 12, 15], 1, 1, 1, 2, "swirl-ring"), ("vigour", "amulet", "amulet of vigour", "hp", [5, 10, 16, 23, 31, 40], 2, 1, 2, 8, "heart-necklace"), ("warding", "amulet", "amulet of warding", "ward", [3, 5, 7, 10, 12, 15], 2, 1, 2, 8, "gem-pendant"), ("mending", "amulet", "amulet of mending", "regen", [10, 20, 30, 40, 50, 60], 2, 1, 2, 8, "tribal-pendant"), ("hourglass", "trinket", "hourglass", "xp", [3, 6, 9, 12, 15, 18], 1, 2, 1, 5, "hourglass"), - ("charm", "trinket", "lucky charm", "double", [2, 3, 4, 5, 6, 8], 1, 2, 1, 5, "clover"), - ("loupe", "trinket", "loupe", "craft_double", [2, 3, 4, 4, 5, 6], 1, 2, 1, 5, "magnifying-glass"), + ("charm", "trinket", "lucky charm", "double", [2, 4, 6, 8, 10, 12], 1, 2, 1, 5, "clover"), + ("loupe", "trinket", "loupe", "craft_double", [2, 4, 6, 8, 10, 12], 1, 2, 1, 5, "magnifying-glass"), ] # How each jewellery bonus reads: name, unit, glyph, tint (and a sign, if it takes away). JEWEL_STATS = { @@ -811,10 +811,10 @@ RESISTANT = 0.75 # ...and from one it resists # How each kind of weapon fights. Two-handed weapons carry the shield's power themselves. STYLES = { - "sword": {"name": "sword", "damage": "slash", "interval": 2.4, "hit": 1.0, "accuracy": 1.0, "crit": 0.05}, - "hammer": {"name": "warhammer", "damage": "blunt", "interval": 3.6, "hit": 1.6, "accuracy": 0.95, "crit": 0.10}, + "sword": {"name": "sword", "damage": "slash", "interval": 2.5, "hit": 1.0, "accuracy": 1.0, "crit": 0.05}, + "hammer": {"name": "warhammer", "damage": "blunt", "interval": 3.75, "hit": 1.6, "accuracy": 0.95, "crit": 0.10}, "staff": {"name": "staff", "damage": "magic", "interval": 3.0, "hit": 1.2, "accuracy": 1.25, "crit": 0.05}, - "bow": {"name": "bow", "damage": "pierce", "interval": 1.8, "hit": 0.75, "accuracy": 1.05, "crit": 0.05, "first": True}, + "bow": {"name": "bow", "damage": "pierce", "interval": 2.0, "hit": 0.75, "accuracy": 1.05, "crit": 0.05, "first": True}, } CLASS_STYLE = {"miner": "hammer", "builder": "sword", "homesteader": "staff", "ranger": "bow"} CLASS_STYLE_BONUS = 1.15 # damage with your own trade's weapon @@ -7891,6 +7891,7 @@ ORDER_RECIPES, ORDER_RAW = _order_sources() # line here (new / balance / fix), and a new release a new entry on top. PATCH_NOTES = [ {"date": "2026-11-10", "title": "Siegeworks", "notes": [ + ("balance", "Rebalanced rings and fixed swing timers"), ("new", "Construction: Siegeworks. 6 traps (Lv 15–89, 1 frame) and 6 engines (Lv 19–93, 3 frames)."), ("new", "Outworks: 5 levels. Per level: 20 traps, 4 engines, +2 trap slots per win."), ("new", "Traps: raids only, +1 to +14 defence, all used up each raid."), diff --git a/tests/test_game.py b/tests/test_game.py index d636880..f5221df 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -3,6 +3,7 @@ import random import sys import unittest from pathlib import Path +from unittest import mock sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) @@ -2940,15 +2941,33 @@ class JewelcraftingTest(unittest.TestCase): hp = game.max_hp(p) p["equip"].update(ring="garnet_haste", amulet="garnet_vigour", trinket="garnet_hourglass") after = game.fighter(p, game.NO_BLESSING, {}) - self.assertAlmostEqual(after["interval"], round(before["interval"] * 0.93, 2)) + self.assertAlmostEqual(after["interval"], round(before["interval"] * (1 - 7 / 100), 2)) self.assertEqual(game.max_hp(p), hp + 10) game.gain_xp(self.world, p, "mining", 100, T0) self.assertAlmostEqual(p["xp"]["mining"], 106) p["equip"]["ring"] = "garnet_fury" - self.assertAlmostEqual(game.fighter(p, game.NO_BLESSING, {})["crit"], before["crit"] + 0.03) + self.assertAlmostEqual(game.fighter(p, game.NO_BLESSING, {})["crit"], before["crit"] + 0.04) p["equip"]["ring"] = "garnet_might" self.assertEqual(game.combat_power(p), game.combat_power({**p, "equip": {**p["equip"], "ring": None}}) + 4) + def test_every_jewellery_tier_beats_the_last(self): + for key, _slot, _noun, _stat, bonus, *_rest in game.JEWELLERY: + self.assertTrue(all(a < b for a, b in zip(bonus, bonus[1:])), key) + + def test_swings_keep_their_real_pace(self): + """Swing time isn't rounded up to the fight's slices, so every bit of haste counts.""" + swings = [] + unit = {"side": "party", "id": "me", "next": 0.0, "interval": 2.14, "cast": None, "stun": 0, "target": "foe", + "base": 10, "damage": "slash", "accuracy": 1} + state = {"units": {"me": unit, "foe": {"id": "foe", "evasion": 0}}} + with mock.patch.object(game.combat, "_alive", lambda _unit: True), \ + mock.patch.object(game.combat, "_affinity", lambda _target, _damage: 1), \ + mock.patch.object(game.combat, "hit_chance", lambda _accuracy, _evasion: 0), \ + mock.patch.object(game.combat, "_event", lambda _state, t, *_rest: swings.append(t)): + for n in range(1, 4001): + game.combat._swing(state, unit, n * game.combat.STEP, random.Random(1)) + self.assertAlmostEqual(len(swings), 1000 / 2.14, delta=1) + def test_loupe_doubles_any_class_crafts(self): self.ann["xp"]["jewelcrafting"] = game.XP_TABLE[15] for loupe, rings in ((None, 1), ("quartz_loupe", 2)):