Files
ecarte/doc/TerminalUI.html
2026-10-10 14:57:27 +02:00

793 lines
21 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>class TerminalUI - RDoc Documentation</title>
<meta
name="keywords"
content="ruby,class,TerminalUI"
>
<meta
name="description"
content="class TerminalUI: Gère l&#39;affichage et les saisies dans le terminal."
>
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" content="class TerminalUI - RDoc Documentation">
<meta property="og:description" content="Gère l&#39;affichage et les saisies dans le terminal.">
<!-- Twitter -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="class TerminalUI - RDoc Documentation">
<meta name="twitter:description" content="Gère l&#39;affichage et les saisies dans le terminal.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script
src="./js/theme-toggle.js?v=7.0.4"
></script>
<script
src="./js/search_navigation.js?v=7.0.4"
defer
></script>
<script
src="./js/search_data.js?v=7.0.4"
defer
></script>
<script
src="./js/search_ranker.js?v=7.0.4"
defer
></script>
<script
src="./js/search_controller.js?v=7.0.4"
defer
></script>
<script
src="./js/c_highlighter.js?v=7.0.4"
defer
></script>
<script
src="./js/aliki.js?v=7.0.4"
defer
></script>
<link
href="./css/rdoc.css?v=7.0.4"
rel="stylesheet"
>
<body role="document" class="class has-toc">
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<!-- Chevron (right arrow) - used for expand/collapse -->
<symbol
id="icon-chevron"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="9 18 15 12 9 6"></polyline>
</symbol>
<!-- File/Document - Pages section -->
<symbol
id="icon-file"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"
></path>
<polyline points="14 2 14 8 20 8"></polyline>
</symbol>
<!-- Layers/Stack - Classes and Modules section -->
<symbol
id="icon-layers"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polygon points="12 2 2 7 12 12 22 7 12 2"></polygon>
<polyline points="2 17 12 22 22 17"></polyline>
<polyline points="2 12 12 17 22 12"></polyline>
</symbol>
<!-- Curly braces with C - Class Methods section -->
<symbol
id="icon-class-methods"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 3C3.5 3 2 4.5 2 7v3c0 1.5-1 2-1 2s1 .5 1 2v5c0 2.5 1.5 4 4 4"></path>
<path d="M18 3c2.5 0 4 1.5 4 4v3c0 1.5 1 2 1 2s-1 .5-1 2v5c0 2.5-1.5 4-4 4"></path>
<text
x="12"
y="17"
text-anchor="middle"
font-size="13"
font-weight="bold"
fill="currentColor"
stroke="none"
>
C
</text>
</symbol>
<!-- Curly braces with I - Instance Methods section -->
<symbol
id="icon-instance-methods"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 3C3.5 3 2 4.5 2 7v3c0 1.5-1 2-1 2s1 .5 1 2v5c0 2.5 1.5 4 4 4"></path>
<path d="M18 3c2.5 0 4 1.5 4 4v3c0 1.5 1 2 1 2s-1 .5-1 2v5c0 2.5-1.5 4-4 4"></path>
<text
x="12"
y="17"
text-anchor="middle"
font-size="13"
font-weight="bold"
fill="currentColor"
stroke="none"
>
I
</text>
</symbol>
<!-- Double chevrons up - Ancestors section -->
<symbol
id="icon-ancestors"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="17 11 12 6 7 11"></polyline>
<polyline points="17 18 12 13 7 18"></polyline>
</symbol>
<!-- User with plus - Included Modules section -->
<symbol
id="icon-includes"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="8.5" cy="7" r="4"></circle>
<line
x1="20"
y1="8"
x2="20"
y2="14"
></line>
<line
x1="23"
y1="11"
x2="17"
y2="11"
></line>
</symbol>
<!-- User with check - Extended Modules section -->
<symbol
id="icon-extends"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="8.5" cy="7" r="4"></circle>
<polyline points="17 11 19 13 23 9"></polyline>
</symbol>
<!-- List - Sections section -->
<symbol
id="icon-list"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line
x1="8"
y1="6"
x2="21"
y2="6"
></line>
<line
x1="8"
y1="12"
x2="21"
y2="12"
></line>
<line
x1="8"
y1="18"
x2="21"
y2="18"
></line>
<line
x1="3"
y1="6"
x2="3.01"
y2="6"
></line>
<line
x1="3"
y1="12"
x2="3.01"
y2="12"
></line>
<line
x1="3"
y1="18"
x2="3.01"
y2="18"
></line>
</symbol>
</svg>
<header class="top-navbar">
<a href="./index.html" class="navbar-brand">
RDoc Documentation
</a>
<!-- Desktop search bar -->
<div class="navbar-search navbar-search-desktop" role="search">
<form action="#" method="get" accept-charset="utf-8">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results-desktop"
type="text" name="search" placeholder="Search (/) for a class, method..."
spellcheck="false" autocomplete="off"
title="Type to search, Up and Down to navigate, Enter to load">
<ul id="search-results-desktop" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden search-results"></ul>
</form>
</div>
<!-- Mobile search icon button -->
<button id="search-toggle" class="navbar-search-mobile" aria-label="Open search" type="button">
<span aria-hidden="true">🔍</span>
</button>
<!-- Theme toggle button -->
<button id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" type="button">
<span class="theme-toggle-icon" aria-hidden="true">🌙</span>
</button>
</header>
<!-- Search Modal (Mobile) -->
<div id="search-modal" class="search-modal" hidden aria-modal="true" role="dialog" aria-label="Search">
<div class="search-modal-backdrop"></div>
<div class="search-modal-content">
<div class="search-modal-header">
<form class="search-modal-form" action="#" method="get" accept-charset="utf-8">
<span class="search-modal-icon" aria-hidden="true">🔍</span>
<input id="search-field-mobile" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results-mobile"
type="text" name="search" placeholder="Search documentation"
spellcheck="false" autocomplete="off">
<button type="button" class="search-modal-close" aria-label="Close search" id="search-modal-close">
<span aria-hidden="true">esc</span>
</button>
</form>
</div>
<div class="search-modal-body">
<ul id="search-results-mobile" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="search-results search-modal-results initially-hidden"></ul>
<div class="search-modal-empty">
<p>No recent searches</p>
</div>
</div>
</div>
</div>
<div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
<span aria-hidden="true">&#9776;</span>
</div>
<nav id="navigation" role="navigation" hidden>
<div id="fileindex-section" class="nav-section">
<details class="nav-section-collapsible" >
<summary class="nav-section-header">
<span class="nav-section-icon">
<svg>
<use href="#icon-file"></use>
</svg>
</span>
<span class="nav-section-title">Pages</span>
<span class="nav-section-chevron">
<svg>
<use href="#icon-chevron"></use>
</svg>
</span>
</summary>
<ul class="nav-list">
<li>
<a href="./README_md.html">
README
</a>
</li>
</ul>
</details>
</div>
<div id="parent-class-section" class="nav-section">
<details class="nav-section-collapsible" open>
<summary class="nav-section-header">
<span class="nav-section-icon">
<svg><use href="#icon-ancestors"></use></svg>
</span>
<span class="nav-section-title">Ancestors</span>
<span class="nav-section-chevron">
<svg><use href="#icon-chevron"></use></svg>
</span>
</summary>
<ul><li>Object</li></ul>
</details>
</div>
<div class="nav-section">
<details class="nav-section-collapsible" open>
<summary class="nav-section-header">
<span class="nav-section-icon">
<svg><use href="#icon-instance-methods"></use></svg>
</span>
<span class="nav-section-title">Instance Methods</span>
<span class="nav-section-chevron">
<svg><use href="#icon-chevron"></use></svg>
</span>
</summary>
<ul class="nav-list" role="directory">
<li ><a href="#method-i-choose_card">choose_card</a></li>
<li ><a href="#method-i-debug_game">debug_game</a></li>
<li ><a href="#method-i-display_trick_winner">display_trick_winner</a></li>
<li ><a href="#method-i-display_trump">display_trump</a></li>
<li ><a href="#method-i-display_wrong_card">display_wrong_card</a></li>
</ul>
</details>
</div>
<div id="classindex-section" class="nav-section">
<details class="nav-section-collapsible" open>
<summary class="nav-section-header">
<span class="nav-section-icon">
<svg><use href="#icon-layers"></use></svg>
</span>
<span class="nav-section-title">Classes and Modules</span>
<span class="nav-section-chevron">
<svg><use href="#icon-chevron"></use></svg>
</span>
</summary>
<ul class="link-list nav-list"><li><code><a href="./Card.html">Card</a></code></li><li><code><a href="./Deck.html">Deck</a></code></li><li><code><a href="./Game.html">Game</a></code></li><li><code><a href="./Player.html">Player</a></code></li><li><code><a href="./TerminalUI.html">TerminalUI</a></code></li></ul>
</details>
</div>
</nav>
<main role="main" aria-labelledby="class-TerminalUI">
<h1 id="class-TerminalUI" class="anchor-link class">
class TerminalUI
</h1>
<section class="description">
<p>Gère l’affichage et les saisies dans le terminal.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section anchor-link">
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3 id="public-instance-methods"><a href="#public-instance-methods">Public Instance Methods</a></h3>
</header>
<div id="method-i-choose_card" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-choose_card" title="Link to this method">
<span class="method-name">choose_card</span>
<span class="method-args">(player)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-source-code" id="choose_card-source">
<pre class="ruby" data-language="ruby"><span class="ruby-comment"># File lib/terminal_ui.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">choose_card</span>(<span class="ruby-identifier">player</span>)
<span class="ruby-identifier">player</span>.<span class="ruby-identifier">hand</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">card</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{index + 1}. #{card}&quot;</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">print</span> <span class="ruby-string">&#39;Choose a card: &#39;</span>
<span class="ruby-identifier">choice</span> = <span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">until</span> <span class="ruby-identifier">choice</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-value">1</span>, <span class="ruby-identifier">player</span>.<span class="ruby-identifier">hand</span>.<span class="ruby-identifier">length</span>)
<span class="ruby-identifier">print</span> <span class="ruby-string">&#39;Invalid choice. Choose a card: &#39;</span>
<span class="ruby-identifier">choice</span> = <span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">player</span>.<span class="ruby-identifier">hand</span>[<span class="ruby-identifier">choice</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
<span class="ruby-keyword">end</span></pre>
</div>
<div class="method-description">
<p>Demande au joueur de choisir une carte et la retourne.</p>
</div>
</div>
<div id="method-i-debug_game" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-debug_game" title="Link to this method">
<span class="method-name">debug_game</span>
<span class="method-args">(game)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-source-code" id="debug_game-source">
<pre class="ruby" data-language="ruby"><span class="ruby-comment"># File lib/terminal_ui.rb, line 37</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug_game</span>(<span class="ruby-identifier">game</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Dealer: #{game.dealer.name}&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Non-dealer: #{game.non_dealer.name}&quot;</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{game.player1.name} has:&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">player1</span>.<span class="ruby-identifier">hand</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{game.player2.name} has:&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">player2</span>.<span class="ruby-identifier">hand</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Upcard: #{game.upcard}&quot;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Trump suit: #{game.trump_suit}&quot;</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;Stock:&#39;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">game</span>.<span class="ruby-identifier">stock</span>.<span class="ruby-identifier">length</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-keyword">end</span></pre>
</div>
<div class="method-description">
<p>Affiche les informations de débogage.</p>
</div>
</div>
<div id="method-i-display_trick_winner" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-display_trick_winner" title="Link to this method">
<span class="method-name">display_trick_winner</span>
<span class="method-args">(player)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-source-code" id="display_trick_winner-source">
<pre class="ruby" data-language="ruby"><span class="ruby-comment"># File lib/terminal_ui.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">display_trick_winner</span>(<span class="ruby-identifier">player</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{player.name} wins the trick.&quot;</span>
<span class="ruby-identifier">puts</span>
<span class="ruby-keyword">end</span></pre>
</div>
<div class="method-description">
<p>Affiche le joueur ayant remporté le pli.</p>
</div>
</div>
<div id="method-i-display_trump" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-display_trump" title="Link to this method">
<span class="method-name">display_trump</span>
<span class="method-args">(trump_suit)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-source-code" id="display_trump-source">
<pre class="ruby" data-language="ruby"><span class="ruby-comment"># File lib/terminal_ui.rb, line 21</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">display_trump</span>(<span class="ruby-identifier">trump_suit</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Trump suit: #{trump_suit}&quot;</span>
<span class="ruby-keyword">end</span></pre>
</div>
<div class="method-description">
<p>Affiche la couleur d’atout.</p>
</div>
</div>
<div id="method-i-display_wrong_card" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-display_wrong_card" title="Link to this method">
<span class="method-name">display_wrong_card</span>
<span class="method-args">()</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-source-code" id="display_wrong_card-source">
<pre class="ruby" data-language="ruby"><span class="ruby-comment"># File lib/terminal_ui.rb, line 26</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">display_wrong_card</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">&#39;You cannot play this card.&#39;</span>
<span class="ruby-keyword">end</span></pre>
</div>
<div class="method-description">
<p>Affiche un avertissement si le coup joué ne respecte pas les règles.</p>
</div>
</div>
</section>
</section>
</main>
<aside class="table-of-contents" role="complementary" aria-label="Table of Contents">
<div class="toc-sticky">
<h3 class="toc-heading">On This Page</h3>
<nav class="toc-nav" id="toc-nav" aria-label="Page sections">
<!-- Generated by JavaScript based on page headings -->
</nav>
</div>
</aside>
<footer class="site-footer">
<div class="footer-bottom">
<p>
Generated by <a href="https://ruby.github.io/rdoc/">RDoc 7.0.4</a>
using the Aliki theme by <a href="http://st0012.dev">Stan Lo</a>
</p>
</div>
</footer>
</body>