Add draw requests and rematches

This commit is contained in:
sepia 2025-07-22 20:44:06 -05:00
parent 1a221bf680
commit 2f46d86947
6 changed files with 297 additions and 7 deletions

View file

@ -0,0 +1,6 @@
document.addEventListener('htmx:wsAfterMessage', function (e) {
const message = JSON.parse(e.detail.message);
if (message.type === 'redirect_to_game') {
window.location.href = '/?gameId=' + message.gameId;
}
});

View file

@ -27,5 +27,29 @@ document.addEventListener('htmx:wsConfigSend', function (e) {
e.detail.parameters = {
type: 'decline_takeback',
};
} else if (e.target.id == 'draw-button') {
e.detail.parameters = {
type: 'request_draw',
};
} else if (e.target.id == 'accept-draw-button') {
e.detail.parameters = {
type: 'accept_draw',
};
} else if (e.target.id == 'decline-draw-button') {
e.detail.parameters = {
type: 'decline_draw',
};
} else if (e.target.id == 'rematch-button') {
e.detail.parameters = {
type: 'request_rematch',
};
} else if (e.target.id == 'accept-rematch-button') {
e.detail.parameters = {
type: 'accept_rematch',
};
} else if (e.target.id == 'decline-rematch-button') {
e.detail.parameters = {
type: 'decline_rematch',
};
}
});