Submodule knockoutwhist updated: c5dd02a5e8...d833932f16
@@ -219,10 +219,10 @@ body {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#nextPlayers {
|
#next-players-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
height: 0;
|
height: 0;
|
||||||
|
|
||||||
p {
|
p {
|
||||||
@@ -231,10 +231,6 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#invisible {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#selecttrumpsuit {
|
#selecttrumpsuit {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -41,21 +41,21 @@ class UserSession(val user: User, val host: Boolean, val gameLobby: GameLobby) e
|
|||||||
lock.lock()
|
lock.lock()
|
||||||
val result = Try {
|
val result = Try {
|
||||||
eventType match {
|
eventType match {
|
||||||
case "Ping" =>
|
case "ping" =>
|
||||||
// No action needed for Ping
|
// No action needed for Ping
|
||||||
()
|
()
|
||||||
case "Start Game" =>
|
case "StartGame" =>
|
||||||
gameLobby.startGame(user)
|
gameLobby.startGame(user)
|
||||||
case "play Card" =>
|
case "PlayCard" =>
|
||||||
val maybeCardIndex: Option[Int] = (data \ "cardindex").asOpt[Int]
|
val maybeCardIndex: Option[String] = (data \ "cardindex").asOpt[String]
|
||||||
maybeCardIndex match {
|
maybeCardIndex match {
|
||||||
case Some(index) =>
|
case Some(index) =>
|
||||||
val session = gameLobby.getUserSession(user.id)
|
val session = gameLobby.getUserSession(user.id)
|
||||||
gameLobby.playCard(session, index)
|
gameLobby.playCard(session, index.toInt)
|
||||||
case None =>
|
case None =>
|
||||||
println("Card Index not found or is not a number.")
|
println("Card Index not found or is not a number.")
|
||||||
}
|
}
|
||||||
case "Picked Trumpsuit" =>
|
case "PickTrumpsuit" =>
|
||||||
val maybeSuitIndex: Option[Int] = (data \ "suitIndex").asOpt[Int]
|
val maybeSuitIndex: Option[Int] = (data \ "suitIndex").asOpt[Int]
|
||||||
maybeSuitIndex match {
|
maybeSuitIndex match {
|
||||||
case Some(index) =>
|
case Some(index) =>
|
||||||
|
|||||||
@@ -15,16 +15,21 @@
|
|||||||
}else {
|
}else {
|
||||||
<p class="fs-5 text-primary" id="current-player-name">---</p>
|
<p class="fs-5 text-primary" id="current-player-name">---</p>
|
||||||
}
|
}
|
||||||
<h4 class="fw-semibold mb-1" style="display: none;" id="next-players-text">Next Players</h4>
|
|
||||||
<div id="next-players-container">
|
|
||||||
@if(gamelobby.getLogic.getPlayerQueue.isDefined && gamelobby.getLogic.getCurrentMatch && !TrickUtil.isOver(gamelobby.getLogic.getCurrentMatch.get, gamelobby.getLogic.getPlayerQueue.get)) {
|
@if(gamelobby.getLogic.getPlayerQueue.isDefined && gamelobby.getLogic.getCurrentMatch && !TrickUtil.isOver(gamelobby.getLogic.getCurrentMatch.get, gamelobby.getLogic.getPlayerQueue.get)) {
|
||||||
|
<h4 class="fw-semibold mb-1" id="next-players-text">Next Players</h4>
|
||||||
|
<div id="next-players-container">
|
||||||
@for(nextplayer <- gamelobby.getLogic.getPlayerQueue.get.duplicate()) {
|
@for(nextplayer <- gamelobby.getLogic.getPlayerQueue.get.duplicate()) {
|
||||||
<p class="fs-5 text-primary">@nextplayer @if(nextplayer.isInDogLife) {
|
<p class="fs-5 text-primary">@nextplayer @if(nextplayer.isInDogLife) {
|
||||||
🐶
|
🐶
|
||||||
}</p>
|
}</p>
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
} else {
|
||||||
|
<h4 class="fw-semibold mb-1" style="display: none;" id="next-players-text">Next Players</h4>
|
||||||
|
<div id="next-players-container">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-4 text-center">
|
<div class="col-4 text-center">
|
||||||
@@ -107,7 +112,7 @@
|
|||||||
} else {
|
} else {
|
||||||
@for(i <- player.currentHand().get.cards.indices) {
|
@for(i <- player.currentHand().get.cards.indices) {
|
||||||
<div class="col-auto handcard" style="border-radius: 6px">
|
<div class="col-auto handcard" style="border-radius: 6px">
|
||||||
<div class="btn btn-outline-light p-0 border-0 shadow-none" id="@i" data-card-id="@i" style="border-radius: 6px" onclick="handlePlayCard(@i, '@player.isInDogLife')">
|
<div class="btn btn-outline-light p-0 border-0 shadow-none" data-card-id="@i" style="border-radius: 6px" onclick="handlePlayCard(this, '@player.isInDogLife')">
|
||||||
@util.WebUIUtils.cardtoImage(player.currentHand().get.cards(i)) width="120px" style="border-radius: 6px"/>
|
@util.WebUIUtils.cardtoImage(player.currentHand().get.cards(i)) width="120px" style="border-radius: 6px"/>
|
||||||
</div>
|
</div>
|
||||||
@if(player.isInDogLife) {
|
@if(player.isInDogLife) {
|
||||||
@@ -137,4 +142,5 @@
|
|||||||
}
|
}
|
||||||
waitForFunction("pollForUpdates").then(fn => fn('@gamelobby.id'));
|
waitForFunction("pollForUpdates").then(fn => fn('@gamelobby.id'));
|
||||||
connectWebSocket()
|
connectWebSocket()
|
||||||
|
canPlayCard = @gamelobby.logic.getCurrentPlayer.contains(player);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
var canPlayCard = false;
|
||||||
|
|
||||||
function alertMessage(message) {
|
function alertMessage(message) {
|
||||||
let newHtml = '';
|
let newHtml = '';
|
||||||
const alertId = `alert-${Date.now()}`;
|
const alertId = `alert-${Date.now()}`;
|
||||||
@@ -38,7 +40,7 @@ function receiveHandEvent(eventData) {
|
|||||||
//Build Hand Container
|
//Build Hand Container
|
||||||
hand.forEach((card) => {
|
hand.forEach((card) => {
|
||||||
//Data
|
//Data
|
||||||
const idx = card.idx
|
const idx = card.idx;
|
||||||
const cardS = card.card;
|
const cardS = card.card;
|
||||||
|
|
||||||
const cardHtml = `
|
const cardHtml = `
|
||||||
@@ -157,6 +159,7 @@ function requestCardEvent(eventData) {
|
|||||||
const player = eventData.player;
|
const player = eventData.player;
|
||||||
const handElement = $('#card-slide')
|
const handElement = $('#card-slide')
|
||||||
handElement.removeClass('inactive');
|
handElement.removeClass('inactive');
|
||||||
|
canPlayCard = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,7 +284,7 @@ function receiveTurnEvent(eventData) {
|
|||||||
|
|
||||||
const currentPlayerNameContainer = $('#current-player-name');
|
const currentPlayerNameContainer = $('#current-player-name');
|
||||||
const nextPlayersContainer = $('#next-players-container');
|
const nextPlayersContainer = $('#next-players-container');
|
||||||
const nextPlayerText = $('#next-players-section');
|
const nextPlayerText = $('#next-players-text');
|
||||||
|
|
||||||
let currentPlayerName = currentPlayer.name;
|
let currentPlayerName = currentPlayer.name;
|
||||||
if (currentPlayer.dog) {
|
if (currentPlayer.dog) {
|
||||||
@@ -293,6 +296,7 @@ function receiveTurnEvent(eventData) {
|
|||||||
nextPlayerText.hide();
|
nextPlayerText.hide();
|
||||||
nextPlayersContainer.html('');
|
nextPlayersContainer.html('');
|
||||||
} else {
|
} else {
|
||||||
|
console.log("Length"+nextPlayers.length);
|
||||||
nextPlayerText.show();
|
nextPlayerText.show();
|
||||||
let nextPlayersHtml = '';
|
let nextPlayersHtml = '';
|
||||||
nextPlayers.forEach((player) => {
|
nextPlayers.forEach((player) => {
|
||||||
@@ -300,7 +304,7 @@ function receiveTurnEvent(eventData) {
|
|||||||
if (player.dog) {
|
if (player.dog) {
|
||||||
playerName += " 🐶";
|
playerName += " 🐶";
|
||||||
}
|
}
|
||||||
nextPlayersHtml += `<p className="fs-5 text-primary">${playerName}</p>`;
|
nextPlayersHtml += `<p class="fs-5 text-primary">${playerName}</p>`;
|
||||||
});
|
});
|
||||||
nextPlayersContainer.html(nextPlayersHtml);
|
nextPlayersContainer.html(nextPlayersHtml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,57 @@
|
|||||||
function handlePlayCard(cardIndex, dog) {
|
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 cardslide = $('#card-slide')
|
||||||
cardslide.addClass("inactive")
|
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
cardindex: cardIndex,
|
cardindex: cardId,
|
||||||
isDog: dog
|
isDog: dog
|
||||||
}
|
}
|
||||||
sendEventAndWait("play Card", payload).then(
|
sendEventAndWait("PlayCard", payload).then(
|
||||||
() => {
|
() => {
|
||||||
console.debug("play card successful")
|
card.parentElement.remove();
|
||||||
const datacardid = $(`#${cardIndex}`)
|
|
||||||
datacardid.parent('.handcard').remove();
|
|
||||||
cardslide.find('.handcard').each(function(newIndex) {
|
cardslide.find('.handcard').each(function(newIndex) {
|
||||||
|
|
||||||
const $innerButton = $(this).find('.btn');
|
const $innerButton = $(this).find('.btn');
|
||||||
|
|
||||||
$innerButton.attr('id', newIndex);
|
|
||||||
$innerButton.attr('data-card-id', newIndex);
|
$innerButton.attr('data-card-id', newIndex);
|
||||||
|
|
||||||
const isInDogLife = $innerButton.attr('onclick').includes("'true'") ? 'true' : 'false';
|
const isInDogLife = $innerButton.attr('onclick').includes("'true'") ? 'true' : 'false';
|
||||||
$innerButton.attr('onclick', `handlePlayCard(${newIndex}, '${isInDogLife}')`);
|
$innerButton.attr('onclick', `handlePlayCard(this, '${isInDogLife}')`);
|
||||||
|
|
||||||
console.debug(`Re-indexed card: Old index was ${$innerButton.attr('data-card-id')}, New index is ${newIndex}`);
|
console.debug(`Re-indexed card: Old index was ${$innerButton.attr('data-card-id')}, New index is ${newIndex}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cardslide.addClass("inactive")
|
||||||
}
|
}
|
||||||
).catch(
|
).catch(
|
||||||
(err) => {
|
(err) => {
|
||||||
|
canPlayCard = true;
|
||||||
const cardslide = $('#card-slide')
|
const cardslide = $('#card-slide')
|
||||||
console.warn("play card was not successful")
|
|
||||||
if (err.message === "You can't play this card!") {
|
|
||||||
cardslide.removeClass("inactive")
|
cardslide.removeClass("inactive")
|
||||||
}
|
card.parentElement.animate(wiggleKeyframes, wiggleTiming);
|
||||||
alertMessage("You aren't allowed to play this card")
|
alertMessage(err.message)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -40,7 +60,7 @@ function handleSkipDogLife(button) {
|
|||||||
// TODO needs implementation
|
// TODO needs implementation
|
||||||
}
|
}
|
||||||
function startGame() {
|
function startGame() {
|
||||||
sendEvent("Start Game")
|
sendEvent("StartGame")
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTrumpSelection(object) {
|
function handleTrumpSelection(object) {
|
||||||
@@ -49,8 +69,7 @@ function handleTrumpSelection(object) {
|
|||||||
const payload = {
|
const payload = {
|
||||||
suitIndex: trumpIndex
|
suitIndex: trumpIndex
|
||||||
}
|
}
|
||||||
console.log("SENDING TRUMP SUIT SELECTION:", payload);
|
sendEvent("PickTrumpsuit", payload)
|
||||||
sendEvent("Picked Trumpsuit", payload)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
function handleKickPlayer(playerId) {
|
function handleKickPlayer(playerId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user