Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def feed_line(self, line):
- #####
- # We can use this block to track menu screen changes
- # It may be the best (only) way to track which game type the user enters
- # I don't see a good way to deduce a Naxx or BR solo game
- # Further, would like to track normal vs heroic difficulty
- if "Start Spectator Game" in line:
- print "\n********** Starting Spectator Game in line **********\n"
- # Every game end logs this
- # [Bob] ---RegisterScreenEndOfGame---
- # [Bob] ---RegisterScreenBox---
- # [Bob] ---RegisterFriendChallenge---
- if "[Bob] ---Register" in line:
- print "\n********** Found Bob!!!! **********\n", line
- print "But he's unflagged for now. [Bob]:\n", line
- # How to deduce?
- if "[Bob] ---RegisterScreenTourneys---" in line:
- print "\nAre about to play Ranked or Casual?\n", line
- if "[Bob] ---RegisterScreenForge---" in line:
- print "\nAre about to play Arena?\n", line
- if "[Bob] ---RegisterScreenPractice---" in line:
- print "\nPicking a deck for Practice?\n", line
- # Yes
- if "[Bob] ---RegisterScreenEndOfGame---" in line:
- print "\nDid your game just conclude? Hope you won!\n", line
- if "[Bob] ---RegisterScreenBox---" in line:
- print "\nAre you in a menu?\n", line
- #####
- pattern = "\[(?P<logger_name>\S+)\] (?P<log_source>\S+\(\)) - (?P<log_msg>.*)" # noqa
- results = re.match(pattern, line)
- if not results:
- return
- self.parser.feed_line(**results.groupdict())
- if self.is_gameover():
- card_db = card_database.CardDatabase.get_database()
- our_hero, enemy_hero = self._get_heroes_from_entities()
- self._create_history(**{
- 'hero': card_db.get_card_by_id(our_hero.card_id)['name'],
- 'opponent': card_db.get_card_by_id(enemy_hero.card_id)['name'],
- 'turns': self.entities.get('1').get_tag('TURN'),
- })
- self.logger.info("Detected gameover")
- self.start_new_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement