feat(api): Vue

Changed ingame JQuery to Vue Components, Started changing lobby to vue components
This commit is contained in:
LQ63
2025-12-04 01:32:17 +01:00
parent eba2ad6232
commit 5eb0eac39e
5 changed files with 693 additions and 494 deletions

View File

@@ -1,61 +1,6 @@
function handlePlayCard(card, dog) {
if(!canPlayCard) return
canPlayCard = false;
const cardId = card.dataset.cardId;
console.debug(`Playing card ${cardId} from hand`)
const wiggleKeyframes = [
{ transform: 'translateX(0)' },
{ transform: 'translateX(-5px)' },
{ transform: 'translateX(5px)' },
{ transform: 'translateX(-5px)' },
{ transform: 'translateX(0)' }
];
const wiggleTiming = {
duration: 400,
iterations: 1,
easing: 'ease-in-out',
fill: 'forwards'
};
const cardslide = $('#card-slide')
const payload = {
cardindex: cardId,
isDog: dog
}
sendEventAndWait("PlayCard", payload).then(
() => {
card.parentElement.remove();
cardslide.find('.handcard').each(function(newIndex) {
const $innerButton = $(this).find('.btn');
$innerButton.attr('data-card-id', newIndex);
const isInDogLife = $innerButton.attr('onclick').includes("'true'") ? 'true' : 'false';
$innerButton.attr('onclick', `handlePlayCard(this, '${isInDogLife}')`);
console.debug(`Re-indexed card: Old index was ${$innerButton.attr('data-card-id')}, New index is ${newIndex}`);
});
cardslide.addClass("inactive")
}
).catch(
(err) => {
canPlayCard = true;
const cardslide = $('#card-slide')
cardslide.removeClass("inactive")
card.parentElement.animate(wiggleKeyframes, wiggleTiming);
alertMessage(err.message)
}
)
}
/*
function handlePlayCard(cardidx) {}
*/
function handleSkipDogLife(button) {
// TODO needs implementation
}
@@ -79,4 +24,9 @@ function handleKickPlayer(playerId) {
}
function handleReturnToLobby() {
sendEvent("ReturnToLobby")
}
}
globalThis.startGame = startGame
globalThis.handleTrumpSelection = handleTrumpSelection
globalThis.handleKickPlayer = handleKickPlayer
globalThis.handleReturnToLobby = handleReturnToLobby