This commit is contained in:
Hepatica
2024-02-24 02:49:59 +01:00
parent 921048c969
commit 8d1316b7ac

View File

@@ -191,9 +191,6 @@ import "vue3-carousel/dist/carousel.css";
import { eventBus } from "@/main"; import { eventBus } from "@/main";
// import ProgressBar from "vue-bulma-progress-bar";
// import '@/assets/css/PagesStyles/games-pages/jackpot.css'
export default { export default {
components: { components: {
HeaderComponent, HeaderComponent,
@@ -209,41 +206,41 @@ export default {
return { return {
JackpotNumbers, JackpotNumbers,
autoplay: 0, autoplay: 0,
slides: [ // slides: [
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Ckutls_.png", // img: "https://avatar.spworlds.ru/face/55/Ckutls_.png",
nickname: "Ckutls_", // nickname: "Ckutls_",
}, // },
{ // {
img: "https://avatar.spworlds.ru/face/55/Hepatir.png", // img: "https://avatar.spworlds.ru/face/55/Hepatir.png",
nickname: "Hepatir", // nickname: "Hepatir",
}, // },
], // ],
slides: [],
currentSlide: 0, currentSlide: 0,
value: 0, value: 0,
max: 100, max: 100,
amountDeposit: 0, amountDeposit: 0,
isCarouselStopped: false,
targetNickname: "", targetNickname: "",
isStopButtonPressed: false, isStopButtonPressed: false,
isGameTimerStarted: false, isGameTimerStarted: false,
@@ -256,6 +253,18 @@ export default {
}, },
methods: { methods: {
mapPlayersToSlides(players) {
this.slides = [];
players.forEach((player) => {
const numberOfCards = player.WinningPercentage / 10; // Предполагаем, что 10% это 1 карточка
for (let i = 0; i < numberOfCards; i++) {
this.slides.push({
img: `https://avatar.spworlds.ru/face/55/${player.UserName}.png`, // Предполагаем структуру URL из имени пользователя
nickname: player.UserName,
});
}
});
},
checkGameEnd(endGameUtc) { checkGameEnd(endGameUtc) {
const endTime = new Date(endGameUtc).getTime(); const endTime = new Date(endGameUtc).getTime();
const currentTime = new Date().getTime(); const currentTime = new Date().getTime();
@@ -281,6 +290,7 @@ export default {
startGameTimer(startGameUtc) { startGameTimer(startGameUtc) {
if (!this.isGameTimerStarted) { if (!this.isGameTimerStarted) {
this.isGameTimerStarted = true; this.isGameTimerStarted = true;
const startTime = new Date(startGameUtc).getTime(); const startTime = new Date(startGameUtc).getTime();
const updateTimer = () => { const updateTimer = () => {
const currentTime = new Date().getTime(); const currentTime = new Date().getTime();
@@ -324,20 +334,48 @@ export default {
handleSlideStart(data) { handleSlideStart(data) {
try { try {
const { slidingToIndex } = data; const { slidingToIndex } = data;
// Проверяем, существует ли слайд и имеет ли он свойство nickname
if (this.slides[slidingToIndex] && this.slides[slidingToIndex].nickname) {
this.currentSlideIndex = slidingToIndex; this.currentSlideIndex = slidingToIndex;
if (this.isStopButtonPressed) { if (this.isStopButtonPressed) {
if ( if (this.slides[this.currentSlideIndex].nickname == "Hepatir") {
this.slides[this.currentSlideIndex].nickname === // if (this.slides[this.currentSlideIndex].nickname == this.targetNickname) {
this.targetNickname &&
!this.isCarouselStopped
) {
this.stopAutoplay(); this.stopAutoplay();
} }
} }
}
} catch (error) { } catch (error) {
console.error("Error in handleSlideStart:", error); console.error("Error in handleSlideStart:", error);
// Здесь вы можете обработать ошибку, например, остановить карусель
} }
// try {
// const { slidingToIndex } = data;
// this.currentSlideIndex = slidingToIndex;
// if (this.isStopButtonPressed) {
// if (
// this.slides[this.currentSlideIndex].nickname == this.targetNickname
// ) {
// this.stopAutoplay();
// }
// }
// } catch (error) {
// console.error("Error in handleSlideStart:", error);
// // Здесь вы можете обработать ошибку, например, остановить карусель
// }
// try {
// const { slidingToIndex } = data;
// this.currentSlideIndex = slidingToIndex;
// if (this.isStopButtonPressed) {
// if (
// this.slides[this.currentSlideIndex].nickname ==
// "Hepatir"
// ) {
// this.stopAutoplay();
// }
// }
// } catch (error) {
// console.error("Error in handleSlideStart:", error);
// // Здесь вы можете обработать ошибку, например, остановить карусель
// }
}, },
stopCarousel() { stopCarousel() {
this.isStopButtonPressed = true; this.isStopButtonPressed = true;
@@ -345,7 +383,9 @@ export default {
}, },
stopAutoplay() { stopAutoplay() {
this.autoplay = 0; this.autoplay = 0;
this.isCarouselStopped = true; this.targetNickname = "";
this.isGameTimerStarted = false;
this.isStopButtonPressed = false;
if (this.interval) { if (this.interval) {
clearInterval(this.interval); clearInterval(this.interval);
} }
@@ -371,14 +411,22 @@ export default {
const dataObject = JSON.parse(data); const dataObject = JSON.parse(data);
console.log(dataObject); console.log(dataObject);
this.lastUserWinner=dataObject.LastGame.WinnerUserName; if (dataObject.CurrentGame.GameState == "WaitingForPlayers") {
console.log("Waiting for players");
console.log("Put there earlies cards");
this.lastUserWinner = dataObject.LastGame.WinnerUserName;
// this.mapPlayersToSlides(dataObject.LastGame.PlayerList);
}
if (dataObject.CurrentGame.GameState == "StartGameTimer") { if (dataObject.CurrentGame.GameState == "StartGameTimer") {
if (!this.isGameTimerStarted) {
console.log("Set players");
this.mapPlayersToSlides(dataObject.CurrentGame.PlayerList);
}
this.startGameTimer(dataObject.CurrentGame.StartGameUtc); this.startGameTimer(dataObject.CurrentGame.StartGameUtc);
} }
if ( if (
dataObject.CurrentGame.GameState != "WaitingForPlayers" &&
dataObject.CurrentGame.GameState == "Running" dataObject.CurrentGame.GameState == "Running"
) { ) {
this.checkGameEnd(dataObject.CurrentGame.EndGameUtc); this.checkGameEnd(dataObject.CurrentGame.EndGameUtc);
@@ -396,8 +444,10 @@ export default {
}); });
eventBus.on("gameEnded", () => { eventBus.on("gameEnded", () => {
setTimeout(() => { setTimeout(() => {
if (!this.isStopButtonPressed) {
this.targetNickname = this.lastUserWinner; this.targetNickname = this.lastUserWinner;
this.stopCarousel(); this.stopCarousel();
}
}, 2000); }, 2000);
}); });
// this.startAutoScroll(); // this.startAutoScroll();