74 lines
3.5 KiB
Python
74 lines
3.5 KiB
Python
"""Offline cultivation-bound checks using public tables and synthetic monsters."""
|
|
from copy import deepcopy
|
|
from types import SimpleNamespace
|
|
import unittest
|
|
|
|
from ranch_assistant.battle_simulator import _snapshot_anomalies, combat_tables
|
|
|
|
|
|
class SnapshotPotentialAnomalyTests(unittest.TestCase):
|
|
def snapshot(self, *, species=5208010, **changes):
|
|
tables = combat_tables()
|
|
row = tables["monster_info"][str(species)]
|
|
mon = {"id": 100001, "typeId": species, "level": 1, "potentialLevel": 3,
|
|
"tpLevel": 0, "feel": 0, "upStar": 0,
|
|
"pAtk": 0, "pDef": 0, "pHp": 0, "pDex": 0}
|
|
mon.update(changes)
|
|
unit = SimpleNamespace(key="player-1", species=species,
|
|
stats=SimpleNamespace(atk=row["atk"], defense=row["def"],
|
|
hp=row["hp"], dex=row["dex"]))
|
|
return mon, unit, tables
|
|
|
|
def test_cultivated_potential_at_zero_tp_is_valid(self):
|
|
# PotentialPanel.as:102,245: job=1, star=5, potentialLevel=3
|
|
# permits atk=64, def=58, hp=510, dex=22, independently of tpLevel.
|
|
mon, unit, tables = self.snapshot(pAtk=38, pDef=44, pHp=300, pDex=22)
|
|
before = deepcopy((mon, unit))
|
|
self.assertEqual(_snapshot_anomalies(mon, unit, tables), [])
|
|
self.assertEqual((mon, unit), before)
|
|
|
|
def test_all_four_excesses_keep_blocking_records(self):
|
|
# Preserve the existing strict > 1.5 * cultivation-cap check.
|
|
mon, unit, tables = self.snapshot(pAtk=97, pDef=88, pHp=766, pDex=34)
|
|
before = deepcopy((mon, unit))
|
|
records = _snapshot_anomalies(mon, unit, tables)
|
|
self.assertEqual([r["code"] for r in records], ["+15overpoten"] * 4)
|
|
self.assertEqual({r["stat"]: (r["value"], r["source_maximum"]) for r in records},
|
|
{"atk": (97, 96), "def": (88, 87),
|
|
"hp": (766, 765), "dex": (34, 33)})
|
|
self.assertTrue(all(r["source_cheat_points"] == 30 for r in records))
|
|
self.assertEqual((mon, unit), before)
|
|
|
|
def test_tp_and_display_star_cannot_hide_uncultivated_excess(self):
|
|
for tp in (0, 4, 8):
|
|
with self.subTest(tp=tp):
|
|
mon, unit, tables = self.snapshot(potentialLevel=1, tpLevel=tp,
|
|
upStar=2, pAtk=19)
|
|
records = _snapshot_anomalies(mon, unit, tables)
|
|
self.assertEqual(len(records), 1)
|
|
self.assertEqual(records[0]["code"], "+15overpoten")
|
|
self.assertEqual(records[0]["source_maximum"], 18)
|
|
|
|
def test_existing_tolerance_boundary_is_preserved(self):
|
|
mon, unit, tables = self.snapshot(pAtk=96, pDef=87, pHp=765, pDex=33)
|
|
self.assertEqual(_snapshot_anomalies(mon, unit, tables), [])
|
|
mon["pDex"] = 33.25
|
|
records = _snapshot_anomalies(mon, unit, tables)
|
|
self.assertEqual(len(records), 1)
|
|
self.assertEqual(records[0]["value"], 33.25)
|
|
|
|
def test_other_source_anomalies_and_temporary_id_exemption_remain(self):
|
|
mon, unit, tables = self.snapshot(level=31, feel=201, pAtk=1000000)
|
|
unit.stats.atk = 1000000
|
|
before = deepcopy((mon, unit))
|
|
records = _snapshot_anomalies(mon, unit, tables)
|
|
self.assertEqual({r["code"] for r in records},
|
|
{"+15overfeel", "+15overgrow", "+15overpoten", "+50overlv"})
|
|
self.assertEqual((mon, unit), before)
|
|
mon["id"] = 99998
|
|
self.assertEqual(_snapshot_anomalies(mon, unit, tables), [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|