Advertisement
Guest User

Untitled

a guest
May 27th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. def feed_line(self, line):
  2. #####
  3. # We can use this block to track menu screen changes
  4. # It may be the best (only) way to track which game type the user enters
  5. # I don't see a good way to deduce a Naxx or BR solo game
  6. # Further, would like to track normal vs heroic difficulty
  7. if "Start Spectator Game" in line:
  8. print "\n********** Starting Spectator Game in line **********\n"
  9.  
  10.  
  11. # Every game end logs this
  12. # [Bob] ---RegisterScreenEndOfGame---
  13. # [Bob] ---RegisterScreenBox---
  14. # [Bob] ---RegisterFriendChallenge---
  15.  
  16. if "[Bob] ---Register" in line:
  17. print "\n********** Found Bob!!!! **********\n", line
  18. print "But he's unflagged for now. [Bob]:\n", line
  19.  
  20. # How to deduce?
  21. if "[Bob] ---RegisterScreenTourneys---" in line:
  22. print "\nAre about to play Ranked or Casual?\n", line
  23.  
  24. if "[Bob] ---RegisterScreenForge---" in line:
  25. print "\nAre about to play Arena?\n", line
  26.  
  27. if "[Bob] ---RegisterScreenPractice---" in line:
  28. print "\nPicking a deck for Practice?\n", line
  29.  
  30. # Yes
  31. if "[Bob] ---RegisterScreenEndOfGame---" in line:
  32. print "\nDid your game just conclude? Hope you won!\n", line
  33.  
  34. if "[Bob] ---RegisterScreenBox---" in line:
  35. print "\nAre you in a menu?\n", line
  36. #####
  37.  
  38. pattern = "\[(?P<logger_name>\S+)\] (?P<log_source>\S+\(\)) - (?P<log_msg>.*)" # noqa
  39. results = re.match(pattern, line)
  40. if not results:
  41. return
  42.  
  43. self.parser.feed_line(**results.groupdict())
  44.  
  45. if self.is_gameover():
  46. card_db = card_database.CardDatabase.get_database()
  47. our_hero, enemy_hero = self._get_heroes_from_entities()
  48. self._create_history(**{
  49. 'hero': card_db.get_card_by_id(our_hero.card_id)['name'],
  50. 'opponent': card_db.get_card_by_id(enemy_hero.card_id)['name'],
  51. 'turns': self.entities.get('1').get_tag('TURN'),
  52. })
  53. self.logger.info("Detected gameover")
  54. self.start_new_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement