diff --git a/client/dev-dist/sw.js b/client/dev-dist/sw.js index 096d6781..f5cd8392 100644 --- a/client/dev-dist/sw.js +++ b/client/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-20a2f87f'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.shqbum89m38" + "revision": "0.o26d1okn5o8" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/client/src/components/FlappyBeasts/flappyBeasts.tsx b/client/src/components/FlappyBeasts/flappyBeasts.tsx index e16afd11..5a0215e8 100644 --- a/client/src/components/FlappyBeasts/flappyBeasts.tsx +++ b/client/src/components/FlappyBeasts/flappyBeasts.tsx @@ -62,6 +62,7 @@ const BIRD_COLLIDER_OFFSET_Y = (BIRD_HEIGHT - BIRD_COLLIDER_HEIGHT) / 2; // Types and Interfaces import { FlappyBirdRefHandle, FlappyBirdProps } from '../../types/components'; +import { Account } from 'starknet'; const FlappyBirdMiniGame = forwardRef(({ className = '', @@ -168,20 +169,11 @@ const FlappyBirdMiniGame = forwardRef(({ await handleAction( "SaveGameResults", async () => { - await client.player.updatePlayerTotalPoints( - account, - score - ) - await client.player.updatePlayerMinigameHighestScore( - account, - score, - 2 - ) - await client.player.addOrUpdateFoodAmount( - account, - foodId, - foodCollected - ) + await client.player.updatePlayerTotalPoints(account, score); + const txtest = await client.achieve.achievePlayerNewTotalPoints(account); + console.info('achievePlayerNewTotalPoints fkaooy', txtest); + await client.player.updatePlayerMinigameHighestScore(account, score, 2); + await client.player.addOrUpdateFoodAmount(account, foodId, foodCollected); }); return true; } else { @@ -217,15 +209,16 @@ const FlappyBirdMiniGame = forwardRef(({ }; // Handle game over - const handleGameEnd = () => { + const handleGameEnd = async () => { const score = currentScoreRef.current; setFinalScore(score); const dojoHighScore = myScoreFlappyBird.length > 0 ? myScoreFlappyBird[0]?.score : 0; const actualHighScore = Math.max(dojoHighScore, currentHighScore); - if (score > actualHighScore) { setCurrentHighScore(score); + const tx = await client.achieve.achieveFlappyBeastHighscore(account as Account, score); + console.info('tx flappy highscore', tx); } else { setCurrentHighScore(actualHighScore); } @@ -893,6 +886,8 @@ const FlappyBirdMiniGame = forwardRef(({ {currentScreen === 'sharing' && (
{ setIsShareModalOpen(false); diff --git a/client/src/components/Header/index.tsx b/client/src/components/Header/index.tsx index 3c66eb65..bf8b0d22 100644 --- a/client/src/components/Header/index.tsx +++ b/client/src/components/Header/index.tsx @@ -29,6 +29,7 @@ import download from "../../assets/img/icon-download.svg"; // Styles import './main.css'; +import { useDojoSDK } from "@dojoengine/sdk/react"; // Constants const WEBSITE_URL = 'https://website.bytebeasts.games'; @@ -56,8 +57,9 @@ const Header: React.FC = ({ tamagotchiStats }) => { // Hooks const { beastsData: beasts } = useBeasts(); const { player } = usePlayer(); + const { client } = useDojoSDK(); const location = useLocation(); - const { connector } = useAccount(); + const { account, connector } = useAccount(); const [buttonSound] = useSound(buttonClick, { volume: SOUND_VOLUME, preload: true }); // Derived state @@ -176,6 +178,8 @@ const Header: React.FC = ({ tamagotchiStats }) => { {tamagotchiStats && ( setIsShareModalOpen(false)} type="beast" diff --git a/client/src/components/SkyJumpMiniGame/index.tsx b/client/src/components/SkyJumpMiniGame/index.tsx index d98878b8..817d82bb 100644 --- a/client/src/components/SkyJumpMiniGame/index.tsx +++ b/client/src/components/SkyJumpMiniGame/index.tsx @@ -26,6 +26,7 @@ import { InputHandler } from './inputHandler'; import RestartIcon from '../../assets/img/icon-restart.svg'; import './main.css'; +import { Account } from 'starknet'; const CanvasSkyJumpGame = forwardRef(({ className = '', @@ -84,7 +85,7 @@ const CanvasSkyJumpGame = forwardRef { + const handleEngineGameOver = useCallback(async (engineFinalScore: number) => { setFinalScore(engineFinalScore); setIsGameOverState(true); @@ -92,6 +93,8 @@ const CanvasSkyJumpGame = forwardRef dojoHighScore) { setCurrentHighScore(engineFinalScore); + const tx = await client.achieve.achievePlatformHighscore(account as Account, engineFinalScore); + console.info('tx sky jump achievePlatformHighscore', tx); } else { setCurrentHighScore(dojoHighScore); } @@ -203,6 +206,9 @@ const CanvasSkyJumpGame = forwardRef setCurrentScreen('gameover')} type="minigame" diff --git a/client/src/components/SpawnBeast/index.tsx b/client/src/components/SpawnBeast/index.tsx index c97e9541..64188a9d 100644 --- a/client/src/components/SpawnBeast/index.tsx +++ b/client/src/components/SpawnBeast/index.tsx @@ -91,11 +91,9 @@ const SpawnBeast: React.FC = ({ className = '' }) => { // Recargar la lista de beasts usando GraphQL const beastsData = await fetchBeastsData(); const processedBeasts = await processBeastData(beastsData); - console.info('processedBeasts', processedBeasts); - + // Encontrar la bestia recién creada newBeast = processedBeasts.find((beast: Beast) => beast.player === account!.address); - console.info('newBeast', newBeast); await new Promise(resolve => setTimeout(resolve, 2000)); } while (!newBeast); diff --git a/client/src/components/Tamagotchi/Actions/index.tsx b/client/src/components/Tamagotchi/Actions/index.tsx index 7b94554b..f45fa34d 100644 --- a/client/src/components/Tamagotchi/Actions/index.tsx +++ b/client/src/components/Tamagotchi/Actions/index.tsx @@ -89,8 +89,7 @@ const Actions = ({ if (action === 'sleep') { await client.achieve.achieveBeastSleep(account as Account); } else if (action === 'clean') { - const txss = await client.achieve.achieveBeastClean(account as Account); - console.info('txss', txss); + await client.achieve.achieveBeastClean(account as Account); } }, beastsDex[beast.specie - 1][pictureKey] diff --git a/client/src/components/Tamagotchi/Chat/index.tsx b/client/src/components/Tamagotchi/Chat/index.tsx index 57bac745..7eaeb168 100644 --- a/client/src/components/Tamagotchi/Chat/index.tsx +++ b/client/src/components/Tamagotchi/Chat/index.tsx @@ -1,5 +1,6 @@ // React and external libraries import { useState, useRef } from "react"; +import { Account } from "starknet"; // Internal components import MessageComponent from "../../ui/message"; @@ -29,7 +30,7 @@ const context = `Remembre this is your context, `; -const Chat = ({ beast, expanded, botMessage, setBotMessage }: { beast: any, expanded: boolean, botMessage: any, setBotMessage: any }) => { +const Chat = ({ beast, expanded, botMessage, setBotMessage, client, account }: { beast: any, expanded: boolean, botMessage: any, setBotMessage: any, client: any, account: any }) => { const { isLoading, error, sendMessage } = useBeastChat({ beast, setBotMessage }); const [input, setInput] = useState(""); @@ -43,6 +44,8 @@ const Chat = ({ beast, expanded, botMessage, setBotMessage }: { beast: any, expa const handleSendMessage = async () => { if (input.trim() === "" || isLoading) return; + + await client.achieve.achieveBeastChat(account as Account); const messageWithContext = `${context}\n\nUser: ${input}`; await sendMessage(messageWithContext); diff --git a/client/src/components/Tamagotchi/Play/index.tsx b/client/src/components/Tamagotchi/Play/index.tsx index 5efe3320..200e72cb 100644 --- a/client/src/components/Tamagotchi/Play/index.tsx +++ b/client/src/components/Tamagotchi/Play/index.tsx @@ -48,6 +48,10 @@ const Play: React.FC = ({ } try { + + const tx = await client.achieve.achievePlayMinigame(account); + console.info('tx achievePlayMinigame', tx); + handleAction( "Play", async () => { diff --git a/client/src/components/Tamagotchi/index.tsx b/client/src/components/Tamagotchi/index.tsx index a61b727b..adfa9d2e 100644 --- a/client/src/components/Tamagotchi/index.tsx +++ b/client/src/components/Tamagotchi/index.tsx @@ -58,8 +58,6 @@ function Tamagotchi() { if (foundBeast) setCurrentBeast(foundBeast); }, [player, beasts]); - console.info('player', player); - const getShareableStats = () => { if (!currentBeast || !status) return undefined; @@ -141,6 +139,8 @@ function Tamagotchi() { /> ) : currentView === 'chat' ? ( = ({ @@ -28,6 +30,8 @@ export const ShareProgress: React.FC = ({ type, stats, minigameData, + account, + client, }) => { const [tweetMsg, setTweetMsg] = useState(""); @@ -35,7 +39,7 @@ export const ShareProgress: React.FC = ({ if (type === 'beast' && stats) { setTweetMsg( `🎮 Playing ByteBeasts Tamagotchi, and here is my Beast's progress:\n\n` + - `🕰️ Age: ${stats.age}` + ` ${stats.age == 1 ? 'day' : 'days' }\n` + + `🕰️ Age: ${stats.age}` + ` ${stats.age == 1 ? 'day' : 'days'}\n` + `⚡ Energy: ${stats.energy} \n` + `🍖 Hunger: ${stats.hunger} \n` + `😊 Happiness: ${stats.happiness} \n` + @@ -72,15 +76,15 @@ export const ShareProgress: React.FC = ({

Share on X

-
- +