# Path: nhlscrapi/_tools.py
# def build_enum(*sequential, **named):
#     enums = dict(zip(sequential, range(len(sequential))), **named)
#     reverse = dict((value, key) for key, value in enums.items())
#     enums['Name'] = reverse
#     return type('Enum', (), enums)
# 
# Path: nhlscrapi/scrapr/rtss.py
# class RTSS(ReportLoader):
#     """Retrieve and load RTSS play by play game data"""
#   
#     def __init__(self, game_key):
#         super(RTSS, self).__init__(game_key, "rtss")
#         
#         self.plays = []
#         """List of plays loaded. See :py:class:`.PlayParser` for play data structure."""
#         
#         
#     def parse(self):
#         """
#         Parse full document. Plays and matchups.
#         
#         :returns: ``self`` on success, ``None`` otherwise
#         """
# 
#         try:
#             return super(RTSS, self).parse().parse_plays()
#         except:
#             return None
#         
#         
#     def parse_plays(self):
#         """
#         Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.GameKey`
#         
#         :returns: ``self`` on success, ``None`` otherwise
#         """
#         
#         try:
#             self.plays = [p for p in self.parse_plays_stream()]
#             return self
#         except:
#             return None
#         
#         
#     def parse_plays_stream(self):
#         """Generate and yield a stream of parsed plays. Useful for per play processing."""
#         
#         lx_doc = self.html_doc()
#         if lx_doc is not None:
#             parser = PlayParser(self.game_key.season, self.game_key.game_type)
#             plays = lx_doc.xpath('//tr[@class = "evenColor"]')
#             for p in plays:
#                 p_obj = parser.build_play(p)
#                 self.plays.append(p_obj)
#                 
#                 yield p_obj


from nhlscrapi._tools import build_enum
from nhlscrapi.scrapr.rtss import RTSS
from nhlscrapi.games.repscrwrap import RepScrWrap
        """
        An object that inherits from :py:class:`.Event` that contains other specifics related to
        the given type of play
        """

class PlayByPlay(RepScrWrap):
    """
    Aggregator of :py:class:`.Play` objects that maintains the play-by-play data for a given game. Allows for
    custom stats of type :py:class:`.AccumulateStats` to be computed for the game.
    
    :Example:
    
    .. code:: python
    
        from nhlscrapi.games.game import GameKey
        from nhlscrapi.games.cumstats import ShotCt
        from nhlscrapi.games.playbyplay import PlayByPlay
        
        # define the game of interest and a stat accumulator
        pbp = PlayByPlay(
            game_key=GameKey(2015, 3, 224),
            cum_stats={ 'ShotCount': ShotCt() }
        )
        
        # compute and print results
        shot_cts = pbp.compute_stats()['ShotCount']
        print('Final Score:\t{}'.format(shot_cts.total))
    """
    
    def __init__(self, game_key, cum_stats = {}, init_cs_teams=True):

# Path: nhlscrapi/_tools.py
# def build_enum(*sequential, **named):
#     enums = dict(zip(sequential, range(len(sequential))), **named)
#     reverse = dict((value, key) for key, value in enums.items())
#     enums['Name'] = reverse
#     return type('Enum', (), enums)
# 
# Path: nhlscrapi/scrapr/rtss.py
# class RTSS(ReportLoader):
#     """Retrieve and load RTSS play by play game data"""
#   
#     def __init__(self, game_key):
#         super(RTSS, self).__init__(game_key, "rtss")
#         
#         self.plays = []
#         """List of plays loaded. See :py:class:`.PlayParser` for play data structure."""
#         
#         
#     def parse(self):
#         """
#         Parse full document. Plays and matchups.
#         
#         :returns: ``self`` on success, ``None`` otherwise
#         """
# 
#         try:
#             return super(RTSS, self).parse().parse_plays()
#         except:
#             return None
#         
#         
#     def parse_plays(self):
#         """
#         Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.GameKey`
#         
#         :returns: ``self`` on success, ``None`` otherwise
#         """
#         
#         try:
#             self.plays = [p for p in self.parse_plays_stream()]
#             return self
#         except:
#             return None
#         
#         
#     def parse_plays_stream(self):
#         """Generate and yield a stream of parsed plays. Useful for per play processing."""
#         
#         lx_doc = self.html_doc()
#         if lx_doc is not None:
#             parser = PlayParser(self.game_key.season, self.game_key.game_type)
#             plays = lx_doc.xpath('//tr[@class = "evenColor"]')
#             for p in plays:
#                 p_obj = parser.build_play(p)
#                 self.plays.append(p_obj)
#                 
#                 yield p_obj


# Path: nhlscrapi/games/playbyplay.py
from nhlscrapi._tools import build_enum
from nhlscrapi.scrapr.rtss import RTSS
from nhlscrapi.games.repscrwrap import RepScrWrap

        """
        An object that inherits from :py:class:`.Event` that contains other specifics related to
        the given type of play
        """

class PlayByPlay(RepScrWrap):
    """
    Aggregator of :py:class:`.Play` objects that maintains the play-by-play data for a given game. Allows for
    custom stats of type :py:class:`.AccumulateStats` to be computed for the game.
    
    :Example:
    
    .. code:: python
    
        from nhlscrapi.games.game import GameKey
        from nhlscrapi.games.cumstats import ShotCt
        from nhlscrapi.games.playbyplay import PlayByPlay
        
        # define the game of interest and a stat accumulator
        pbp = PlayByPlay(
            game_key=GameKey(2015, 3, 224),
            cum_stats={ 'ShotCount': ShotCt() }
        )
        
        # compute and print results
        shot_cts = pbp.compute_stats()['ShotCount']
        print('Final Score:\t{}'.format(shot_cts.total))
    """
    
    def __init__(self, game_key, cum_stats = {}, init_cs_teams=True):

        super(PlayByPlay, self).__init__(game_key, RTSS(game_key))