def play_game(player_1, player_2): challenger_1 = [ player for player in all_players if player.name == player_1 ][0] challenger_2 = [ player for player in all_players if player.name == player_2 ][0] return render_template("index.html", winner=play(challenger_1, challenger_2), title="winner")
def play_against_player(): challenger_1_name = request.form["player_1"] challenger_1_gesture = request.form["P1-gesture"] challenger_2_name = request.form["player_2"] challenger_2_gesture = request.form["P2-gesture"] challenger_1 = Player(challenger_1_name, challenger_1_gesture) challenger_2 = Player(challenger_2_name, challenger_2_gesture) return render_template("index.html", winner=play(challenger_1, challenger_2), title="Winner")
def play_against_computer(): # user input challenger_1_name = request.form["player_1"] challenger_1_gesture = request.form["P1-gesture"] challenger_1 = Player(challenger_1_name, challenger_1_gesture) # random computer selection gestures = ["Rock", "Paper", "Scissors"] computer_roll = random.choice(gestures) # computer_roll = random.randint(0,2) # if computer_roll == 0: # computer_roll = "Rock" # elif computer_roll == 1: # computer_roll = "Paper" # computer_roll = "scissors" computer = Computer("Computer", computer_roll) return render_template("PvC.html", winner=play(challenger_1, computer), title="Winner")
def test_game_scissors_beats_paper(self): self.assertEqual(self.chris, game.play(self.chris,self.jill))
def test_game_scissors_beats_paper_reversed(self): self.assertEqual(self.chris, game.play(self.jill,self.chris))
def test_game_paper_beats_rock_reversed(self): self.assertEqual(self.jill, game.play(self.mark,self.jill))
def test_game_paper_beats_rock(self): self.assertEqual(self.jill, game.play(self.jill,self.mark))
def test_game_rock_beats_scissors_reversed(self): self.assertEqual(self.mark, game.play(self.mark,self.chris))
def test_game_rock_beats_scissors(self): self.assertEqual(self.mark, game.play(self.chris,self.mark))
def test_game_recognizes_draw(self): self.assertEqual(None, game.play(self.mark,self.mark))