IBBoard / bbreplay

A small Python library to parse Blood Bowl 1 replay files
GNU General Public License v3.0
1 stars 0 forks source link

Handle dropped ball during movement #4

Closed IBBoard closed 3 years ago

IBBoard commented 3 years ago

Replay_2020-08-16_10-12-51.db fails because the ball carrier trips and drops the ball. We currently check for a turnover straight away, but since 9664b53b05f019292d1b2912fd71525a038690ad we've moved the TurnOverEvent to the end of the list of log entries. In this case we have not only a bounce, but a throw-in!

[Dodge(team=TeamType.AWAY, player=1, required=3+, roll=1, result=ActionResult.FAILURE), Reroll(team=TeamType.AWAY), Dodge(team=Team
Type.AWAY, player=1, required=3+, roll=6, result=ActionResult.SUCCESS), GoingForIt(team=TeamType.AWAY, player=1, required=2+, roll=1, result=ActionResult.FAIL
URE), ArmourValueRoll(team=TeamType.AWAY, player=1, required=8+, roll=4, result=ActionResult.FAILURE), Bounce(direction=ScatterDirection.SW), ThrowInDirection
(direction=ThrowInDirection.DOWN_PITCH), ThrowInDistance(distance=7), Bounce(direction=ScatterDirection.E), TurnOver(team=TeamType.AWAY, reason=Knocked Down!)
]
        Consuming BounceLogEntry 5: Bounce(direction=ScatterDirection.SW)
Traceback (most recent call last):
  File "dump-data.py", line 68, in <module>
    for event in replay.events():
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 172, in events
    for event in self._process_turn(cmds, log_entries, board):
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 355, in _process_turn
    yield from self._process_movement(player, cmd, cmds, None, log_entries, board)
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 888, in _process_movement
    validate_log_entry(log_entry, TurnOverEntry, player.team.team_type)
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 1206, in validate_log_entry
    raise ValueError(f"Expected {expected_type.__name__} but got {type(log_entry).__name__}")
ValueError: Expected TurnOverEntry but got BounceLogEntry
IBBoard commented 3 years ago

Now presenting as:

Traceback (most recent call last):
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 1183, in _process_movement
    log_entry = next(move_log_entries)
  File "/home/ibboard/Projects/bbreplay/bbreplay/__init__.py", line 270, in __next__
    return self.next()
  File "dump-data.py", line 16, in next
    datum = super().next()
  File "/home/ibboard/Projects/bbreplay/bbreplay/__init__.py", line 276, in next
    to_return = next(self._generator)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "dump-data.py", line 74, in <module>
    for event in replay.events():
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 180, in events
    for event in self._process_turn(cmds, log_entries, board):
  File "/home/ibboard/Projects/bbreplay/bbreplay/replay.py", line 375, in _process_turn
    yield from self._process_movement(player, cmd, cmds, None, log_entries, board)
RuntimeError: generator raised StopIteration
IBBoard commented 3 years ago

Fixed by aec0889