Ajoute les commentaires et la documentation RDoc

This commit is contained in:
julien committed 2026-10-08 19:42:56 +02:00
1 parent 5cf2d683e7
commit dbd8c51412
56 files changed
+3601 -17

No files matched your search

+271
View File
@@ -0,0 +1,271 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>class Card - RDoc Documentation</title>
<meta name="keywords" content="ruby,class,Card">
<meta name="description" content="class Card: Représente une carte à jouer avec sa valeur et sa couleur.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<ul><li>Object</li></ul>
</div>
<div class="nav-section">
<h3>Class Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-new">new</a></li>
</ul>
</div>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-strength">strength</a></li>
<li ><a href="#method-i-to_s">to_s</a></li>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main" aria-labelledby="class-Card">
<h1 id="class-Card" class="anchor-link class">
class Card
</h1>
<section class="description">
<p>Représente une carte à jouer avec sa valeur et sa couleur.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section anchor-link">
<section class="attribute-method-details" class="method-section">
<header>
<h3>Attributes</h3>
</header>
<div id="attribute-i-suit" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-suit" title="Link to this attribute">
<span class="method-name">suit</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-value" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-value" title="Link to this attribute">
<span class="method-name">value</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
</section>
<section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-new" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-c-new" title="Link to this method">
<span class="method-name">new</span>
<span class="method-args">(value, suit)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/card.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">suit</span>)
<span class="ruby-ivar">@value</span> = <span class="ruby-identifier">value</span>
<span class="ruby-ivar">@suit</span> = <span class="ruby-identifier">suit</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-strength" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-strength" title="Link to this method">
<span class="method-name">strength</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-description">
<div class="method-source-code" id="strength-source">
<pre><span class="ruby-comment"># File lib/card.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">strength</span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@value</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/\A\d+\z/</span>)
<span class="ruby-ivar">@value</span>.<span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">else</span>
<span class="ruby-keyword">case</span> <span class="ruby-ivar">@value</span>
<span class="ruby-keyword">when</span> <span class="ruby-string">&quot;ace&quot;</span>
<span class="ruby-value">11</span>
<span class="ruby-keyword">when</span> <span class="ruby-string">&quot;jack&quot;</span>
<span class="ruby-value">12</span>
<span class="ruby-keyword">when</span> <span class="ruby-string">&quot;queen&quot;</span>
<span class="ruby-value">13</span>
<span class="ruby-keyword">when</span> <span class="ruby-string">&quot;king&quot;</span>
<span class="ruby-value">14</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retourne la force de la carte sous forme d’integer.</p>
</div>
</div>
<div id="method-i-to_s" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-to_s" title="Link to this method">
<span class="method-name">to_s</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-description">
<div class="method-source-code" id="to_s-source">
<pre><span class="ruby-comment"># File lib/card.rb, line 11</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_s</span>
<span class="ruby-node">&quot;#{@value} of #{@suit}&quot;</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retourne une représentation de la carte sous forme de string.</p>
</div>
</div>
</section>
</section>
</main>
+253
View File
@@ -0,0 +1,253 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>class Deck - RDoc Documentation</title>
<meta name="keywords" content="ruby,class,Deck">
<meta name="description" content="class Deck: Représente un paquet de cartes et gère son contenu.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<ul><li>Object</li></ul>
</div>
<div class="nav-section">
<h3>Class Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-new">new</a></li>
</ul>
</div>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-draw">draw</a></li>
<li ><a href="#method-i-shuffle">shuffle</a></li>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main" aria-labelledby="class-Deck">
<h1 id="class-Deck" class="anchor-link class">
class Deck
</h1>
<section class="description">
<p>Représente un paquet de cartes et gère son contenu.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section anchor-link">
<section class="attribute-method-details" class="method-section">
<header>
<h3>Attributes</h3>
</header>
<div id="attribute-i-cards" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-cards" title="Link to this attribute">
<span class="method-name">cards</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
</section>
<section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-new" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-c-new" title="Link to this method">
<span class="method-name">new</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-description">
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/deck.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
<span class="ruby-ivar">@cards</span> = []
<span class="ruby-identifier">values</span> = [<span class="ruby-string">&quot;7&quot;</span>, <span class="ruby-string">&quot;8&quot;</span>, <span class="ruby-string">&quot;9&quot;</span>, <span class="ruby-string">&quot;10&quot;</span>, <span class="ruby-string">&quot;ace&quot;</span>, <span class="ruby-string">&quot;jack&quot;</span>, <span class="ruby-string">&quot;queen&quot;</span>, <span class="ruby-string">&quot;king&quot;</span>]
<span class="ruby-identifier">suits</span> = [<span class="ruby-string">&quot;hearts&quot;</span>, <span class="ruby-string">&quot;diamonds&quot;</span>, <span class="ruby-string">&quot;clubs&quot;</span>, <span class="ruby-string">&quot;spades&quot;</span>]
<span class="ruby-identifier">suits</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">suit</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
<span class="ruby-ivar">@cards</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Card</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">suit</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-draw" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-draw" title="Link to this method">
<span class="method-name">draw</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-description">
<div class="method-source-code" id="draw-source">
<pre><span class="ruby-comment"># File lib/deck.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">draw</span>
<span class="ruby-ivar">@cards</span>.<span class="ruby-identifier">pop</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retire et retourne la dernière carte du paquet.</p>
</div>
</div>
<div id="method-i-shuffle" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-shuffle" title="Link to this method">
<span class="method-name">shuffle</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-description">
<div class="method-source-code" id="shuffle-source">
<pre><span class="ruby-comment"># File lib/deck.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">shuffle</span>
<span class="ruby-ivar">@cards</span>.<span class="ruby-identifier">shuffle!</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Mélange les cartes du paquet.</p>
</div>
</div>
</section>
</section>
</main>
+601
View File
@@ -0,0 +1,601 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>class Game - RDoc Documentation</title>
<meta name="keywords" content="ruby,class,Game">
<meta name="description" content="class Game: Gère le déroulement et les règles d&#39;une partie d&#39;Écarté.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<ul><li>Object</li></ul>
</div>
<div class="nav-section">
<h3>Class Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-new">new</a></li>
</ul>
</div>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-change_dealer">change_dealer</a></li>
<li ><a href="#method-i-deal">deal</a></li>
<li ><a href="#method-i-determine_dealer">determine_dealer</a></li>
<li ><a href="#method-i-game_winner">game_winner</a></li>
<li ><a href="#method-i-other_player">other_player</a></li>
<li ><a href="#method-i-play">play</a></li>
<li ><a href="#method-i-play_trick">play_trick</a></li>
<li ><a href="#method-i-stock">stock</a></li>
<li ><a href="#method-i-valid_follow_card-3F">valid_follow_card?</a></li>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main" aria-labelledby="class-Game">
<h1 id="class-Game" class="anchor-link class">
class Game
</h1>
<section class="description">
<p>Gère le déroulement et les règles d’une partie d’Écarté.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section anchor-link">
<section class="attribute-method-details" class="method-section">
<header>
<h3>Attributes</h3>
</header>
<div id="attribute-i-dealer" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-dealer" title="Link to this attribute">
<span class="method-name">dealer</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-non_dealer" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-non_dealer" title="Link to this attribute">
<span class="method-name">non_dealer</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-player1" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-player1" title="Link to this attribute">
<span class="method-name">player1</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-player2" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-player2" title="Link to this attribute">
<span class="method-name">player2</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-trick_winner" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-trick_winner" title="Link to this attribute">
<span class="method-name">trick_winner</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-trump_suit" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-trump_suit" title="Link to this attribute">
<span class="method-name">trump_suit</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-upcard" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-upcard" title="Link to this attribute">
<span class="method-name">upcard</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
</section>
<section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-new" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-c-new" title="Link to this method">
<span class="method-name">new</span>
<span class="method-args">(player_name1, player_name2)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 10</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">player_name1</span>, <span class="ruby-identifier">player_name2</span>)
<span class="ruby-ivar">@deck</span> = <span class="ruby-constant">Deck</span>.<span class="ruby-identifier">new</span>
<span class="ruby-ivar">@player1</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">player_name1</span>)
<span class="ruby-ivar">@player2</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">player_name2</span>)
<span class="ruby-ivar">@dealer</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-ivar">@non_dealer</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-ivar">@upcard</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-ivar">@trump_suit</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-ivar">@trick_winner</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-ivar">@ui</span> = <span class="ruby-constant">TerminalUI</span>.<span class="ruby-identifier">new</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-change_dealer" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-change_dealer" title="Link to this method">
<span class="method-name">change_dealer</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-description">
<div class="method-source-code" id="change_dealer-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">change_dealer</span>
<span class="ruby-identifier">old_dealer</span> = <span class="ruby-ivar">@dealer</span>
<span class="ruby-ivar">@dealer</span> = <span class="ruby-ivar">@non_dealer</span>
<span class="ruby-ivar">@non_dealer</span> = <span class="ruby-identifier">old_dealer</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Échange les rôles de donneur et de non-donneur.</p>
</div>
</div>
<div id="method-i-deal" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-deal" title="Link to this method">
<span class="method-name">deal</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-description">
<div class="method-source-code" id="deal-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deal</span>
<span class="ruby-ivar">@player1</span>.<span class="ruby-identifier">clear_hand</span>
<span class="ruby-ivar">@player2</span>.<span class="ruby-identifier">clear_hand</span>
<span class="ruby-ivar">@deck</span> = <span class="ruby-constant">Deck</span>.<span class="ruby-identifier">new</span>
<span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">shuffle</span>
<span class="ruby-value">5</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
<span class="ruby-ivar">@non_dealer</span>.<span class="ruby-identifier">receive</span>(<span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">draw</span>)
<span class="ruby-ivar">@dealer</span>.<span class="ruby-identifier">receive</span>(<span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">draw</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-ivar">@upcard</span> = <span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">draw</span>
<span class="ruby-ivar">@trump_suit</span> = <span class="ruby-ivar">@upcard</span>.<span class="ruby-identifier">suit</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Distribue les cartes et pose la retourne.</p>
</div>
</div>
<div id="method-i-determine_dealer" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-determine_dealer" title="Link to this method">
<span class="method-name">determine_dealer</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-description">
<div class="method-source-code" id="determine_dealer-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">determine_dealer</span>
<span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">shuffle</span>
<span class="ruby-keyword">while</span> <span class="ruby-ivar">@dealer</span>.<span class="ruby-identifier">nil?</span>
<span class="ruby-identifier">card1</span> = <span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">cards</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">30</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
<span class="ruby-identifier">card2</span> = <span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">cards</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">30</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
<span class="ruby-keyword">if</span> <span class="ruby-identifier">card1</span>.<span class="ruby-identifier">strength</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">card2</span>.<span class="ruby-identifier">strength</span>
<span class="ruby-ivar">@dealer</span> = <span class="ruby-ivar">@player1</span>
<span class="ruby-ivar">@non_dealer</span> = <span class="ruby-ivar">@player2</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">card2</span>.<span class="ruby-identifier">strength</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">card1</span>.<span class="ruby-identifier">strength</span>
<span class="ruby-ivar">@dealer</span> = <span class="ruby-ivar">@player2</span>
<span class="ruby-ivar">@non_dealer</span> = <span class="ruby-ivar">@player1</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Simule une coupe pour déterminer quel joueur sera le donneur.</p>
</div>
</div>
<div id="method-i-game_winner" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-game_winner" title="Link to this method">
<span class="method-name">game_winner</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-description">
<div class="method-source-code" id="game_winner-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 123</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">game_winner</span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@player1</span>.<span class="ruby-identifier">score</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@player2</span>.<span class="ruby-identifier">score</span>
<span class="ruby-ivar">@player1</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@player1</span>.<span class="ruby-identifier">score</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@player2</span>.<span class="ruby-identifier">score</span>
<span class="ruby-ivar">@player2</span>
<span class="ruby-keyword">else</span>
<span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retourne le joueur ayant le meilleur score.</p>
</div>
</div>
<div id="method-i-other_player" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-other_player" title="Link to this method">
<span class="method-name">other_player</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-description">
<div class="method-source-code" id="other_player-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 105</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">other_player</span>(<span class="ruby-identifier">player</span>)
<span class="ruby-identifier">player</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@player1</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@player2</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@player1</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retourne l’autre joueur.</p>
</div>
</div>
<div id="method-i-play" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-play" title="Link to this method">
<span class="method-name">play</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-description">
<div class="method-source-code" id="play-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">play</span>
<span class="ruby-identifier">lead_player</span> = <span class="ruby-ivar">@non_dealer</span>
<span class="ruby-identifier">follow_player</span> = <span class="ruby-ivar">@dealer</span>
<span class="ruby-value">5</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
<span class="ruby-identifier">play_trick</span>(<span class="ruby-identifier">lead_player</span>, <span class="ruby-identifier">follow_player</span>)
<span class="ruby-identifier">lead_player</span> = <span class="ruby-ivar">@trick_winner</span>
<span class="ruby-identifier">follow_player</span> = <span class="ruby-identifier">other_player</span>(<span class="ruby-identifier">lead_player</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Joue une partie.</p>
</div>
</div>
<div id="method-i-play_trick" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-play_trick" title="Link to this method">
<span class="method-name">play_trick</span>
<span class="method-args">(lead_player, follow_player)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="play_trick-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 80</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">play_trick</span>(<span class="ruby-identifier">lead_player</span>, <span class="ruby-identifier">follow_player</span>)
<span class="ruby-identifier">lead_card</span> = <span class="ruby-ivar">@ui</span>.<span class="ruby-identifier">choose_card</span>(<span class="ruby-identifier">lead_player</span>)
<span class="ruby-identifier">follow_card</span> = <span class="ruby-ivar">@ui</span>.<span class="ruby-identifier">choose_card</span>(<span class="ruby-identifier">follow_player</span>)
<span class="ruby-keyword">until</span> <span class="ruby-identifier">valid_follow_card?</span>(<span class="ruby-identifier">follow_player</span>, <span class="ruby-identifier">lead_card</span>, <span class="ruby-identifier">follow_card</span>)
<span class="ruby-ivar">@ui</span>.<span class="ruby-identifier">display_wrong_card</span>
<span class="ruby-identifier">follow_card</span> = <span class="ruby-ivar">@ui</span>.<span class="ruby-identifier">choose_card</span>(<span class="ruby-identifier">follow_player</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">lead_player</span>.<span class="ruby-identifier">play</span>(<span class="ruby-identifier">lead_card</span>)
<span class="ruby-identifier">follow_player</span>.<span class="ruby-identifier">play</span>(<span class="ruby-identifier">follow_card</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">lead_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">follow_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">follow_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">!=</span> <span class="ruby-ivar">@trump_suit</span>
<span class="ruby-ivar">@trick_winner</span> = <span class="ruby-identifier">lead_player</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">lead_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">follow_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">lead_card</span>.<span class="ruby-identifier">strength</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">follow_card</span>.<span class="ruby-identifier">strength</span>
<span class="ruby-ivar">@trick_winner</span> = <span class="ruby-identifier">lead_player</span>
<span class="ruby-keyword">else</span>
<span class="ruby-ivar">@trick_winner</span> = <span class="ruby-identifier">follow_player</span>
<span class="ruby-keyword">end</span>
<span class="ruby-ivar">@trick_winner</span>.<span class="ruby-identifier">add_point</span>
<span class="ruby-ivar">@ui</span>.<span class="ruby-identifier">display_trick_winner</span>(<span class="ruby-ivar">@trick_winner</span>)
<span class="ruby-keyword">end</span></pre>
</div>
<p>Joue un pli.</p>
</div>
</div>
<div id="method-i-stock" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-stock" title="Link to this method">
<span class="method-name">stock</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-description">
<div class="method-source-code" id="stock-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 64</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">stock</span>
<span class="ruby-ivar">@deck</span>.<span class="ruby-identifier">cards</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retourne les cartes restantes dans le talon.</p>
</div>
</div>
<div id="method-i-valid_follow_card-3F" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-valid_follow_card-3F" title="Link to this method">
<span class="method-name">valid_follow_card?</span>
<span class="method-args">(follow_player, lead_card, follow_card)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="valid_follow_card-3F-source">
<pre><span class="ruby-comment"># File lib/game.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">valid_follow_card?</span>(<span class="ruby-identifier">follow_player</span>, <span class="ruby-identifier">lead_card</span>, <span class="ruby-identifier">follow_card</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">follow_card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">lead_card</span>.<span class="ruby-identifier">suit</span>
<span class="ruby-keyword">true</span>
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">follow_player</span>.<span class="ruby-identifier">hand</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">card</span><span class="ruby-operator">|</span> <span class="ruby-identifier">card</span>.<span class="ruby-identifier">suit</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">lead_card</span>.<span class="ruby-identifier">suit</span> }
<span class="ruby-keyword">false</span>
<span class="ruby-keyword">else</span>
<span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Vérifie si le coup du second joueur respecte les règles.</p>
</div>
</div>
</section>
</section>
</main>
+331
View File
@@ -0,0 +1,331 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>class Player - RDoc Documentation</title>
<meta name="keywords" content="ruby,class,Player">
<meta name="description" content="class Player: Représente un joueur, sa main et son score.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<ul><li>Object</li></ul>
</div>
<div class="nav-section">
<h3>Class Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-new">new</a></li>
</ul>
</div>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-add_point">add_point</a></li>
<li ><a href="#method-i-clear_hand">clear_hand</a></li>
<li ><a href="#method-i-play">play</a></li>
<li ><a href="#method-i-receive">receive</a></li>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main" aria-labelledby="class-Player">
<h1 id="class-Player" class="anchor-link class">
class Player
</h1>
<section class="description">
<p>Représente un joueur, sa main et son score.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section anchor-link">
<section class="attribute-method-details" class="method-section">
<header>
<h3>Attributes</h3>
</header>
<div id="attribute-i-hand" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-hand" title="Link to this attribute">
<span class="method-name">hand</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-name" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-name" title="Link to this attribute">
<span class="method-name">name</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="attribute-i-score" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#attribute-i-score" title="Link to this attribute">
<span class="method-name">score</span>
<span class="attribute-access-type">[R]</span>
</a>
</div>
<div class="method-description">
</div>
</div>
</section>
<section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-new" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-c-new" title="Link to this method">
<span class="method-name">new</span>
<span class="method-args">(name)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File lib/player.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">name</span>)
<span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
<span class="ruby-ivar">@hand</span> = []
<span class="ruby-ivar">@score</span> = <span class="ruby-value">0</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-add_point" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-add_point" title="Link to this method">
<span class="method-name">add_point</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-description">
<div class="method-source-code" id="add_point-source">
<pre><span class="ruby-comment"># File lib/player.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_point</span>
<span class="ruby-ivar">@score</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Ajoute un point au joueur.</p>
</div>
</div>
<div id="method-i-clear_hand" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-clear_hand" title="Link to this method">
<span class="method-name">clear_hand</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-description">
<div class="method-source-code" id="clear_hand-source">
<pre><span class="ruby-comment"># File lib/player.rb, line 17</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">clear_hand</span>
<span class="ruby-ivar">@hand</span>.<span class="ruby-identifier">clear</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Vide la main du joueur.</p>
</div>
</div>
<div id="method-i-play" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-play" title="Link to this method">
<span class="method-name">play</span>
<span class="method-args">(card)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="play-source">
<pre><span class="ruby-comment"># File lib/player.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">play</span>(<span class="ruby-identifier">card</span>)
<span class="ruby-ivar">@hand</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">card</span>)
<span class="ruby-keyword">end</span></pre>
</div>
<p>Retire une carte de la main du joueur.</p>
</div>
</div>
<div id="method-i-receive" class="method-detail anchor-link ">
<div class="method-header">
<div class="method-heading">
<a href="#method-i-receive" title="Link to this method">
<span class="method-name">receive</span>
<span class="method-args">(card)</span>
</a>
</div>
</div>
<div class="method-controls">
<details class="method-source-toggle">
<summary>Source</summary>
</details>
</div>
<div class="method-description">
<div class="method-source-code" id="receive-source">
<pre><span class="ruby-comment"># File lib/player.rb, line 12</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">receive</span>(<span class="ruby-identifier">card</span>)
<span class="ruby-ivar">@hand</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">card</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Ajoute une carte à la main du joueur.</p>
</div>
</div>
</section>
</section>
</main>
+90
View File
@@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>README - RDoc Documentation</title>
<meta name="keywords" content="ruby,documentation,README">
<meta name="description" content="README: # Écarté">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="file">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>
<ul class="link-list">
<li><a href="./README_md.html">README</a>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main" aria-label="Page README.md">
<h1 id="label-C3-89cart-C3-A9">Écarté<span><a href="#label-C3-89cart-C3-A9">&para;</a> <a href="#top">&uarr;</a></span></h1>
</main>
+270
View File
@@ -0,0 +1,270 @@
<!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.">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<ul><li>Object</li></ul>
</div>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-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_wrong_card">display_wrong_card</a></li>
</ul>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</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>Public Instance Methods</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-description">
<div class="method-source-code" id="choose_card-source">
<pre><span class="ruby-comment"># File lib/terminal_ui.rb, line 5</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">&quot;Choose a card: &quot;</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-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>
<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-description">
<div class="method-source-code" id="debug_game-source">
<pre><span class="ruby-comment"># File lib/terminal_ui.rb, line 28</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">&quot;Stock:&quot;</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>
<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-description">
<div class="method-source-code" id="display_trick_winner-source">
<pre><span class="ruby-comment"># File lib/terminal_ui.rb, line 22</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>
<p>Affiche le joueur ayant remporté le pli.</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-description">
<div class="method-source-code" id="display_wrong_card-source">
<pre><span class="ruby-comment"># File lib/terminal_ui.rb, line 17</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">&quot;You cannot play this card.&quot;</span>
<span class="ruby-keyword">end</span></pre>
</div>
<p>Affiche un avertissement si le coup joué ne respecte pas les règles.</p>
</div>
</div>
</section>
</section>
</main>
+8
View File
@@ -0,0 +1,8 @@
Thu, 08 Oct 2026 19:38:51 +0200
/home/julien/src/ecarte/README.md Tue, 06 Oct 2026 15:31:12 +0200
/home/julien/src/ecarte/lib/card.rb Thu, 08 Oct 2026 19:34:18 +0200
/home/julien/src/ecarte/lib/deck.rb Thu, 08 Oct 2026 19:33:38 +0200
/home/julien/src/ecarte/lib/game.rb Thu, 08 Oct 2026 19:33:06 +0200
/home/julien/src/ecarte/lib/player.rb Thu, 08 Oct 2026 19:32:32 +0200
/home/julien/src/ecarte/lib/terminal_ui.rb Thu, 08 Oct 2026 19:37:44 +0200
/home/julien/src/ecarte/main.rb Thu, 08 Oct 2026 18:35:18 +0200
+167
View File
@@ -0,0 +1,167 @@
/*
* Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
* with Reserved Font Name "Source". All Rights Reserved. Source is a
* trademark of Adobe Systems Incorporated in the United States and/or other
* countries.
*
* This Font Software is licensed under the SIL Open Font License, Version
* 1.1.
*
* This license is copied below, and is also available with a FAQ at:
* http://scripts.sil.org/OFL
*/
@font-face {
font-family: "Source Code Pro";
font-style: normal;
font-weight: 400;
src: local("Source Code Pro"),
local("SourceCodePro-Regular"),
url("../fonts/SourceCodePro-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Source Code Pro";
font-style: normal;
font-weight: 700;
src: local("Source Code Pro Bold"),
local("SourceCodePro-Bold"),
url("../fonts/SourceCodePro-Bold.ttf") format("truetype");
}
/*
* Copyright (c) 2010, Łukasz Dziedzic (dziedzic@typoland.com),
* with Reserved Font Name Lato.
*
* This Font Software is licensed under the SIL Open Font License, Version
* 1.1.
*
* This license is copied below, and is also available with a FAQ at:
* http://scripts.sil.org/OFL
*/
@font-face {
font-family: "Lato";
font-style: normal;
font-weight: 300;
src: local("Lato Light"),
local("Lato-Light"),
url("../fonts/Lato-Light.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: italic;
font-weight: 300;
src: local("Lato Light Italic"),
local("Lato-LightItalic"),
url("../fonts/Lato-LightItalic.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: normal;
font-weight: 700;
src: local("Lato Regular"),
local("Lato-Regular"),
url("../fonts/Lato-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Lato";
font-style: italic;
font-weight: 700;
src: local("Lato Italic"),
local("Lato-Italic"),
url("../fonts/Lato-RegularItalic.ttf") format("truetype");
}
/*
* -----------------------------------------------------------
* SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
* -----------------------------------------------------------
*
* PREAMBLE
* The goals of the Open Font License (OFL) are to stimulate worldwide
* development of collaborative font projects, to support the font creation
* efforts of academic and linguistic communities, and to provide a free and
* open framework in which fonts may be shared and improved in partnership
* with others.
*
* The OFL allows the licensed fonts to be used, studied, modified and
* redistributed freely as long as they are not sold by themselves. The
* fonts, including any derivative works, can be bundled, embedded,
* redistributed and/or sold with any software provided that any reserved
* names are not used by derivative works. The fonts and derivatives,
* however, cannot be released under any other type of license. The
* requirement for fonts to remain under this license does not apply
* to any document created using the fonts or their derivatives.
*
* DEFINITIONS
* "Font Software" refers to the set of files released by the Copyright
* Holder(s) under this license and clearly marked as such. This may
* include source files, build scripts and documentation.
*
* "Reserved Font Name" refers to any names specified as such after the
* copyright statement(s).
*
* "Original Version" refers to the collection of Font Software components as
* distributed by the Copyright Holder(s).
*
* "Modified Version" refers to any derivative made by adding to, deleting,
* or substituting -- in part or in whole -- any of the components of the
* Original Version, by changing formats or by porting the Font Software to a
* new environment.
*
* "Author" refers to any designer, engineer, programmer, technical
* writer or other person who contributed to the Font Software.
*
* PERMISSION & CONDITIONS
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of the Font Software, to use, study, copy, merge, embed, modify,
* redistribute, and sell modified and unmodified copies of the Font
* Software, subject to the following conditions:
*
* 1) Neither the Font Software nor any of its individual components,
* in Original or Modified Versions, may be sold by itself.
*
* 2) Original or Modified Versions of the Font Software may be bundled,
* redistributed and/or sold with any software, provided that each copy
* contains the above copyright notice and this license. These can be
* included either as stand-alone text files, human-readable headers or
* in the appropriate machine-readable metadata fields within text or
* binary files as long as those fields can be easily viewed by the user.
*
* 3) No Modified Version of the Font Software may use the Reserved Font
* Name(s) unless explicit written permission is granted by the corresponding
* Copyright Holder. This restriction only applies to the primary font name as
* presented to the users.
*
* 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
* Software shall not be used to promote, endorse or advertise any
* Modified Version, except to acknowledge the contribution(s) of the
* Copyright Holder(s) and the Author(s) or with their explicit written
* permission.
*
* 5) The Font Software, modified or unmodified, in part or in whole,
* must be distributed entirely under this license, and must not be
* distributed under any other license. The requirement for fonts to
* remain under this license does not apply to any document created
* using the Font Software.
*
* TERMINATION
* This license becomes null and void if any of the above conditions are
* not met.
*
* DISCLAIMER
* THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
* OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
* DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
* OTHER DEALINGS IN THE FONT SOFTWARE.
*/
+683
View File
@@ -0,0 +1,683 @@
/*
* "Darkfish" RDoc CSS
* $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $
*
* Author: Michael Granger <ged@FaerieMUD.org>
*
*/
/* vim: ft=css et sw=2 ts=2 sts=2 */
/* 1. Variables and Root Styles */
:root {
--sidebar-width: 300px;
--highlight-color: #cc342d; /* Reddish color for accents and headings */
--secondary-highlight-color: #c83045; /* Darker reddish color for secondary highlights */
--text-color: #505050; /* Dark bluish-grey for text */
--background-color: #fefefe; /* Near white background */
--code-block-background-color: #f6f6f3; /* Slightly darker grey for code blocks */
--link-color: #42405F; /* Dark bluish-grey for links */
--link-hover-color: var(--highlight-color); /* Reddish color on hover */
--border-color: #e0e0e0;; /* General border color */
--source-code-toggle-color: var(--secondary-highlight-color);
--scrollbar-thumb-hover-background: #505050; /* Hover color for scrollbar thumb */
--table-header-background-color: #eceaed;
--table-td-background-color: #f5f4f6;
/* Font family variables */
--font-primary: 'Segoe UI', 'Verdana', 'Arial', sans-serif;
--font-heading: 'Helvetica', 'Arial', sans-serif;
--font-code: monospace;
}
/* 2. Global Styles */
body {
background: var(--background-color);
font-family: var(--font-primary);
font-weight: 400;
color: var(--text-color);
line-height: 1.6;
/* Layout */
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
}
/* 3. Typography */
h1 span,
h2 span,
h3 span,
h4 span,
h5 span,
h6 span {
position: relative;
display: none;
padding-left: 1em;
line-height: 0;
vertical-align: baseline;
font-size: 10px;
}
h1 span { top: -1.3em; }
h2 span { top: -1.2em; }
h3 span { top: -1.0em; }
h4 span { top: -0.8em; }
h5 span { top: -0.5em; }
h6 span { top: -0.5em; }
h1:hover span,
h2:hover span,
h3:hover span,
h4:hover span,
h5:hover span,
h6:hover span {
display: inline;
}
h1:target,
h2:target,
h3:target,
h4:target,
h5:target,
h6:target {
margin-left: -10px;
border-left: 10px solid var(--border-color);
scroll-margin-top: 1rem;
}
main .anchor-link:target {
scroll-margin-top: 1rem;
}
/* 4. Links */
a {
color: var(--link-color);
transition: color 0.3s ease;
text-decoration: underline;
text-underline-offset: 0.2em; /* Make sure it doesn't overlap with underscores in a method name. */
}
a:hover {
color: var(--link-hover-color);
}
a code:hover {
color: var(--link-hover-color);
}
/* 5. Code and Pre */
code,
pre {
font-family: var(--font-code);
background-color: var(--code-block-background-color);
border: 1px solid var(--border-color);
border-radius: 6px;
padding: 16px;
overflow-x: auto;
font-size: 15px;
line-height: 1.5;
margin: 1em 0;
}
code {
background-color: var(--code-block-background-color);
padding: 0.1em 0.3em;
border-radius: 3px;
font-size: 85%;
}
/* Tables */
table {
margin: 0;
border-spacing: 0;
border-collapse: collapse;
}
table tr th, table tr td {
padding: 0.2em 0.4em;
border: 1px solid var(--border-color);
}
table tr th {
background-color: var(--table-header-background-color);
}
table tr:nth-child(even) td {
background-color: var(--table-td-background-color);
}
/* 7. Navigation and Sidebar */
nav {
font-family: var(--font-heading);
font-size: 16px;
border-right: 1px solid var(--border-color);
position: fixed;
top: 0;
bottom: 0;
left: 0;
width: var(--sidebar-width);
background: var(--background-color); /* It needs an explicit background for toggling narrow screens */
overflow-y: auto;
z-index: 10;
display: flex;
flex-direction: column;
color: var(--text-color);
}
nav[hidden] {
display: none;
}
nav footer {
padding: 1em;
border-top: 1px solid var(--border-color);
}
nav footer a {
color: var(--secondary-highlight-color);
}
nav .nav-section {
margin-top: 1em;
padding: 0 1em;
}
nav h2, nav h3 {
margin: 0 0 0.5em;
padding: 0.5em 0;
color: var(--highlight-color);
border-bottom: 1px solid var(--border-color);
}
nav h2 {
font-size: 1.2em;
}
nav h3,
#table-of-contents-navigation {
font-size: 1em;
}
ol.breadcrumb {
display: flex;
padding: 0;
margin: 0 0 1em;
}
ol.breadcrumb li {
display: block;
list-style: none;
font-size: 125%;
}
nav ul,
nav dl,
nav p {
padding: 0;
list-style: none;
margin: 0.5em 0;
}
nav ul li {
margin-bottom: 0.3em;
}
nav ul ul {
padding-left: 1em;
}
nav ul ul ul {
padding-left: 1em;
}
nav ul ul ul ul {
padding-left: 1em;
}
nav a {
color: var(--link-color);
text-decoration: none;
}
nav a:hover {
color: var(--link-hover-color);
text-decoration: underline;
}
#navigation-toggle {
z-index: 1000;
font-size: 2em;
display: block;
position: fixed;
top: 10px;
left: 20px;
cursor: pointer;
}
#navigation-toggle[aria-expanded="true"] {
top: 10px;
left: 250px;
}
nav ul li details {
position: relative;
padding-right: 1.5em; /* Add space for the marker on the right */
}
nav ul li details > summary {
list-style: none; /* Remove the default marker */
position: relative; /* So that the open/close triangle can position itself absolutely inside */
}
nav ul li details > summary::-webkit-details-marker {
display: none; /* Removes the default marker, in Safari 18. */
}
nav ul li details > summary::after {
content: '▶'; /* Unicode right-pointing triangle */
position: absolute;
font-size: 0.8em;
bottom: 0.1em;
margin-left: 0.3em;
transition: transform 0.2s ease;
}
nav ul li details[open] > summary::after {
transform: rotate(90deg); /* Rotate the triangle when open */
}
/* 8. Main Content */
main {
flex: 1;
display: block;
margin: 3em auto;
padding: 0 2em;
max-width: 800px;
font-size: 16px;
line-height: 1.6;
color: var(--text-color);
box-sizing: border-box;
}
@media (min-width: 1024px) {
main {
margin-left: var(--sidebar-width);
}
.table-of-contents main {
margin-left: 20em;
}
#navigation-toggle {
display: none;
}
}
main h1[class] {
margin-top: 0;
margin-bottom: 1em;
font-size: 2.5em;
color: var(--highlight-color);
}
main h1,
main h2,
main h3,
main h4,
main h5,
main h6 {
font-family: var(--font-heading);
color: var(--highlight-color);
}
/* Search */
#search-section {
padding: 1em;
background-color: var(--background-color);
border-bottom: 1px solid var(--border-color);
}
#search-field-wrapper {
position: relative;
display: flex;
align-items: center;
}
#search-field {
width: 100%;
padding: 0.5em 1em 0.5em 2.5em;
border: 1px solid var(--border-color);
border-radius: 20px;
font-size: 14px;
outline: none;
transition: border-color 0.3s ease;
color: var(--text-color);
}
#search-field:focus {
border-color: var(--highlight-color);
}
#search-field::placeholder {
color: var(--text-color);
}
#search-field-wrapper::before {
content: "\1F50D";
position: absolute;
left: 0.75em;
top: 50%;
transform: translateY(-50%);
font-size: 14px;
color: var(--text-color);
opacity: 0.6;
}
/* Search Results */
#search-results {
font-family: var(--font-primary);
font-weight: 300;
}
#search-results .search-match {
font-family: var(--font-heading);
font-weight: normal;
}
#search-results .search-selected {
background: var(--code-block-background-color);
border-bottom: 1px solid transparent;
}
#search-results li {
list-style: none;
border-bottom: 1px solid var(--border-color);
margin-bottom: 0.5em;
}
#search-results li:last-child {
border-bottom: none;
margin-bottom: 0;
}
#search-results li p {
padding: 0;
margin: 0.5em;
}
#search-results .search-namespace {
font-weight: bold;
}
#search-results li em {
background-color: rgba(224, 108, 117, 0.1);
font-style: normal;
}
#search-results pre {
margin: 0.5em;
font-family: var(--font-code);
}
/* Syntax Highlighting - Gruvbox Light Scheme */
.ruby-constant { color: #AF3A03; } /* Dark Orange */
.ruby-keyword { color: #9D0006; } /* Dark Red */
.ruby-ivar { color: #B57614; } /* Brown */
.ruby-operator { color: #427B58; } /* Dark Teal */
.ruby-identifier { color: #076678; } /* Deep Teal */
.ruby-node { color: #8F3F71; } /* Plum */
.ruby-comment { color: #928374; font-style: italic; } /* Gray */
.ruby-regexp { color: #8F3F71; } /* Plum */
.ruby-value { color: #AF3A03; } /* Dark Orange */
.ruby-string { color: #79740E; } /* Olive */
/* Emphasis */
em {
text-decoration-color: rgba(52, 48, 64, 0.25);
text-decoration-line: underline;
text-decoration-style: dotted;
}
strong,
em {
color: var(--highlight-color);
background-color: rgba(255, 111, 97, 0.1); /* Light red background for emphasis */
}
/* Paragraphs */
main p {
line-height: 1.5em;
font-weight: 400;
}
/* Preformatted Text */
main pre {
margin: 1.2em 0.5em;
padding: 1em;
font-size: 0.8em;
}
/* Horizontal Rules */
main hr {
margin: 1.5em 1em;
border: 2px solid var(--border-color);
}
/* Blockquotes */
main blockquote {
margin: 0 2em 1.2em 1.2em;
padding-left: 0.5em;
border-left: 2px solid var(--border-color);
}
/* Lists */
main li > p {
margin: 0.5em;
}
/* Definition Lists */
main dl {
margin: 1em 0.5em;
}
main dt {
line-height: 1.5; /* matches `main p` */
font-weight: bold;
}
main dl.note-list dt {
margin-right: 1em;
float: left;
}
main dl.note-list dt:has(+ dt) {
margin-right: 0.25em;
}
main dl.note-list dt:has(+ dt)::after {
content: ', ';
font-weight: normal;
}
main dd {
margin: 0 0 1em 1em;
}
main dd p:first-child {
margin-top: 0;
}
/* Headers within Main */
main header h2 {
margin-top: 2em;
border-width: 0;
border-top: 4px solid var(--border-color);
font-size: 130%;
}
main header h3 {
margin: 2em 0 1.5em;
border-width: 0;
border-top: 3px solid var(--border-color);
font-size: 120%;
}
/* Utility Classes */
.hide { display: none !important; }
.initially-hidden { display: none; }
/* Table of Contents */
.table-of-contents ul {
margin: 1em;
list-style: none;
}
.table-of-contents ul ul {
margin-top: 0.25em;
}
.table-of-contents ul :link,
.table-of-contents ul :visited {
font-size: 16px;
}
.table-of-contents li {
margin-bottom: 0.25em;
}
/* Method Details */
main .method-source-code {
visibility: hidden;
max-height: 0;
overflow: auto;
transition-duration: 200ms;
transition-delay: 0ms;
transition-property: all;
transition-timing-function: ease-in-out;
}
main .method-source-code pre {
border-color: var(--source-code-toggle-color);
}
main .method-source-code.active-menu {
visibility: visible;
max-height: 100vh;
}
main .method-description .method-calls-super {
color: var(--text-color);
font-weight: bold;
}
main .method-detail {
margin-bottom: 2.5em;
}
main .method-detail:target {
margin-left: -10px;
border-left: 10px solid var(--border-color);
}
main .method-header {
display: inline-block;
}
main .method-heading {
position: relative;
font-family: var(--font-code);
font-size: 110%;
font-weight: bold;
}
main .method-heading::after {
content: '¶';
position: absolute;
visibility: hidden;
color: var(--highlight-color);
font-size: 0.5em;
}
main .method-heading:hover::after {
visibility: visible;
}
main .method-controls {
line-height: 20px;
float: right;
color: var(--source-code-toggle-color);
cursor: pointer;
}
main .method-description,
main .aliases {
margin-top: 0.75em;
color: var(--text-color);
}
main .aliases {
padding-top: 4px;
font-style: italic;
cursor: default;
}
main .aliases a {
color: var(--secondary-highlight-color);
}
main .mixin-from {
font-size: 80%;
font-style: italic;
margin-bottom: 0.75em;
}
main .method-description ul {
margin-left: 1.5em;
}
main #attribute-method-details .method-detail:hover {
background-color: transparent;
cursor: default;
}
main .attribute-access-type {
text-transform: uppercase;
}
/* Responsive Adjustments */
@media (max-width: 480px) {
nav {
width: 100%;
}
main {
margin: 1em auto;
padding: 0 1em;
max-width: 100%;
}
#navigation-toggle {
right: 10px;
left: auto;
}
#navigation-toggle[aria-expanded="true"] {
left: auto;
}
table {
display: block;
overflow-x: auto;
white-space: nowrap;
}
main .method-controls {
margin-top: 10px;
float: none;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

+95
View File
@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>RDoc Documentation</title>
<meta name="keywords" content="ruby,documentation,RDoc Documentation">
<meta name="description" content="Documentation for RDoc Documentation">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="file">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>
<ul class="link-list">
<li><a href="./README_md.html">README</a>
</ul>
</div>
<div id="classindex-section" class="nav-section">
<h3>Class and Module Index</h3>
<ul class="link-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>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main">
<p>This is the API documentation for RDoc Documentation.
</main>
+120
View File
@@ -0,0 +1,120 @@
/**
*
* Darkfish Page Functions
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
*
* Author: Michael Granger <mgranger@laika.com>
*
*/
/* Provide console simulation for firebug-less environments */
/*
if (!("console" in window) || !("firebug" in console)) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {};
};
*/
function showSource( e ) {
var target = e.target;
while (!target.classList.contains('method-detail')) {
target = target.parentNode;
}
if (typeof target !== "undefined" && target !== null) {
target = target.querySelector('.method-source-code');
}
if (typeof target !== "undefined" && target !== null) {
target.classList.toggle('active-menu')
}
};
function hookSourceViews() {
document.querySelectorAll('.method-source-toggle').forEach(function (codeObject) {
codeObject.addEventListener('click', showSource);
});
};
function hookSearch() {
var input = document.querySelector('#search-field');
var result = document.querySelector('#search-results');
result.classList.remove("initially-hidden");
var search_section = document.querySelector('#search-section');
search_section.classList.remove("initially-hidden");
var search = new Search(search_data, input, result);
search.renderItem = function(result) {
var li = document.createElement('li');
var html = '';
// TODO add relative path to <script> per-page
html += '<p class="search-match"><a href="' + index_rel_prefix + this.escapeHTML(result.path) + '">' + this.hlt(result.title);
if (result.params)
html += '<span class="params">' + result.params + '</span>';
html += '</a>';
if (result.namespace)
html += '<p class="search-namespace">' + this.hlt(result.namespace);
if (result.snippet)
html += '<div class="search-snippet">' + result.snippet + '</div>';
li.innerHTML = html;
return li;
}
search.select = function(result) {
window.location.href = result.firstChild.firstChild.href;
}
search.scrollIntoView = search.scrollInWindow;
};
function hookFocus() {
document.addEventListener("keydown", (event) => {
if (document.activeElement.tagName === 'INPUT') {
return;
}
if (event.key === "/") {
event.preventDefault();
document.querySelector('#search-field').focus();
}
});
}
function hookSidebar() {
var navigation = document.querySelector('#navigation');
var navigationToggle = document.querySelector('#navigation-toggle');
navigationToggle.addEventListener('click', function() {
navigation.hidden = !navigation.hidden;
navigationToggle.ariaExpanded = navigationToggle.ariaExpanded !== 'true';
});
var isSmallViewport = window.matchMedia("(max-width: 1023px)").matches;
if (isSmallViewport) {
navigation.hidden = true;
navigationToggle.ariaExpanded = false;
document.addEventListener('click', (e) => {
if (e.target.closest('#navigation a')) {
navigation.hidden = true;
navigationToggle.ariaExpanded = false;
}
});
}
}
document.addEventListener('DOMContentLoaded', function() {
hookSourceViews();
hookSearch();
hookFocus();
hookSidebar();
});
+105
View File
@@ -0,0 +1,105 @@
/*
* Navigation allows movement using the arrow keys through the search results.
*
* When using this library you will need to set scrollIntoView to the
* appropriate function for your layout. Use scrollInWindow if the container
* is not scrollable and scrollInElement if the container is a separate
* scrolling region.
*/
Navigation = new function() {
this.initNavigation = function() {
var _this = this;
document.addEventListener('keydown', function(e) {
_this.onkeydown(e);
});
this.navigationActive = true;
}
this.setNavigationActive = function(state) {
this.navigationActive = state;
}
this.onkeydown = function(e) {
if (!this.navigationActive) return;
switch(e.key) {
case 'ArrowLeft':
if (this.moveLeft()) e.preventDefault();
break;
case 'ArrowUp':
if (e.key == 'ArrowUp' || e.ctrlKey) {
if (this.moveUp()) e.preventDefault();
}
break;
case 'ArrowRight':
if (this.moveRight()) e.preventDefault();
break;
case 'ArrowDown':
if (e.key == 'ArrowDown' || e.ctrlKey) {
if (this.moveDown()) e.preventDefault();
}
break;
case 'Enter':
if (this.current) e.preventDefault();
this.select(this.current);
break;
}
if (e.ctrlKey && e.shiftKey) this.select(this.current);
}
this.moveRight = function() {
}
this.moveLeft = function() {
}
this.move = function(isDown) {
}
this.moveUp = function() {
return this.move(false);
}
this.moveDown = function() {
return this.move(true);
}
/*
* Scrolls to the given element in the scrollable element view.
*/
this.scrollInElement = function(element, view) {
var offset, viewHeight, viewScroll, height;
offset = element.offsetTop;
height = element.offsetHeight;
viewHeight = view.offsetHeight;
viewScroll = view.scrollTop;
if (offset - viewScroll + height > viewHeight) {
view.scrollTop = offset - viewHeight + height;
}
if (offset < viewScroll) {
view.scrollTop = offset;
}
}
/*
* Scrolls to the given element in the window. The second argument is
* ignored
*/
this.scrollInWindow = function(element, ignored) {
var offset, viewHeight, viewScroll, height;
offset = element.offsetTop;
height = element.offsetHeight;
viewHeight = window.innerHeight;
viewScroll = window.scrollY;
if (offset - viewScroll + height > viewHeight) {
window.scrollTo(window.scrollX, offset - viewHeight + height);
}
if (offset < viewScroll) {
window.scrollTo(window.scrollX, offset);
}
}
}
Binary file not shown.
+110
View File
@@ -0,0 +1,110 @@
Search = function(data, input, result) {
this.data = data;
this.input = input;
this.result = result;
this.current = null;
this.view = this.result.parentNode;
this.searcher = new Searcher(data.index);
this.init();
}
Search.prototype = Object.assign({}, Navigation, new function() {
var suid = 1;
this.init = function() {
var _this = this;
var observer = function(e) {
switch(e.key) {
case 'ArrowUp':
case 'ArrowDown':
return;
}
_this.search(_this.input.value);
};
this.input.addEventListener('keyup', observer);
this.input.addEventListener('click', observer); // mac's clear field
this.searcher.ready(function(results, isLast) {
_this.addResults(results, isLast);
})
this.initNavigation();
this.setNavigationActive(false);
}
this.search = function(value, selectFirstMatch) {
value = value.trim().toLowerCase();
if (value) {
this.setNavigationActive(true);
} else {
this.setNavigationActive(false);
}
if (value == '') {
this.lastQuery = value;
this.result.innerHTML = '';
this.result.setAttribute('aria-expanded', 'false');
this.setNavigationActive(false);
} else if (value != this.lastQuery) {
this.lastQuery = value;
this.result.setAttribute('aria-busy', 'true');
this.result.setAttribute('aria-expanded', 'true');
this.firstRun = true;
this.searcher.find(value);
}
}
this.addResults = function(results, isLast) {
var target = this.result;
if (this.firstRun && (results.length > 0 || isLast)) {
this.current = null;
this.result.innerHTML = '';
}
for (var i=0, l = results.length; i < l; i++) {
var item = this.renderItem.call(this, results[i]);
item.setAttribute('id', 'search-result-' + target.childElementCount);
target.appendChild(item);
};
if (this.firstRun && results.length > 0) {
this.firstRun = false;
this.current = target.firstChild;
this.current.classList.add('search-selected');
}
//TODO: ECMAScript
//if (jQuery.browser.msie) this.$element[0].className += '';
if (isLast) this.result.setAttribute('aria-busy', 'false');
}
this.move = function(isDown) {
if (!this.current) return;
var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
if (next) {
this.current.classList.remove('search-selected');
next.classList.add('search-selected');
this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
this.scrollIntoView(next, this.view);
this.current = next;
this.input.value = next.firstChild.firstChild.text;
this.input.select();
}
return true;
}
this.hlt = function(html) {
return this.escapeHTML(html).
replace(/\u0001/g, '<em>').
replace(/\u0002/g, '</em>');
}
this.escapeHTML = function(html) {
return html.replace(/[&<>"`']/g, function(c) {
return '&#' + c.charCodeAt(0) + ';';
});
}
});
+1
View File
@@ -0,0 +1 @@
var search_data = {"index":{"searchIndex":["card","deck","game","player","terminalui","add_point()","change_dealer()","choose_card()","clear_hand()","deal()","debug_game()","determine_dealer()","display_trick_winner()","display_wrong_card()","draw()","game_winner()","new()","new()","new()","new()","other_player()","play()","play()","play_trick()","receive()","shuffle()","stock()","strength()","to_s()","valid_follow_card?()","readme"],"longSearchIndex":["card","deck","game","player","terminalui","player#add_point()","game#change_dealer()","terminalui#choose_card()","player#clear_hand()","game#deal()","terminalui#debug_game()","game#determine_dealer()","terminalui#display_trick_winner()","terminalui#display_wrong_card()","deck#draw()","game#game_winner()","card::new()","deck::new()","game::new()","player::new()","game#other_player()","game#play()","player#play()","game#play_trick()","player#receive()","deck#shuffle()","game#stock()","card#strength()","card#to_s()","game#valid_follow_card?()",""],"info":[["Card","","Card.html","","<p>Représente une carte à jouer avec sa valeur et sa couleur.\n"],["Deck","","Deck.html","","<p>Représente un paquet de cartes et gère son contenu.\n"],["Game","","Game.html","","<p>Gère le déroulement et les règles d’une partie d’Écarté.\n"],["Player","","Player.html","","<p>Représente un joueur, sa main et son score.\n"],["TerminalUI","","TerminalUI.html","","<p>Gère l’affichage et les saisies dans le terminal.\n"],["add_point","Player","Player.html#method-i-add_point","()","<p>Ajoute un point au joueur.\n"],["change_dealer","Game","Game.html#method-i-change_dealer","()","<p>Échange les rôles de donneur et de non-donneur.\n"],["choose_card","TerminalUI","TerminalUI.html#method-i-choose_card","(player)","<p>Demande au joueur de choisir une carte et la retourne.\n"],["clear_hand","Player","Player.html#method-i-clear_hand","()","<p>Vide la main du joueur.\n"],["deal","Game","Game.html#method-i-deal","()","<p>Distribue les cartes et pose la retourne.\n"],["debug_game","TerminalUI","TerminalUI.html#method-i-debug_game","(game)","<p>Affiche les informations de débogage.\n"],["determine_dealer","Game","Game.html#method-i-determine_dealer","()","<p>Simule une coupe pour déterminer quel joueur sera le donneur.\n"],["display_trick_winner","TerminalUI","TerminalUI.html#method-i-display_trick_winner","(player)","<p>Affiche le joueur ayant remporté le pli.\n"],["display_wrong_card","TerminalUI","TerminalUI.html#method-i-display_wrong_card","()","<p>Affiche un avertissement si le coup joué ne respecte pas les règles.\n"],["draw","Deck","Deck.html#method-i-draw","()","<p>Retire et retourne la dernière carte du paquet.\n"],["game_winner","Game","Game.html#method-i-game_winner","()","<p>Retourne le joueur ayant le meilleur score.\n"],["new","Card","Card.html#method-c-new","(value, suit)",""],["new","Deck","Deck.html#method-c-new","()",""],["new","Game","Game.html#method-c-new","(player_name1, player_name2)",""],["new","Player","Player.html#method-c-new","(name)",""],["other_player","Game","Game.html#method-i-other_player","(player)","<p>Retourne l’autre joueur.\n"],["play","Game","Game.html#method-i-play","()","<p>Joue une partie.\n"],["play","Player","Player.html#method-i-play","(card)","<p>Retire une carte de la main du joueur.\n"],["play_trick","Game","Game.html#method-i-play_trick","(lead_player, follow_player)","<p>Joue un pli.\n"],["receive","Player","Player.html#method-i-receive","(card)","<p>Ajoute une carte à la main du joueur.\n"],["shuffle","Deck","Deck.html#method-i-shuffle","()","<p>Mélange les cartes du paquet.\n"],["stock","Game","Game.html#method-i-stock","()","<p>Retourne les cartes restantes dans le talon.\n"],["strength","Card","Card.html#method-i-strength","()","<p>Retourne la force de la carte sous forme d’integer.\n"],["to_s","Card","Card.html#method-i-to_s","()","<p>Retourne une représentation de la carte sous forme de string.\n"],["valid_follow_card?","Game","Game.html#method-i-valid_follow_card-3F","(follow_player, lead_card, follow_card)","<p>Vérifie si le coup du second joueur respecte les règles.\n"],["README","","README_md.html","","<p>Écarté\n"]]}}
Binary file not shown.
+229
View File
@@ -0,0 +1,229 @@
Searcher = function(data) {
this.data = data;
this.handlers = [];
}
Searcher.prototype = new function() {
// search is performed in chunks of 1000 for non-blocking user input
var CHUNK_SIZE = 1000;
// do not try to find more than 100 results
var MAX_RESULTS = 100;
var huid = 1;
var suid = 1;
var runs = 0;
this.find = function(query) {
var queries = splitQuery(query);
var regexps = buildRegexps(queries);
var highlighters = buildHilighters(queries);
var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
var _this = this;
this.currentSuid = state.n;
if (!query) return;
var run = function() {
// stop current search thread if new search started
if (state.n != _this.currentSuid) return;
var results =
performSearch(_this.data, regexps, queries, highlighters, state);
var hasMore = (state.limit > 0 && state.pass < 4);
triggerResults.call(_this, results, !hasMore);
if (hasMore) {
setTimeout(run, 2);
}
runs++;
};
runs = 0;
// start search thread
run();
}
/* ----- Events ------ */
this.ready = function(fn) {
fn.huid = huid;
this.handlers.push(fn);
}
/* ----- Utilities ------ */
function splitQuery(query) {
return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
return string.match(/\S/);
});
}
function buildRegexps(queries) {
return queries.map(function(query) {
return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
});
}
function buildHilighters(queries) {
return queries.map(function(query) {
return query.split('').map(function(l, i) {
return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
}).join('');
});
}
// function longMatchRegexp(index, longIndex, regexps) {
// for (var i = regexps.length - 1; i >= 0; i--){
// if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
// };
// return true;
// }
/* ----- Mathchers ------ */
/*
* This record matches if the index starts with queries[0] and the record
* matches all of the regexps
*/
function matchPassBeginning(index, longIndex, queries, regexps) {
if (index.indexOf(queries[0]) != 0) return false;
for (var i=1, l = regexps.length; i < l; i++) {
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
return false;
};
return true;
}
/*
* This record matches if the longIndex starts with queries[0] and the
* longIndex matches all of the regexps
*/
function matchPassLongIndex(index, longIndex, queries, regexps) {
if (longIndex.indexOf(queries[0]) != 0) return false;
for (var i=1, l = regexps.length; i < l; i++) {
if (!longIndex.match(regexps[i]))
return false;
};
return true;
}
/*
* This record matches if the index contains queries[0] and the record
* matches all of the regexps
*/
function matchPassContains(index, longIndex, queries, regexps) {
if (index.indexOf(queries[0]) == -1) return false;
for (var i=1, l = regexps.length; i < l; i++) {
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
return false;
};
return true;
}
/*
* This record matches if regexps[0] matches the index and the record
* matches all of the regexps
*/
function matchPassRegexp(index, longIndex, queries, regexps) {
if (!index.match(regexps[0])) return false;
for (var i=1, l = regexps.length; i < l; i++) {
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
return false;
};
return true;
}
/* ----- Highlighters ------ */
function highlightRegexp(info, queries, regexps, highlighters) {
var result = createResult(info);
for (var i=0, l = regexps.length; i < l; i++) {
result.title = result.title.replace(regexps[i], highlighters[i]);
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
};
return result;
}
function hltSubstring(string, pos, length) {
return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
}
function highlightQuery(info, queries, regexps, highlighters) {
var result = createResult(info);
var pos = 0;
var lcTitle = result.title.toLowerCase();
pos = lcTitle.indexOf(queries[0]);
if (pos != -1) {
result.title = hltSubstring(result.title, pos, queries[0].length);
}
result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
for (var i=1, l = regexps.length; i < l; i++) {
result.title = result.title.replace(regexps[i], highlighters[i]);
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
};
return result;
}
function createResult(info) {
var result = {};
result.title = info[0];
result.namespace = info[1];
result.path = info[2];
result.params = info[3];
result.snippet = info[4];
result.badge = info[6];
return result;
}
/* ----- Searching ------ */
function performSearch(data, regexps, queries, highlighters, state) {
var searchIndex = data.searchIndex;
var longSearchIndex = data.longSearchIndex;
var info = data.info;
var result = [];
var i = state.from;
var l = searchIndex.length;
var togo = CHUNK_SIZE;
var matchFunc, hltFunc;
while (state.pass < 4 && state.limit > 0 && togo > 0) {
if (state.pass == 0) {
matchFunc = matchPassBeginning;
hltFunc = highlightQuery;
} else if (state.pass == 1) {
matchFunc = matchPassLongIndex;
hltFunc = highlightQuery;
} else if (state.pass == 2) {
matchFunc = matchPassContains;
hltFunc = highlightQuery;
} else if (state.pass == 3) {
matchFunc = matchPassRegexp;
hltFunc = highlightRegexp;
}
for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
if (info[i].n == state.n) continue;
if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
info[i].n = state.n;
result.push(hltFunc(info[i], queries, regexps, highlighters));
state.limit--;
}
};
if (searchIndex.length <= i) {
state.pass++;
i = state.from = 0;
} else {
state.from = i;
}
}
return result;
}
function triggerResults(results, isLast) {
this.handlers.forEach(function(fn) {
fn.call(this, results, isLast)
});
}
}
Binary file not shown.
+237
View File
@@ -0,0 +1,237 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Table of Contents - RDoc Documentation</title>
<meta name="keywords" content="ruby,documentation,Table of Contents - RDoc Documentation">
<meta name="description" content="Documentation for Table of Contents - RDoc Documentation">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" class="table-of-contents">
<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">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.14.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
</nav>
<main role="main">
<h1 class="class">Table of Contents - RDoc Documentation</h1>
<h2 id="pages">Pages</h2>
<ul>
<li class="file">
<a href="README_md.html">README</a>
<ul>
<li><a href="README_md.html#label-C3-89cart-C3-A9">Écarté</a>
</ul>
</li>
</ul>
<h2 id="classes">Classes and Modules</h2>
<ul>
<li class="class">
<a href="Card.html">Card</a>
</li>
<li class="class">
<a href="Deck.html">Deck</a>
</li>
<li class="class">
<a href="Game.html">Game</a>
</li>
<li class="class">
<a href="Player.html">Player</a>
</li>
<li class="class">
<a href="TerminalUI.html">TerminalUI</a>
</li>
</ul>
<h2 id="methods">Methods</h2>
<ul>
<li class="method">
<a href="Card.html#method-c-new">::new</a>
&mdash;
<span class="container">Card</span>
<li class="method">
<a href="Deck.html#method-c-new">::new</a>
&mdash;
<span class="container">Deck</span>
<li class="method">
<a href="Game.html#method-c-new">::new</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Player.html#method-c-new">::new</a>
&mdash;
<span class="container">Player</span>
<li class="method">
<a href="Player.html#method-i-add_point">#add_point</a>
&mdash;
<span class="container">Player</span>
<li class="method">
<a href="Game.html#method-i-change_dealer">#change_dealer</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="TerminalUI.html#method-i-choose_card">#choose_card</a>
&mdash;
<span class="container">TerminalUI</span>
<li class="method">
<a href="Player.html#method-i-clear_hand">#clear_hand</a>
&mdash;
<span class="container">Player</span>
<li class="method">
<a href="Game.html#method-i-deal">#deal</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="TerminalUI.html#method-i-debug_game">#debug_game</a>
&mdash;
<span class="container">TerminalUI</span>
<li class="method">
<a href="Game.html#method-i-determine_dealer">#determine_dealer</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="TerminalUI.html#method-i-display_trick_winner">#display_trick_winner</a>
&mdash;
<span class="container">TerminalUI</span>
<li class="method">
<a href="TerminalUI.html#method-i-display_wrong_card">#display_wrong_card</a>
&mdash;
<span class="container">TerminalUI</span>
<li class="method">
<a href="Deck.html#method-i-draw">#draw</a>
&mdash;
<span class="container">Deck</span>
<li class="method">
<a href="Game.html#method-i-game_winner">#game_winner</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Game.html#method-i-other_player">#other_player</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Game.html#method-i-play">#play</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Player.html#method-i-play">#play</a>
&mdash;
<span class="container">Player</span>
<li class="method">
<a href="Game.html#method-i-play_trick">#play_trick</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Player.html#method-i-receive">#receive</a>
&mdash;
<span class="container">Player</span>
<li class="method">
<a href="Deck.html#method-i-shuffle">#shuffle</a>
&mdash;
<span class="container">Deck</span>
<li class="method">
<a href="Game.html#method-i-stock">#stock</a>
&mdash;
<span class="container">Game</span>
<li class="method">
<a href="Card.html#method-i-strength">#strength</a>
&mdash;
<span class="container">Card</span>
<li class="method">
<a href="Card.html#method-i-to_s">#to_s</a>
&mdash;
<span class="container">Card</span>
<li class="method">
<a href="Game.html#method-i-valid_follow_card-3F">#valid_follow_card?</a>
&mdash;
<span class="container">Game</span>
</ul>
</main>
+3
View File
@@ -1,3 +1,4 @@
# Représente une carte à jouer avec sa valeur et sa couleur.
class Card
attr_reader :value, :suit
@@ -6,10 +7,12 @@ class Card
@suit = suit
end
# Retourne une représentation de la carte sous forme de string.
def to_s
"#{@value} of #{@suit}"
end
# Retourne la force de la carte sous forme d'integer.
def strength
if @value.match?(/\A\d+\z/)
@value.to_i
+3
View File
@@ -1,5 +1,6 @@
require_relative "card"
# Représente un paquet de cartes et gère son contenu.
class Deck
attr_reader :cards
@@ -15,10 +16,12 @@ class Deck
end
end
# Mélange les cartes du paquet.
def shuffle
@cards.shuffle!
end
# Retire et retourne la dernière carte du paquet.
def draw
@cards.pop
end
+12 -2
View File
@@ -2,6 +2,7 @@ require_relative "deck"
require_relative "player"
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
@@ -18,6 +19,7 @@ class Game
@ui = TerminalUI.new
end
# Simule une coupe pour déterminer quel joueur sera le donneur.
def determine_dealer
@deck.shuffle
@@ -35,12 +37,14 @@ class Game
end
end
# Échange les rôles de donneur et de non-donneur.
def change_dealer
old_dealer = @dealer
@dealer = @non_dealer
@non_dealer = old_dealer
end
# Distribue les cartes et pose la retourne.
def deal
@player1.clear_hand
@player2.clear_hand
@@ -56,10 +60,12 @@ class Game
@trump_suit = @upcard.suit
end
# Retourne les cartes restantes dans le talon.
def stock
@deck.cards
end
# 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
@@ -70,6 +76,7 @@ class Game
end
end
# Joue un pli.
def play_trick(lead_player, follow_player)
lead_card = @ui.choose_card(lead_player)
follow_card = @ui.choose_card(follow_player)
@@ -94,10 +101,12 @@ class Game
@ui.display_trick_winner(@trick_winner)
end
# Retourne l'autre joueur.
def other_player(player)
player == @player1 ? @player2 : @player1
end
# Joue une partie.
def play
lead_player = @non_dealer
follow_player = @dealer
@@ -105,11 +114,12 @@ class Game
5.times do
play_trick(lead_player, follow_player)
lead_player = @trick_winner
follow_player = other_player(lead_player)
lead_player = @trick_winner
follow_player = other_player(lead_player)
end
end
# Retourne le joueur ayant le meilleur score.
def game_winner
if @player1.score > @player2.score
@player1
+5
View File
@@ -1,3 +1,4 @@
# Représente un joueur, sa main et son score.
class Player
attr_reader :name, :hand, :score
@@ -7,18 +8,22 @@ class Player
@score = 0
end
# Ajoute une carte à la main du joueur.
def receive(card)
@hand << card
end
# Vide la main du joueur.
def clear_hand
@hand.clear
end
# Retire une carte de la main du joueur.
def play(card)
@hand.delete(card)
end
# Ajoute un point au joueur.
def add_point
@score += 1
end
+6
View File
@@ -1,4 +1,7 @@
# Gère l'affichage et les saisies dans le terminal.
class TerminalUI
# Demande au joueur de choisir une carte et la retourne.
def choose_card(player)
player.hand.each_with_index do |card, index|
puts "#{index + 1}. #{card}"
@@ -10,15 +13,18 @@ class TerminalUI
player.hand[choice - 1]
end
# Affiche un avertissement si le coup joué ne respecte pas les règles.
def display_wrong_card
puts "You cannot play this card."
end
# Affiche le joueur ayant remporté le pli.
def display_trick_winner(player)
puts "#{player.name} wins the trick."
puts
end
# Affiche les informations de débogage.
def debug_game(game)
puts "Dealer: #{game.dealer.name}"
puts "Non-dealer: #{game.non_dealer.name}"
+1 -15
View File
@@ -1,24 +1,10 @@
#!/usr/bin/env ruby
require_relative "lib/game"
require_relative "lib/terminal_ui"
# Instance du jeu
# Crée une partie.
game = Game.new("Alice", "Bob")
ui = TerminalUI.new
game.determine_dealer
game.deal
# Première manche
ui.debug_game(game)
game.play
# Nouvelle manche
# game.change_dealer
# game.deal
# ui.debug_game(game)
# card = ui.choose_card(game.player1)
# puts "#{game.player1.name} chose #{card}."