Vérification des plis

This commit is contained in:
julien committed 2026-10-09 20:26:46 +02:00
1 parent b0fd3c100c
commit ba399719a3
3 files changed
+19 -7

No files matched your search

+14 -6
View File
@@ -5,7 +5,7 @@ require_relative "terminal_ui"
# Gère le déroulement et les règles d'une partie d'Écarté.
class Game
attr_reader :player1, :player2, :dealer, :non_dealer,
:upcard, :trump_suit, :trick_winner
:upcard, :trump_suit, :trick_winner, :stock
def initialize(player_name1, player_name2)
@deck = Deck.new
@@ -67,12 +67,18 @@ class Game
# Vérifie si le coup du second joueur respecte les règles.
def valid_follow_card?(follow_player, lead_card, follow_card)
if follow_card.suit == lead_card.suit
true
elsif follow_player.hand.any? { |card| card.suit == lead_card.suit }
false
if follow_player.hand.any? { |card| card.suit == lead_card.suit }
if follow_player.hand.any? { |card| card.suit == lead_card.suit && card.strength > lead_card.strength }
follow_card.suit == lead_card.suit && follow_card.strength > lead_card.strength
else
follow_card.suit == lead_card.suit
end
else
true
if follow_player.hand.any? { |card| card.suit == @trump_suit }
follow_card.suit == @trump_suit
else
true
end
end
end
@@ -111,6 +117,8 @@ class Game
lead_player = @non_dealer
follow_player = @dealer
@ui.display_trump(@trump_suit)
5.times do
play_trick(lead_player, follow_player)
+5 -1
View File
@@ -18,6 +18,11 @@ class TerminalUI
player.hand[choice - 1]
end
# Affiche la couleur d'atout.
def display_trump(trump_suit)
puts "Trump suit: #{trump_suit}"
end
# Affiche un avertissement si le coup joué ne respecte pas les règles.
def display_wrong_card
puts "You cannot play this card."
@@ -52,4 +57,3 @@ class TerminalUI
puts
end
end
View File
Whitespace-only changes.