def test_ocr_ps1(): mongo = MongoManager() table_dict = mongo.get_table("Official Poker Stars") table_scraper = TableScraper(table_dict) table_scraper.screenshot = Image.open( os.path.join(get_dir('tests', 'screenshots'), 'ps473830744_Flop_1.png')) table_scraper.crop_from_top_left_corner() result = ocr(table_scraper.screenshot, 'total_pot_area', table_scraper.table_dict) assert result == 0.29 result = ocr(table_scraper.screenshot, 'call_value', table_scraper.table_dict) assert result == 0.04 result = ocr(table_scraper.screenshot, 'raise_value', table_scraper.table_dict) assert result == 0.08 result = ocr(table_scraper.screenshot, 'player_funds_area', table_scraper.table_dict, player='0') assert result == 1.67
def test_ocr_pp1(): mongo = MongoManager() table_dict = mongo.get_table( "PartyPoker 6 Players Fast Forward $1-$2 NL Hold'em") table_scraper = TableScraper(table_dict) table_scraper.screenshot = Image.open( os.path.join(get_dir('tests', 'screenshots'), '173280759_PreFlop_0.png')) table_scraper.crop_from_top_left_corner() result = ocr(table_scraper.screenshot, 'total_pot_area', table_scraper.table_dict) assert result == 0.09 result = ocr(table_scraper.screenshot, 'call_value', table_scraper.table_dict) assert result == 0.04 result = ocr(table_scraper.screenshot, 'raise_value', table_scraper.table_dict) assert result == 0.1 result = ocr(table_scraper.screenshot, 'player_funds_area', table_scraper.table_dict, player='0') assert result == 1.32
def test_ocr_pp1(): mongo = MongoManager() table_dict = mongo.get_table("Official Party Poker") table_scraper = TableScraper(table_dict) table_scraper.screenshot = Image.open( os.path.join(get_dir('tests', 'screenshots'), '53269218_PreFlop_0.png')) table_scraper.crop_from_top_left_corner() result = ocr(table_scraper.screenshot, 'total_pot_area', table_scraper.table_dict) assert result == 0.08 result = ocr(table_scraper.screenshot, 'call_value', table_scraper.table_dict) assert result == 0.03 result = ocr(table_scraper.screenshot, 'raise_value', table_scraper.table_dict) assert result == 0.08 result = ocr(table_scraper.screenshot, 'player_funds_area', table_scraper.table_dict, player='0') assert result == 1.98
def get_pots(self): """Get current and total pot""" self.current_round_pot = ocr(self.screenshot, 'current_round_pot', self.table_dict, fast=True) log.info(f"Current round pot {self.current_round_pot}") self.total_pot = ocr(self.screenshot, 'total_pot_area', self.table_dict) log.info(f"Total pot {self.total_pot}")
def get_raise_value(self): """Read the value of the raise button""" self.raise_value = ocr(self.screenshot, 'raise_value', self.table_dict) log.info(f"Raise value: {self.raise_value}") if round(self.raise_value) >= 90: log.warning("Correcting raise value from >90") self.raise_value -= 90 return self.raise_value
def get_call_value(self): """Read the call value from the call button""" self.call_value = ocr(self.screenshot, 'call_value', self.table_dict) log.info(f"Call value: {self.call_value}") if round(self.call_value) >= 90: log.warning("Correcting call value from >90") self.call_value -= 90 return self.call_value
def get_player_pots(self, skip=[]): # pylint: disable=dangerous-default-value """Get pots of the players""" self.player_pots = [] for i in range(self.total_players): if i in skip: funds = 0 else: funds = ocr(self.screenshot, 'player_pot_area', self.table_dict, str(i)) self.player_pots.append(funds) log.info(f"Player pots: {self.player_pots}") return True
def get_bot_pot(self, p): self.gui_signals.signal_status.emit("Get bot pot") from poker.tools.screen_operations import ocr value = ocr(self.screenshot, 'player_pot_area', self.table_dict, str(0)) if value != "": self.bot_pot = float(value) self.value = float(value) if value == "": self.bot_pot = 0 log.debug("Assuming bot pot is 0") return True
def get_players_funds(self, my_funds_only=False, skip=[]): # pylint: disable=dangerous-default-value """ Get funds of players Returns: list of floats """ if my_funds_only: counter = 1 else: counter = self.total_players self.player_funds = [] for i in range(counter): if i in skip: funds = 0 else: funds = ocr(self.screenshot, 'player_funds_area', self.table_dict, str(i)) self.player_funds.append(funds) log.info(f"Player funds: {self.player_funds}") return True
def get_game_number_on_screen2(self): """Game number""" self.game_number = ocr(self.screenshot, 'game_number', self.table_dict) log.debug(f"Game number: {self.game_number}") return self.game_number
def get_raise_value(self): """Read the value of the raise button""" self.raise_value = ocr(self.screenshot, 'raise_value', self.table_dict) log.info(f"Raise value: {self.raise_value}") return self.raise_value
def get_call_value(self): """Read the call value from the call button""" self.call_value = ocr(self.screenshot, 'call_value', self.table_dict) log.info(f"Call value: {self.call_value}") return self.call_value