def process(inputList): shop = "Lamar Games" results = [] try: basicUrl = "https://www.lamargames.nl/c-1312737/xbox-classic-games/" pageUrl = "https://www.lamargames.nl/c-1312737-{0}/xbox-classic-games/?sort_order=ascending&sort_method=by_relevance" source = requests.get(basicUrl).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='page-selection') size = pageSelection.findAll('li')[-2].text for x in range(1, int(size) + 1): sourceUrl = pageUrl.format(x) if x != 1 else basicUrl source = requests.get(sourceUrl).text soup = BeautifulSoup(source, 'lxml') for li in soup.findAll( 'li', id=lambda x: x and x.startswith('article_')): title = li.find('a', class_='title').text.strip() pricetag = li.find('span', class_='pricetag') price = pricetag.span.text.strip() url = li.find('a', class_='image')['href'] res = functions.titlePresent(title, inputList) if res: results.append(GameResult(title, price, url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def process(inputList): shop = "Gameland-Groningen" results = [] try: begin = 1 basicUrl = "https://www.gameland-groningen.nl/nl/xbox/xbox-classic/games/page{0}.html" source = requests.get(basicUrl.format(begin)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('span', class_='page-product-count').text.strip() increment = soup.find('span', class_='page-info').find('option', selected=True).text.strip() total = int(pageSelection) total = total / int(increment) for x in range(1, math.ceil(total)+1): if x > 1: source = requests.get(basicUrl.format(x)).text soup = BeautifulSoup(source, 'lxml') for div in soup.findAll('div', class_='product'): title = div.find('div', class_='info').find('a').text.strip() price = div.find('span', class_='new-price').text.strip() url = div.find('div', class_='info').find('a')['href'] res = functions.titlePresent(title,inputList) if res: results.append(GameResult(title,price,url,shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR","404","",shop)) return results
def process(inputList): shop = "Passion For Games" results = [] try: begin = 1 basicUrl = "https://www.gamewebshop.eu/en/xbox/page{0}.html" source = requests.get(basicUrl.format(begin)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='pagination-container') size = pageSelection.findAll('li')[-2].text for x in range(1, int(size) + 1): if x > 1: source = requests.get(basicUrl.format(x)).text soup = BeautifulSoup(source, 'lxml') for div in soup.findAll('div', class_='product'): title = div.find('h3').find('a').text.strip() pricetag = div.find('div', class_='product-price') price = pricetag.span.text.strip() url = div.find('h3').find('a')['href'] res = functions.titlePresent(title, inputList) if res: results.append(GameResult(title, price, url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def runInternal(inputList): shop = "NedGame" results = [] try: global next global source global soup global pageIndex basicUrl = "https://www.nedgame.nl/xbox/games/&aantal=100&pagina={0}" source = requests.get(basicUrl.format(pageIndex)).text soup = BeautifulSoup(source, 'lxml') for tr in soup.findAll('tr', id=lambda x: x and x.startswith('prod_id')): titleDiv = tr.find('div', class_='titlewrapper') title = titleDiv.find('h3').text.strip() price = tr.find('div', class_='currentprice').text.strip() url = titleDiv.find('a')['href'] res = functions.titlePresent(title,inputList) if res: results.append(GameResult(title,price,url,shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR","404","",shop)) return results
def process(inputList): shop = "GamesEnCo" results = [] try: begin = 1 increment = 20 basicUrl = "https://www.gamesenco.be/product-categorie/xbox-2/xbox/page/{0}" source = requests.get(basicUrl.format(begin)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('p', class_='woocommerce-result-count').text.strip() total = int(re.findall(r'\d+', pageSelection)[-1]) total = total / increment for x in range(1, math.ceil(total)+1): if x > 1: source = requests.get(basicUrl.format(x)).text soup = BeautifulSoup(source, 'lxml') ul = soup.find('ul', class_='products') for li in ul.findAll('li', class_='product'): title = li.find('h2', class_='woocommerce-loop-product__title').text.strip() price = li.find('span', class_='woocommerce-Price-amount').text.strip() url = li.find('a')['href'] res = functions.titlePresent(title,inputList) if res: results.append(GameResult(title,price,url,shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR","404","",shop)) return results
def process(inputList): shop = "RetroGamesCorner" results = [] try: begin = 1 increment = 24 basicUrl = "https://www.retrogamescorner.com/44-xbox?page={0}" source = requests.get(basicUrl.format(begin)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='total-products').text.strip() total = int(re.findall(r'\d+', pageSelection)[-1]) total = total / increment for x in range(1, math.ceil(total) + 1): if x > 1: source = requests.get(basicUrl.format(x)).text soup = BeautifulSoup(source, 'lxml') for article in soup.findAll('article', class_='product-miniature'): title = article.find( 'h1', class_='product-title').find('a').text.strip() price = article.find('span', class_='price').text.strip() url = article.find('h1', class_='product-title').find('a')['href'] res = functions.titlePresent(title, inputList) if res: results.append(GameResult(title, price, url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
class Main: def __init__(self, options: Options, result_led: RGBLED): self.starting_time = 0 self.options = options self.game_indicators = GameIndicators(options) self.game_result = GameResult(result_led) self.game = Game(options, self.on_new_question, self.on_ok, self.on_ko) self.game_buttons = GameButtons(options, self.game.process_answer) self._new_turn() def _new_turn(self): self.game_indicators.reset() sleep(1) self.game_result.reset() new_timeout = randint(DELAY_MIN, DELAY_MAX) sleep(new_timeout) self.game.choose_question() def on_new_question(self): self.game_indicators.select(self.game.current_question) self.starting_time = time() def on_ok(self): self.game_indicators.reset() total_time = time() - self.starting_time is_success = total_time < TIME_LIMIT fn = self.game_result.success if ( is_success ) else self.game_result.warn fn() self._new_turn() def on_ko(self): self.game_result.error() self._new_turn()
def act(self, container): try: container.black_player.end_game() except RuntimeError: container.next_action = BlackIllegalMove() return try: container.white_player.end_game() except RuntimeError: container.next_action = WhiteIllegalMove() return scores = rc.get_scores(container.boards[0]) if scores["B"] > scores["W"]: container.game_result = GameResult(winner=container.black_player, loser=container.white_player, loser_was_cheating=False) elif scores["W"] > scores["B"]: container.game_result = GameResult(winner=container.white_player, loser=container.black_player, loser_was_cheating=False) else: winner, loser = toss_coin(container.white_player, container.black_player) container.game_result = GameResult(winner=winner, loser=loser, loser_was_cheating=False)
def process(inputList): shop = "RetroGameKing" results = [] try: begin = 1 increment = 60 basicUrl = "https://www.retrogameking.com/epages/78704979.sf/nl_NL/?ViewAction=View&ObjectPath=/Shops/78704979/Categories/Xbox/Xbox_Games&PageSize={1}&Page={0}" source = requests.get(basicUrl.format(begin, increment)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('ul', class_='PagerSizeContainer') size = pageSelection.findAll('li')[-2].text for x in range(1, int(size) + 1): if x > 1: source = requests.get(basicUrl.format(x, increment)).text soup = BeautifulSoup(source, 'lxml') for div in soup.findAll('div', class_='InfoArea'): title = div.find('h3').find('a').text.strip() pricetag = div.find('span', class_='price-value') price = pricetag.span.text.strip() url = div.find('h3').find('a')['href'] res = functions.titlePresent(title, inputList) if res: results.append( GameResult( title, price, "https://www.retrogameking.com/epages/78704979.sf/nl_NL/" + url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def __init__(self, options: Options, result_led: RGBLED): self.starting_time = 0 self.options = options self.game_indicators = GameIndicators(options) self.game_result = GameResult(result_led) self.game = Game(options, self.on_new_question, self.on_ok, self.on_ko) self.game_buttons = GameButtons(options, self.game.process_answer) self._new_turn()
def process(inputList): shop = "Press Start Games" results = [] try: basicUrl = "https://www.press-startgames.com/c-3103097/complete-cib-pal/" pageUrl = "https://www.press-startgames.com/c-3103097-{0}/complete-cib-pal/" source = requests.get(basicUrl).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='page-selection') size = pageSelection.findAll('li')[-2].text for x in range(1, int(size) + 1): sourceUrl = pageUrl.format(x) if x != 1 else basicUrl source = requests.get(sourceUrl).text soup = BeautifulSoup(source, 'lxml') for li in soup.findAll( 'li', id=lambda x: x and x.startswith('article_')): title = li.find('a', class_='title').text.strip() pricetag = li.find('span', class_='pricetag') price = pricetag.span.text.strip() url = li.find('a', class_='image')['href'] res = functions.titlePresent(title, inputList) if res: results.append(GameResult(title, price, url, shop)) '''run for ntsc put this in common function''' basicUrl = "https://www.press-startgames.com/c-3103098/complete-cib-ntsc/" pageUrl = "https://www.press-startgames.com/c-3103098-{0}/complete-cib-ntsc/" source = requests.get(basicUrl).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='page-selection') if pageSelection is None: size = 1 else: size = pageSelection.findAll('li')[-2].text for x in range(1, int(size) + 1): sourceUrl = pageUrl.format(x) if x != 1 else basicUrl source = requests.get(sourceUrl).text soup = BeautifulSoup(source, 'lxml') for li in soup.findAll( 'li', id=lambda x: x and x.startswith('article_')): title = li.find('a', class_='title').text.strip() pricetag = li.find('span', class_='pricetag') price = pricetag.span.text.strip() url = li.find('a', class_='image')['href'] res = functions.titlePresent(title, inputList) if res: results.append(GameResult(title, price, url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def process(inputList): shop = "JPRS Games" results = [] try: begin = 1 end = 40 increment = 39 basicUrl = "https://jprsgames.nl/index.php/xbox/games2013-04-03-09-00-102013-04-03-09-00-10-3/results,{0}-{1}" source = requests.get(basicUrl.format(begin, end)).text soup = BeautifulSoup(source, 'lxml') pageSelection = soup.find('div', class_='display-number').contents[0].strip() total = int(next(re.finditer(r'\d+$', pageSelection)).group(0)) + increment while end < total: if begin > 1: source = requests.get(basicUrl.format(begin, end)).text soup = BeautifulSoup(source, 'lxml') for div in soup.findAll('div', class_='product'): titleDiv = div.find('div', class_=lambda x: x and x.startswith( 'vm-product-descr-container')) title = titleDiv.find('h2').text.strip() price = div.find('span', class_='PricesalesPrice').text.strip() url = titleDiv.find('h2').find('a')['href'] res = functions.titlePresent(title, inputList) if res: results.append( GameResult(title, price, 'https://jprsgames.nl' + url, shop)) begin = begin + 39 end = end + 39 return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def act(self, container): try: container.black_player.end_game() except RuntimeError: pass try: container.white_player.end_game() except RuntimeError: pass container.game_result = GameResult(winner=container.white_player, loser=container.black_player, loser_was_cheating=True)
def get_plot_groups(): sorted_groups = sorted(game_results, key=lambda a: (a.player_sum, a.dealer_card_showing)) groups = groupby(sorted_groups, lambda a: (a.player_sum, a.dealer_card_showing)) plot_groups = [] for key, group in groups: group = list(group) wins = [g.win for g in group] wins_avg = s.mean(wins) plot_groups.append( GameResult(group[0].player_sum, group[0].dealer_card_showing, wins_avg)) return plot_groups
def process(inputList): shop = "Gameshop-Twente" results = [] try: begin = 1 increment = 16 basicUrl = "https://www.gameshop-twente.nl/inhoudZoeken.php?blz={0}&&maxAantalResults={1}&&productgroep=&&systeem=Genre_Games&&genre=&&actie=navbar_klik&&tagNegeer=niets&&meegekregenTermen=_@Systeem@XBX_@Groep@Games" source = requests.get(basicUrl.format(begin, increment)).text soup = BeautifulSoup(source, 'lxml') pages = soup.find('input', id='aantalBladzijden')['value'] for x in range(1, int(pages) + 1): if x > 1: source = requests.get(basicUrl.format(x, increment)).text soup = BeautifulSoup(source, 'lxml') for div in soup.findAll('div', id='browse_resultbox_zoekpagina'): title = div.find('table').find('a').text.strip() prices = div.findAll('div', class_='genoegVoorraad') if len(prices) > 0: price = "" for i in prices: price = price + i.find( 'span', id='prijs_center').text.strip() + " " url = div.find('table').find('a')['href'] res = functions.titlePresent(title, inputList) if res: results.append( GameResult(title, price, "https://www.gameshop-twente.nl/" + url, shop)) return results except: print(sys.exc_info()[0]) results.append(GameResult("ERROR", "404", "", shop)) return results
def play(self, start_check_limit): self.init_dealer_cards() # two cards for dealer self.init_player_cards() # two cards for player if (self.get_player_cards_sum() == 21): # natural when dealer also has 21 win = 0 if self.get_dealer_cards_sum() == 21 else 1 return GameResult(self.get_player_cards_sum(), self.showing_card, win) # player hitting until stopping while self.get_player_cards_sum() < start_check_limit: self.add_card(self.deck.GetTopCardValue(), self.player_cards) # bust, instant lose if self.get_player_cards_sum() > 21: return GameResult(self.get_player_cards_sum(), self.showing_card, -1) # dealer's turn while self.get_dealer_cards_sum() < 17: self.add_card(self.deck.GetTopCardValue(), self.dealer_cards) if self.get_player_cards_sum() > 21: win = -1 elif self.get_dealer_cards_sum() > 21: win = 1 elif self.get_player_cards_sum() == 21: win = 1 elif self.get_dealer_cards_sum() == self.get_player_cards_sum(): win = 0 elif self.get_player_cards_sum() > self.get_dealer_cards_sum(): win = 1 else: win = -1 return GameResult(self.get_player_cards_sum(), self.showing_card, win)
def give_answer(self, answer: bool): def exceeded_allowed_mistakes(): return self.__mistakes > self.__allowed_mistakes if self.__questions[self.__counter].is_true != answer: self.__mistakes += 1 if self.is_last_question() or exceeded_allowed_mistakes(): self.__game_status = GameStatus.GAME_IS_OVER result = GameResult(self.__counter, self.__mistakes, self.__mistakes <= self.__allowed_mistakes) self.__end_of_game_event(result) self.__counter += 1