From dd79c8387d7c60ade2948aafd2cab9cbc532210a Mon Sep 17 00:00:00 2001 From: Tiyo Date: Tue, 7 Nov 2023 19:14:38 +0800 Subject: [PATCH] fix: fix bug --- packages/client/src/mud/createSystemCalls.ts | 1 + packages/client/src/pages/game/index.tsx | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/client/src/mud/createSystemCalls.ts b/packages/client/src/mud/createSystemCalls.ts index 979180b1..157e0893 100644 --- a/packages/client/src/mud/createSystemCalls.ts +++ b/packages/client/src/mud/createSystemCalls.ts @@ -68,6 +68,7 @@ export function createSystemCalls( const tx = await worldContract.write.battleInvitation([addr, steps]); await waitForTransaction(tx); console.log('battleInvitation success', new Date().getTime(), tx); + return tx } catch (error) { console.log('battleInvitation', error); message.error(error.cause.reason || error.cause.details); diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index ae3aa1a4..b321510a 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -389,10 +389,12 @@ const Game = () => { const setStartBattle = async (player) => { const paths = bfs(simpleMapData, { x: curPlayer.x, y: curPlayer.y }, {x: player.x, y: player.y}).slice(1); - await battleInvitation(player.addr, formatMovePath(paths)); - setTargetPlayer(player); - setBattleCurPlayer(curPlayer) - setStartBattleData(true); + let res = await battleInvitation(player.addr, formatMovePath(paths)); + if (res) { + setTargetPlayer(player); + setBattleCurPlayer(curPlayer) + setStartBattleData(true); + } } const openTreasureChest = async (id) => {