diff --git a/packages/client/src/mud/createSystemCalls.ts b/packages/client/src/mud/createSystemCalls.ts index f46ef64a..2c933e5c 100644 --- a/packages/client/src/mud/createSystemCalls.ts +++ b/packages/client/src/mud/createSystemCalls.ts @@ -9,6 +9,8 @@ import { SetupNetworkResult } from "./setupNetwork"; import eventEmitter from '../utils/eventEmitter'; import { message } from 'antd'; +import { delay } from '../utils/delay'; + export type SystemCalls = ReturnType; let wait = false; @@ -78,6 +80,7 @@ export function createSystemCalls( try { const tx = await worldContract.write.selectBothNFT([userTokenId, lootTokenId]); await waitForTransaction(tx); + await delay(300) return { playerData: useStore.getState().getValue(tables.PlayerParams, { addr: address }), lootData: useStore.getState().getValue(tables.LootList1, { addr: address }) @@ -176,6 +179,7 @@ export function createSystemCalls( eventEmitter.emit('log', log) console.log('revealBox success', new Date().getTime(), tx); wait = false + await delay(300) return useStore.getState().getValue(tables.BoxList, { boxId }) } catch (error) { console.log(error) @@ -201,6 +205,7 @@ export function createSystemCalls( log.block = await getBlockNumber(tx) eventEmitter.emit('log', log) wait = false + await delay(300) return { type: 'success' } @@ -256,6 +261,7 @@ export function createSystemCalls( log.block = await getBlockNumber(tx) eventEmitter.emit('log', log) wait = false + await delay(300) return { type: 'success', data: useStore.getState().getValue(tables.BattleList, { battleId }) @@ -288,6 +294,7 @@ export function createSystemCalls( log.block = await getBlockNumber(tx) eventEmitter.emit('log', log) wait = false + await delay(300) return { type: 'success', data: useStore.getState().getValue(tables.BattleList, { battleId }) @@ -320,6 +327,7 @@ export function createSystemCalls( log.block = await getBlockNumber(tx) eventEmitter.emit('log', log) wait = false + await delay(300) return useStore.getState().getValue(tables.BattleList, { battleId }) } catch (error) { log.type = 'error' diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index 662fb9dd..c68aeffc 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -23,6 +23,7 @@ import Loading from '@/components/Loading'; import {BLOCK_TIME} from '@/config/chain'; import discordImg from '@/assets/img/discord.png'; import { TALK_MAIN } from '@/config/talk'; +import { delay } from '../../utils/delay'; const toObject = (obj) => { return JSON.parse(JSON.stringify(obj, (key, value) => @@ -91,6 +92,7 @@ const Game = () => { let lootContractAddress = GlobalConfigData[0].lootContract userContract = new ethers.Contract(userContractAddress, userAbi, wallet) lootContract = new ethers.Contract(lootContractAddress, lootAbi, wallet) + percentage = 100 } const LootList1Data = useStore((state: any) => { @@ -156,8 +158,6 @@ const Game = () => { }) }); - if (PlayersData.length && PlayersData[0].hp) percentage = 100 - const curPlayer = PlayersData.find((player: any) => player.addr.toLocaleLowerCase() == account.toLocaleLowerCase()); if (curPlayer && curPlayer.state == 0 && percentage == 100) { navigate('/'); diff --git a/packages/client/src/pages/test/index.jsx b/packages/client/src/pages/test/index.jsx index be0c7ea7..15157119 100644 --- a/packages/client/src/pages/test/index.jsx +++ b/packages/client/src/pages/test/index.jsx @@ -400,11 +400,11 @@ const Test = () => { { players.map((item, index) => (
用户信息 {item.isMe ? '(自己)' : ''}
-
addr: {item.addr}
-
hp: {item.hp.toString()}
-
attack: {item.attack.toString()}
-
oreBalance: {item.oreBalance.toString()}
-
treasureBalance: {item.treasureBalance.toString()}
+
addr: {item?.addr}
+
hp: {item?.hp?.toString()}
+
attack: {item?.attack?.toString()}
+
oreBalance: {item?.oreBalance?.toString()}
+
treasureBalance: {item?.treasureBalance?.toString()}
state:{item?.state}
坐标:{item?.x || 0},{item?.y || 0}
)) @@ -415,11 +415,11 @@ const Test = () => { { boxs.map((item, index) => (
宝箱信息
-
id: {item.id}
-
opened: {item.opened.toString()}
-
owner: {item.owner}
-
oreBalance: {item.opened ? item.oreBalance : '--'}
-
treasureBalance: {item.opened ? item.treasureBalance : '--'}
+
id: {item?.id}
+
opened: {item?.opened.toString()}
+
owner: {item?.owner}
+
oreBalance: {item?.opened ? item?.oreBalance : '--'}
+
treasureBalance: {item?.opened ? item?.treasureBalance : '--'}
坐标:{item?.x || 0},{item?.y || 0}
)) } diff --git a/packages/contracts/worlds.json b/packages/contracts/worlds.json index d4145083..ad7ae920 100644 --- a/packages/contracts/worlds.json +++ b/packages/contracts/worlds.json @@ -1,6 +1,6 @@ { "31337": { - "address": "0x6e9474e9c83676b9a71133ff96db43e7aa0a4342" + "address": "0xe233198863b75acc6e1af43daff3f5918e35875e" }, "33784": { "address": "0xe233198863b75acc6e1af43daff3f5918e35875e",