diff --git a/frontend/js/game.js b/frontend/js/game.js index fcf5286..f0d757e 100644 --- a/frontend/js/game.js +++ b/frontend/js/game.js @@ -7,6 +7,10 @@ class Hand { this.sort(); } + setDraw(t) { + this.draw = t; + } + sort() { this.tiles.sort((a, b) => { if (a.lessThan(b)) return -1; @@ -58,5 +62,7 @@ class Game { this.hands = Array.from({ length: 4 }, () => this.wall.drawHand()); this.discards = Array.from({ length: 4 }, () => new Discard()); this.turn = 0; + + this.hands[this.turn].setDraw(this.wall.draw()); } } \ No newline at end of file diff --git a/frontend/js/tile.js b/frontend/js/tile.js index 6a4a7b3..1d4f684 100644 --- a/frontend/js/tile.js +++ b/frontend/js/tile.js @@ -62,8 +62,11 @@ class Tile { } lessThan(other) { - if (this.family !== other.family) { - return this.family < other.family; + const order = [Family.MAN, Family.PIN, Family.SOU, Family.WIND, Family.DRAGON]; + const famA = order.indexOf(this.family); + const famB = order.indexOf(other.family); + if (famA !== famB) { + return famA < famB; } if (typeof this.value === 'object' && 'value' in this.value) { return this.value.value < other.value.value; diff --git a/frontend/pages/riichi/chap5.html b/frontend/pages/riichi/chap5.html index 6967538..b5ce2eb 100644 --- a/frontend/pages/riichi/chap5.html +++ b/frontend/pages/riichi/chap5.html @@ -91,6 +91,22 @@ padding: 20px 0 0 20px; } + .hand-tiles { + display: flex; + flex-direction: row; + gap: 5px; + } + .hand-with-draw { + display: flex; + flex-direction: row; + align-items: flex-end; + } + .draw-tile { + margin-left: 12px; + position: relative; + top: 0; + display: inline-block; + } #hand-2 { position: absolute; transform: translate(-50%, -400%) rotate(180deg) translate(0%, 450%); @@ -181,6 +197,21 @@ } handDiv.appendChild(tileDiv); } + // Affiche la tuile draw à droite de la main, séparée + const drawTile = game.hands[i].draw; + if (drawTile) { + const drawDiv = document.createElement('div'); + drawDiv.className = 'draw-tile'; + if (i === 0) { + drawDiv.innerHTML = drawTile.getSVG(); + } else { + drawDiv.innerHTML = ` + + + `; + } + handDiv.appendChild(drawDiv); + } } });