Rebalance rings and trinkets, fix swing timers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-10 14:58:23 +00:00
parent c35c2289e2
commit 1bac06cb28
4 changed files with 34 additions and 11 deletions

View file

@ -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)):