affichage dos des tuiles
This commit is contained in:
parent
d24eac42dd
commit
668e355132
1 changed files with 19 additions and 25 deletions
|
|
@ -157,31 +157,20 @@
|
||||||
console.log('Réponse API', data);
|
console.log('Réponse API', data);
|
||||||
if (data.state && data.state.hand_player) {
|
if (data.state && data.state.hand_player) {
|
||||||
displayHand(data.state.hand_player, 'hand-0');
|
displayHand(data.state.hand_player, 'hand-0');
|
||||||
// joueur 1
|
|
||||||
fetch('/api/game/hand/1')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(botData => {
|
|
||||||
if (botData.hand) {
|
|
||||||
displayHand(botData.hand, 'hand-1');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// joueur 2
|
|
||||||
fetch('/api/game/hand/2')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(botData => {
|
|
||||||
if (botData.hand) {
|
|
||||||
displayHand(botData.hand, 'hand-2');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// joueur 3
|
|
||||||
fetch('/api/game/hand/3')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(botData => {
|
|
||||||
if (botData.hand) {
|
|
||||||
displayHand(botData.hand, 'hand-3');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
// Affichage des mains bots (1, 2, 3)
|
||||||
|
[1, 2, 3].forEach(id => {
|
||||||
|
fetch(`/api/game/hand/${id}`)
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(botData => {
|
||||||
|
if (botData.hand) {
|
||||||
|
displayHand(botData.hand, `hand-${id}`);
|
||||||
|
} else {
|
||||||
|
console.error(`Main vide pour joueur ${id}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => console.error(`Erreur main ${id}`, e));
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(e => console.error('Erreur initialisation partie', e));
|
.catch(e => console.error('Erreur initialisation partie', e));
|
||||||
|
|
||||||
|
|
@ -190,7 +179,12 @@
|
||||||
display.innerHTML = '';
|
display.innerHTML = '';
|
||||||
hand.forEach(tile => {
|
hand.forEach(tile => {
|
||||||
const tileDiv = document.createElement('div');
|
const tileDiv = document.createElement('div');
|
||||||
tileDiv.innerHTML = tile.svg;
|
// Affiche le dos des tuiles pour les bots
|
||||||
|
if (displayId !== 'hand-0') {
|
||||||
|
tileDiv.innerHTML = '<svg viewBox="0 0 310 410" width="60" height="80"><image href="/img/Regular/Back.svg" width="310" height="410"/></svg>';
|
||||||
|
} else {
|
||||||
|
tileDiv.innerHTML = tile.svg;
|
||||||
|
}
|
||||||
display.appendChild(tileDiv);
|
display.appendChild(tileDiv);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue