def decide_win(self, player, grouped_hand, new_tile, src, score, neighbors, game): #print("BEGIN decide win!!!!!") if self.display_step: if src == "steal": self.print_game_board(player.fixed_hand, player.hand, neighbors, game) self.print_msg("Someone just discarded a %s." % new_tile.symbol) else: self.print_game_board(player.fixed_hand, player.hand, neighbors, game, new_tile=new_tile) self.print_msg("%s [%s] chooses to declare victory." % (self.player_name, display_name)) self.print_msg("You can form a victory hand of: ") utils.print_hand(player.fixed_hand, end=" ") utils.print_hand(grouped_hand, end=" ") self.print_msg("[%d]" % score) return True
def get_points_for_runs(self): self._init_analysis() reorderd = sorted(self.all_sequences, key=len, reverse=True) points = 0 for s in reorderd: if len(s) >= 3 and CribbageScorer.is_sequence(s): self._add_run(s) for runs in self.runs.values(): for run in runs: points += len(run) utils.print_hand(run) return points
def print_screen(hand_number: int = None, output: bool = True) -> str: """Print Dealer's and Player's hand""" reset_screen() screen = print_status_line(msg="", status=f"Cards left: {len(game['deck'])}", output=False) screen += dealer["header"] + "\n" for hand in dealer["hand"]: if game["settings"]["display"]["points"]: points, adjective = hand_points(hand) screen += f" POINTS: {points} {adjective if adjective else ''}\n" screen += print_hand(hand, output=False) screen += "\n" + " " * 20 + "-" * 40 + " " * 20 + "\n" if hand_number is None: for idx, (hand, bet) in enumerate(zip(player["hand"], player["bet"])): header = player["header"] if len( player["hand"] ) == 1 else f"Your {player['hand_name'][idx]} hand:" bank_info = f"BANK: ${player['bank']}" if idx == 0 else "" screen += print_status_line(msg=header, status=bank_info, output=False) if game["settings"]["display"]["points"]: points, adjective = hand_points(hand) screen += f" POINTS: {points} {adjective if adjective else ''}\n" screen += f" BET: ${bet}\n" screen += print_hand(hand, output=False) else: hand, bet = player["hand"][hand_number], player["bet"][hand_number] header = player["header"] if len( player["hand"] ) == 1 else f"Your {player['hand_name'][hand_number]} hand:" screen += print_status_line(msg=header, status=f"BANK: ${player['bank']}", output=False) if game["settings"]["display"]["points"]: points, adjective = hand_points(hand) screen += f" POINTS: {points} {adjective if adjective else ''}\n" screen += f" BET: ${bet}\n" screen += print_hand(hand, output=False) if output: print(screen) return screen
import utils import random print("じゃんけんをはじめます") player_name = input("名前を入力してください:") print('何を出しますか?(0: グー, 1: チョキ, 2: パー)') player_hand = int(input("数字で入力してください:")) if utils.validate(player_hand): computer_hand = random.randint(0, 2) if player_name == "": utils.print_hand(player_hand) else: utils.print_hand(player_hand, player_name) utils.print_hand(computer_hand, "コンピューター") result = utils.judge(player_hand, computer_hand) print("結果は" + result + "でした") else: print("正しい数値を入力してください")
import utils # random module import import random print('''Let's start Rock-paper-scissors''') player_name = input('Enter your name:') print('What is your choice?(0: Rock, 1: Scissors, 2: Paper)') player_hand = int(input('Enter the number:')) if utils.validate(player_hand): # randintを用いて0から2までの数値を取得し、変数computer_handに代入してください computer_hand = random.randint(0, 2) if player_name == '': utils.print_hand(player_hand) else: utils.print_hand(player_hand, player_name) utils.print_hand(computer_hand, 'Computer') result = utils.judge(player_hand, computer_hand) print('Result is ' + result) else: print('Choise ONLY number')
import utils print('じゃんけんをはじめます') player_name = input('名前を入力してください:') print('何を出しますか?(0: グー, 1: チョキ, 2: パー)') player_hand = int(input('数字で入力してください:')) if utils.validate(player_hand): computer_hand = 1 if player_name == '': utils.print_hand(player_hand) else: utils.print_hand(player_hand, player_name) utils.print_hand(computer_hand, 'コンピュータ') result = utils.judge(player_hand, computer_hand) print('結果は' + result + 'でした') else: print('正しい数値を入力してください')
import utils import random print("じゃんけんをはじめます") print("何を出すのか決めてください") player_name = "にんじゃわんこ" player_hand = random.randint(0,2) computer_name = "コンピューター" computer_hand = random.randint(0,2) if utils.validate(player_hand): utils.print_hand(player_hand,player_name) utils.print_hand(computer_hand,computer_name) result = utils.judge(player_hand, computer_hand) print("結果は"+result+"でした") else: print("正しい数値を入力してください")
import utils import random print('じゃんけんをしよう!!') player_name = input('名前はなに?') select_hand = int(input('何を出すか数字で決めてね!(0:ぐー 1:チョキ 2:パー)')) if utils.validate(select_hand): computer_hand = random.randint(0, 2) if player_name == '': utils.print_hand(select_hand) else: utils.print_hand(select_hand, player_name) utils.print_hand(computer_hand, 'コンピューター') result = utils.judge(select_hand, computer_hand) print('結果は' + result + 'でした') else: print('正しい値を入力してください')
import utils import randon print('じゃんけんをはじめます') player_name = input('名前を入力してください: ') print('何を出しますか? (0: グー, 1: チョキ, 2: パー) ') palyer_hand = int(input('数字を入力してください: ')) if utils.validate(player_hand): computer_hand = randon.randit(0,2) if player_name == '': utils.print_hand(player_hand) else: utils.print_hand(player_hand, player_name) utils.print_hand(player_hand, player_hand, 'コンピューター result = utils.judge(player_hand, computer_hand print('結果は' + result + 'でした else: print('正しい数値を入力してください')
# Start of the Game while True: playing = True num_mapping = { "ones": 1, "fives": 5, "tens": 10, "twentys": 20, "fiftys": 50 } bust = [] dealer.deal_hands([player1]) dealer_card = dealer.hand[0] # print(f"Dealer hand: {[str(dealer_card.name) + ' of ' + dealer_card.suit]}") print_hand(dealer) print_hand(player1) while playing: # TODO: Modify so it works for multiple players # BETTING STAGE ------------------------------------------------------------- print(f"Pot: {pot}") print(f"Pot: {sum([v*num_mapping[k] for k, v in pot.items()])}") print(player1.chipset.show_chips()) bet_amount = input("Bet amount, or check: ") if bet_amount.lower() == "check": bet_amount = 0 elif int(bet_amount) > player1.get_total(): print("Enter an amount that you can cover, bud.") continue