diff --git a/project/reproducer.py b/project/reproducer.py index 6492469b..97e1e083 100644 --- a/project/reproducer.py +++ b/project/reproducer.py @@ -41,8 +41,26 @@ def reproduce(self, dry_run=False): table = Table() for tag in self.round_content: + if player_draw_regex.match(tag) and 'UN' not in tag: + print('Player draw') + tile = self.decoder.parse_tile(tag) + table.player.draw_tile(tile) + if dry_run: - print(tag) + if self._is_draw(tag): + print('<-', TilesConverter.to_one_line_string([self._parse_tile(tag)]), tag) + elif self._is_discard(tag): + print('->', TilesConverter.to_one_line_string([self._parse_tile(tag)]), tag) + elif self._is_init_tag(tag): + hands = { + 0: [int(x) for x in self._get_attribute_content(tag, 'hai0').split(',')], + 1: [int(x) for x in self._get_attribute_content(tag, 'hai1').split(',')], + 2: [int(x) for x in self._get_attribute_content(tag, 'hai2').split(',')], + 3: [int(x) for x in self._get_attribute_content(tag, 'hai3').split(',')], + } + print('Initial hand:', TilesConverter.to_one_line_string(hands[self.player_position])) + else: + print(tag) if not dry_run and tag == self.stop_tag: break @@ -72,10 +90,6 @@ def reproduce(self, dry_run=False): table.player.init_hand(hands[self.player_position]) - if player_draw_regex.match(tag) and 'UN' not in tag: - tile = self.decoder.parse_tile(tag) - table.player.draw_tile(tile) - if discard_regex.match(tag) and 'DORA' not in tag: tile = self.decoder.parse_tile(tag) player_sign = tag.upper()[1] @@ -198,6 +212,35 @@ def _parse_rounds(self, log_content): return rounds[1:] + def _is_discard(self, tag): + skip_tags = ['