883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
29 lines
1.4 KiB
Python
29 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Visibility replay must retain near objects and handle real mask deltas/removals."""
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
import tempfile
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from population_report import replay
|
|
|
|
def create(guid, typ, flags=0):
|
|
return dict(event='legacy', kind=3, guid=guid, type=typ, update_flags=flags,
|
|
fields={'3': 6, '131': 123}, position={'0': 0, '1': 0, '2': 0, '3': 0})
|
|
events = [create(4509, 4, 1), create(100, 3), create(101, 3), create(102, 3),
|
|
dict(event='sent', guid=100, modern_guid='00'*16),
|
|
dict(event='legacy', kind=0, guid=100, fields={'131': 456}),
|
|
dict(event='legacy', kind=5, guid=0, removed=[100]),
|
|
dict(event='legacy', kind=4, guid=0, removed=[101]),
|
|
dict(event='destroy', guid=102)]
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
path = Path(tmp)/'audit.jsonl'
|
|
path.write_text(''.join(json.dumps(e)+'\n' for e in events))
|
|
report = replay(path)
|
|
assert report['visible_counts'] == {'creature': 1, 'player': 1}
|
|
assert report['translated_counts'] == {'creature': 1}
|
|
actor = next(r for r in report['objects'] if r['category'] == 'creature')
|
|
assert actor['display'] == 456 and actor['mask_indices'] == [3, 131]
|
|
assert report['removal_counts'] == {'out_of_range': 1, 'destroy': 1}
|
|
print('Population replay: mask delta, near list, destruction and range removal passed.')
|