feat(game): Implement return to lobby functionality and enhance dog life handling

This commit is contained in:
2025-11-19 19:21:26 +01:00
parent b260e18223
commit 437f8fd466

View File

@@ -389,7 +389,7 @@ function handlePlayCard(cardobject, gameId, dog = false) {
const jsonObj = {
cardID: cardId
}
sendPlayCardRequest(jsonObj, gameId, cardobject)
sendPlayCardRequest(jsonObj, gameId, cardobject, dog)
}
function handleSkipDogLife(cardobject, gameId) {
@@ -419,7 +419,7 @@ function handleSkipDogLife(cardobject, gameId) {
})
}
function sendPlayCardRequest(jsonObj, gameId, cardobject) {
function sendPlayCardRequest(jsonObj, gameId, cardobject, dog) {
const wiggleKeyframes = [
{ transform: 'translateX(0)' },
{ transform: 'translateX(-5px)' },
@@ -434,7 +434,7 @@ function sendPlayCardRequest(jsonObj, gameId, cardobject) {
easing: 'ease-in-out',
fill: 'forwards'
};
const route = jsRoutes.controllers.IngameController.playCard(gameId);
const route = dog ? jsRoutes.controllers.IngameController.playCard(gameId) : jsRoutes.controllers.IngameController.playDogCard(gameId);
$.ajax({
url: route.url,
@@ -448,9 +448,9 @@ function sendPlayCardRequest(jsonObj, gameId, cardobject) {
} catch (e) {
console.error("Failed to parse error response:", e);
}
if (error && error.errorMessage.includes("You can't play this card!")) {
if (error?.errorMessage.includes("You can't play this card!")) {
cardobject.parentElement.animate(wiggleKeyframes, wiggleTiming);
} else if (error && error.errorMessage) {
} else if (error?.errorMessage) {
alert(`${error.errorMessage}`);
} else {
alert('An unexpected error occurred. Please try again.');