Recover sphere response and correct Jimmy ceiling cancellation
This commit is contained in:
1 parent
6a7a53c90d
commit
57dfcc64bb
37 files changed
+1324
-18
No files matched your search
@@ -0,0 +1,50 @@
|
||||
"""Byte-guarded Jimmy ceiling query and cancellation boundaries."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from ceiling_wrapper import CeilingState, ceiling_projection, collect, upward_segment
|
||||
|
||||
|
||||
class CeilingWrapperTests(unittest.TestCase):
|
||||
def test_original_byte_constants_and_virtual_contracts(self):
|
||||
report = collect(ROOT.parent / 'Original')
|
||||
self.assertEqual(len(report['sites']), 37)
|
||||
self.assertEqual(len(report['tables']), 8)
|
||||
self.assertEqual(len(report['constants']), 6)
|
||||
self.assertEqual(len(report['bodies']), 4)
|
||||
|
||||
def test_query_is_logical_root_to_plus150_not_capsule_top(self):
|
||||
self.assertEqual(upward_segment((10, 75, 20)), ((10, 75, 20), (10, 225, 20)))
|
||||
with self.assertRaises(ValueError):
|
||||
upward_segment((0, float('nan'), 0))
|
||||
|
||||
def test_only_upward_hit_changes_velocity_with_minimum_downward_speed(self):
|
||||
for vy in (0, -1, -200):
|
||||
state = CeilingState((3, vy, 4), 1, 3, 8)
|
||||
self.assertEqual(ceiling_projection(state, True), (state, ()))
|
||||
slow = CeilingState((3, 10, 4), 1, 3, 8)
|
||||
self.assertEqual(ceiling_projection(slow, False), (slow, ('query47C210',)))
|
||||
self.assertEqual(ceiling_projection(slow, True)[0].velocity, (3, -85, 4))
|
||||
fast = CeilingState((3, 200, 4), 1, 3, 8)
|
||||
self.assertEqual(ceiling_projection(fast, True)[0].velocity, (3, -120, 4))
|
||||
|
||||
def test_cancel_is_mode1_only_and_preserves_other_motion_fields(self):
|
||||
state = CeilingState((3, 10, 4), 1, 3, 8, .625, 264, 550)
|
||||
result, events = ceiling_projection(state, True)
|
||||
self.assertEqual((result.mode, result.jump, result.fire_remaining), (1, 0, 0))
|
||||
self.assertEqual((result.hold, result.extra_acceleration, result.queued_impulse), (.625, 264, 550))
|
||||
self.assertEqual(events, ('query47C210', 'velocity2C4', 'cancel1E0', 'FALL', 'cleanup140'))
|
||||
for mode in (-1, 0, 2):
|
||||
source = CeilingState((3, 10, 4), mode, 3, 8)
|
||||
result, events = ceiling_projection(source, True)
|
||||
self.assertEqual((result.mode, result.jump, result.fire_remaining), (mode, 3, 8))
|
||||
self.assertEqual(events, ('query47C210', 'velocity2C4', 'cancel1E0'))
|
||||
missing = CeilingState((3, 10, 4), 1, 3, None)
|
||||
self.assertIsNone(ceiling_projection(missing, True)[0].fire_remaining)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user