feat(game): Implement return to lobby functionality and enhance dog life handling
This commit is contained in:
@@ -389,7 +389,7 @@ function handlePlayCard(cardobject, gameId, dog = false) {
|
|||||||
const jsonObj = {
|
const jsonObj = {
|
||||||
cardID: cardId
|
cardID: cardId
|
||||||
}
|
}
|
||||||
sendPlayCardRequest(jsonObj, gameId, cardobject)
|
sendPlayCardRequest(jsonObj, gameId, cardobject, dog)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSkipDogLife(cardobject, gameId) {
|
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 = [
|
const wiggleKeyframes = [
|
||||||
{ transform: 'translateX(0)' },
|
{ transform: 'translateX(0)' },
|
||||||
{ transform: 'translateX(-5px)' },
|
{ transform: 'translateX(-5px)' },
|
||||||
@@ -434,7 +434,7 @@ function sendPlayCardRequest(jsonObj, gameId, cardobject) {
|
|||||||
easing: 'ease-in-out',
|
easing: 'ease-in-out',
|
||||||
fill: 'forwards'
|
fill: 'forwards'
|
||||||
};
|
};
|
||||||
const route = jsRoutes.controllers.IngameController.playCard(gameId);
|
const route = dog ? jsRoutes.controllers.IngameController.playCard(gameId) : jsRoutes.controllers.IngameController.playDogCard(gameId);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: route.url,
|
url: route.url,
|
||||||
@@ -448,9 +448,9 @@ function sendPlayCardRequest(jsonObj, gameId, cardobject) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to parse error response:", 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);
|
cardobject.parentElement.animate(wiggleKeyframes, wiggleTiming);
|
||||||
} else if (error && error.errorMessage) {
|
} else if (error?.errorMessage) {
|
||||||
alert(`${error.errorMessage}`);
|
alert(`${error.errorMessage}`);
|
||||||
} else {
|
} else {
|
||||||
alert('An unexpected error occurred. Please try again.');
|
alert('An unexpected error occurred. Please try again.');
|
||||||
|
|||||||
Reference in New Issue
Block a user