Private
Public Access
1
0

chg: dev: increase the minimum PHP version to the latest major - and massive refactor on back-end, like Controllers and Repositories #4

This commit is contained in:
2026-04-12 08:01:46 +02:00
parent 92bfa5b301
commit c0dcc2896a
12 changed files with 511 additions and 104 deletions

View File

@@ -130,6 +130,51 @@ const useServerCommunication = (gameAssoc, gameInherited, isEnvDev) => {
showOverlay('The connection has been lost w/ your friend...', 'Please, restart the game!');
};
const wChallenge = payload => {
const { challengerName, challengerGameAssoc } = payload;
const handleAccept = () => {
fetch('/api/game/challenge/respond/' + challengerGameAssoc, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ accepted: true, targetGameAssoc: gameAssoc }),
}).then(() => {
showOverlay('Challenge accepted!', 'Waiting for the challenger to join...');
}).catch(() => {});
};
const handleDecline = () => {
fetch('/api/game/challenge/respond/' + challengerGameAssoc, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ accepted: false, targetGameAssoc: gameAssoc }),
}).then(() => {
showOverlay('We are waiting for your opponent...', gameAssoc ? (
<WaitingOverlayContent
shareUrl={window.location.origin + '/play/' + gameAssoc}
currentGameAssoc={gameAssoc}
/>
) : '');
}).catch(() => {});
};
showOverlay(
challengerName + ' wants to challenge you!',
<div className="resign">
<a onClick={handleAccept}>Accept</a>
<a onClick={handleDecline}>Decline</a>
</div>,
);
};
const wChallengeResponse = payload => {
if (payload.accepted) {
window.location.href = '/play/' + payload.targetGameAssoc;
} else {
window.dispatchEvent(new CustomEvent('challenge-declined'));
}
};
const wTopic = payload => {
if (webPlayerRef.current !== payload.data.player) {
if (null === payload.data.resign) {
@@ -152,6 +197,12 @@ const useServerCommunication = (gameAssoc, gameInherited, isEnvDev) => {
};
const handleMercureMessage = payload => {
if (undefined !== payload.type) {
if ('challenge' === payload.type) wChallenge(payload);
else if ('challenge-response' === payload.type) wChallengeResponse(payload);
return;
}
if (undefined !== payload.data) {
wTopic(payload);
} else if (undefined === payload.msg) {