From 71acb898418381b66a249384f3977d5c72236da6 Mon Sep 17 00:00:00 2001 From: Kostya Date: Sun, 4 Feb 2024 19:24:51 +0300 Subject: [PATCH] added if-block for over game, added vision players bid, fixed styles --- .../css/PagesStyles/games-pages/crash.css | 13 ++-- .../src/assets/js/games/crash/CrashAPI.js | 2 +- .../games-components/CrashGraphComponent.vue | 12 ++- .../src/pages/games-pages/CrashgamePage.vue | 77 ++++++++++++------- 4 files changed, 70 insertions(+), 34 deletions(-) diff --git a/luckydiamond/src/assets/css/PagesStyles/games-pages/crash.css b/luckydiamond/src/assets/css/PagesStyles/games-pages/crash.css index 6974e3c..326c6d4 100644 --- a/luckydiamond/src/assets/css/PagesStyles/games-pages/crash.css +++ b/luckydiamond/src/assets/css/PagesStyles/games-pages/crash.css @@ -124,26 +124,29 @@ height: 474px; background: #30364F; position: relative; - top: -415px; + top: -342px; left: 10%; z-index: 1; } .crash-content .error-block { - top: 500px; + top: 420px; } /* /Crash-Window */ /* Crash-Graph */ -.chart-container { +.crash-game__graph { width: 800px; - top: 10%; - left: 10%; + top: 200px; + left: 600px; + position: fixed; } + .chart-container canvas { + background-color: transparent !important; width: 800px !important; height: 400px !important; transition: .3s ease; diff --git a/luckydiamond/src/assets/js/games/crash/CrashAPI.js b/luckydiamond/src/assets/js/games/crash/CrashAPI.js index a3c306f..fbb1223 100644 --- a/luckydiamond/src/assets/js/games/crash/CrashAPI.js +++ b/luckydiamond/src/assets/js/games/crash/CrashAPI.js @@ -40,7 +40,7 @@ export async function ExitAndTakeMoneyFromCrashGame(userData) { } try { - const response = await fetch(`${BackendApiUrl}/GameCrash/ExitAndTakeMoneyFromCrash`, { + const response = await fetch(`${BackendApiUrl}/GameCrash/ExitAndTakeMoneyFromCrashGame`, { method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/luckydiamond/src/components/games-components/CrashGraphComponent.vue b/luckydiamond/src/components/games-components/CrashGraphComponent.vue index b535dfb..819f07d 100644 --- a/luckydiamond/src/components/games-components/CrashGraphComponent.vue +++ b/luckydiamond/src/components/games-components/CrashGraphComponent.vue @@ -48,8 +48,18 @@ export default { }, }, scales: { + x: { + grid: { + display: false + } + }, + y: { + grid: { + display: false + } + } }, - animation: false, // Отключаем анимацию + animation: false, }, }; }, diff --git a/luckydiamond/src/pages/games-pages/CrashgamePage.vue b/luckydiamond/src/pages/games-pages/CrashgamePage.vue index 917f4ff..5c2a3a9 100644 --- a/luckydiamond/src/pages/games-pages/CrashgamePage.vue +++ b/luckydiamond/src/pages/games-pages/CrashgamePage.vue @@ -28,22 +28,13 @@ -
-

Автовывод

-
- -
-
-

Ошибка при заполнении

-
-
-

Игра уже начата или только закончилась

+

{{ textError }}

- - + +
@@ -57,9 +48,18 @@
-
+
- +
    +
  • +

    {{ player.UserName }}

    +

    {{ player.Bid }}

    +
    +

    {{ player.WinningMoney }}

    +

    {{ player.WinningX }}

    +
    +
  • +
@@ -82,7 +82,7 @@ import SaperNumbers from "@/mocks/SaperNumbers"; import {GetCurrentMoney} from "@/assets/js/rest/RestMethods"; import {GetCookie} from "@/assets/js/storage/CookieStorage"; import {eventBus} from "@/main"; -import {JoinCrashGame} from "@/assets/js/games/crash/CrashAPI"; +import {ExitAndTakeMoneyFromCrashGame, JoinCrashGame} from "@/assets/js/games/crash/CrashAPI"; export default { components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent }, @@ -94,9 +94,9 @@ export default { ErrorJoin: false, balance: 0, amountDeposit: 0, - autoRatio: '', crashObject: '', - startGame: false + textError: '', + startGame: false, } }, setup() { @@ -108,16 +108,19 @@ export default { const dataCrashParse = JSON.parse(dataCrash) this.crashObject = dataCrashParse + console.log(this.crashObject) } catch (e) { console.error(e) } + if (this.crashObject.Status === 'GameEnd' && this.crashObject.Players.some(player => player.UserName === GetCookie('SpUserName'))) { + this.startGame = false + } }) }, validations() { return { amountDeposit: { required, numeric, minValue: minValue(1), maxValue: maxValue(this.balance), integer }, - autoRatio: { numeric, minValue: minValue(1.01) } } }, watch: { @@ -190,12 +193,10 @@ export default { this.v$.$touch() if (this.v$.amountDeposit.$error) { + this.textError = 'Ошибка введении данных' this.errorPlayButton() } - // if (this.v$.autoRatio.$error) { - // this.errorPlayButton() - // } - // && this.v$.autoRatio.$error + if (!this.v$.amountDeposit.$error) { const userData = { searchToken: GetCookie('SearchToken'), @@ -205,12 +206,18 @@ export default { await JoinCrashGame(userData, this.amountDeposit) .then((response) => { console.log(response) - if (response === `You can't join to started or ended game`) { - this.ErrorJoin = true + if (response === `You can't join to started or ended game` || response === 'Player alredy in the game.') { - setTimeout(() => { - this.ErrorJoin = false - }, 2000) + if (response === `You can't join to started or ended game`) { + this.textError = 'Игра уже началась или только закончилась!' + this.errorPlayButton() + } + else if (response === 'Player alredy in the game.') { + this.textError = 'Вы уже в игре!' + this.errorPlayButton() + } + + return } this.startGame = true }) @@ -220,8 +227,24 @@ export default { this.ErrorClick = true setTimeout(() => { this.ErrorClick = false + this.textError = '' }, 2000) }, + async clickClaimDep() { + if (this.startGame === true) { + const userData = { + searchToken: GetCookie('SearchToken'), + authtoken: GetCookie('AUTHTOKEN') + } + + await ExitAndTakeMoneyFromCrashGame(userData) + .then((response) => { + console.log(response) + this.startGame = false + return eventBus.emit('Updatebalance') + }) + } + }, async clickedBtnChoice(index, content) { this.clickedBtn = index if (content === 'max') {