def final_result(self): final_result = console.get_template('final_result.txt', 'green') print(final_result) for i, name in enumerate(self.ranking_list): print("{}位: {}".format(i+1, name)) n = list(filter(lambda x: x not in self.ranking_list, self.players_order))[0] print("{}位: {}".format(self.num, n))
def turn(self): # 名前とカードを紐づけるために辞書化 dict_deck = dict(zip(self.player_names, self.results_list)) decide_order = console.get_template('decide_order.txt', 'green') print(decide_order) # self.players_order = random.sample(self.player_names, len(self.player_names)) self.players_order = self.player_names self.dict_deck = dict_deck print(' → '.join(self.players_order))
def __init__(self): super().__init__() # ババ抜きを始めます。 first_message = console.get_template("start_game.txt", "red") print(first_message) # 何人で遊びますか? how_many = console.get_template('how_many.txt', 'green') num = int(input(how_many)) self.num = num # 名前を入力してください。 type_name = console.get_template('type_name.txt', 'green') print(type_name) player_name = [] for i in range(num): player_name.append(input('Player{} : '.format(i + 1))) self.player_names = player_name
def deal(self): deal_cards = console.get_template("deal_cards.txt", "green") print(deal_cards) players_cards = [] print(self.sv_list) for i in range(self.num): players_cards.append([]) while len(self.sv_list) > 0: for player_cards in players_cards: player_cards.append(self.sv_list.pop()) if len(self.sv_list) == 0: break self.players_cards = players_cards for (name, player) in zip(self.player_names, self.players_cards): print(name + " : " + ", ".join(player))
def first_discard(self): discard_pair = console.get_template('discard_pair.txt', 'green') print(discard_pair) players_only_num = [] results_list = [] for i in range(self.num): players_only_num.append([]) for (player_cards, player_only_num) in zip(self.players_cards, players_only_num): for i in player_cards: t = i[:2] player_only_num.append(t) for (player_only_num, name, player_cards) in zip( players_only_num, self.player_names, self.players_cards): # 重複削除 rules = Rules() player_card = rules.index_total(player_only_num, player_cards) results_list.append(player_card) self.results_list = results_list print(name + " : " + ", ".join(player_card))