From e74e51b35ea738f731fc0564fe6c1057edf1f758 Mon Sep 17 00:00:00 2001 From: Kostya Date: Fri, 19 Jan 2024 21:20:21 +0300 Subject: [PATCH] added request for get percentage-steps in saper-game --- .../src/assets/js/games/saper/SaperAPI.js | 28 +++++++++++++++++++ .../src/pages/games-pages/SapergamePage.vue | 23 ++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 luckydiamond/src/assets/js/games/saper/SaperAPI.js diff --git a/luckydiamond/src/assets/js/games/saper/SaperAPI.js b/luckydiamond/src/assets/js/games/saper/SaperAPI.js new file mode 100644 index 0000000..ce9a2ee --- /dev/null +++ b/luckydiamond/src/assets/js/games/saper/SaperAPI.js @@ -0,0 +1,28 @@ +import { BackendApiUrl } from '@/properties/Сonfig.js'; + +export async function GetPercentageSteps(CrystalsCount) { + const data = { + minesCount: CrystalsCount + } + + try { + const response = await fetch(`${BackendApiUrl}/GameMines/GetMultiplierPercentage`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data), + redirect: 'follow' + }) + + if (!response.ok) { + console.log('Fetch error:', response.status) + } + + console.log(response) + return await response.json() + } + catch (error) { + console.log('Fetch Error!') + } +} \ No newline at end of file diff --git a/luckydiamond/src/pages/games-pages/SapergamePage.vue b/luckydiamond/src/pages/games-pages/SapergamePage.vue index d0bb70b..d347bdc 100644 --- a/luckydiamond/src/pages/games-pages/SapergamePage.vue +++ b/luckydiamond/src/pages/games-pages/SapergamePage.vue @@ -136,6 +136,7 @@ import ChatComponent from "@/components/ChatComponent.vue"; import AsideBarElement from "@/components/AsidebarComponent.vue"; import HeaderElementPage from "@/components/HeaderComponent.vue"; +import { GetPercentageSteps } from "@/assets/js/games/saper/SaperAPI"; import { Swiper, SwiperSlide } from 'swiper/vue'; import 'swiper/css'; @@ -153,13 +154,33 @@ export default { clickedBtn: '', clickedBtnCrystal : '', amountCrystals: 5, + amountSaveCrystals: 0, balance: 1000, amountDeposit: 5, flippedCards: [], - + PercentageGameSteps: [], modules: [ Pagination ] } }, + watch: { + PercentageGameSteps(CrystalsCount) { + if (CrystalsCount >= 1) { + this.amountSaveCrystals = CrystalsCount + setTimeout(() => { + try { + GetPercentageSteps(this.amountSaveCrystals) + .then((response) => { + this.PercentageGameSteps.push(response) + console.log(response) + }) + } + catch (e) { + console.error('Error in Percantage', e) + } + }, 1500) + } + } + }, methods: { flipCard(index) { if (this.flippedCards.includes(index)) {