diff --git a/packages/client/src/components/UserInfo/index.tsx b/packages/client/src/components/UserInfo/index.tsx
index 935b222a..52d7037c 100644
--- a/packages/client/src/components/UserInfo/index.tsx
+++ b/packages/client/src/components/UserInfo/index.tsx
@@ -16,7 +16,7 @@ export interface IUserInfo {
const UserInfo = (props: IUserInfo) => {
const { handheld, head, clothes, gem = 0, userUrl, lootUrl, player } = props;
- const lootHasLoaded = handheld && head && clothes;
+ const lootHasLoaded = (handheld && head && clothes) || (player?.equip?.handheld && player?.equip?.head && player?.equip?.clothes);
console.log(handheld, head, clothes, lootHasLoaded);
return (
@@ -26,7 +26,7 @@ const UserInfo = (props: IUserInfo) => {
@@ -44,7 +44,7 @@ const UserInfo = (props: IUserInfo) => {
- HP
- - {lootHasLoaded ? player?.maxHp?.toString() : 0}{lootHasLoaded ? player?.maxHp?.toString() : ''}
+ - {lootHasLoaded ? player?.maxHp : 0}{lootHasLoaded ? player?.maxHp?.toString() : ''}
- Attack
diff --git a/packages/client/src/components/UserInfoDialog/index.tsx b/packages/client/src/components/UserInfoDialog/index.tsx
index 85304b58..0e7b265b 100644
--- a/packages/client/src/components/UserInfoDialog/index.tsx
+++ b/packages/client/src/components/UserInfoDialog/index.tsx
@@ -13,7 +13,7 @@ const UserInfoDialog = (props: IProps) => {
return (
-
+
);
diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx
index 2791f5cc..2eb45bf1 100644
--- a/packages/client/src/pages/game/index.tsx
+++ b/packages/client/src/pages/game/index.tsx
@@ -243,7 +243,9 @@ const Game = () => {
const target = paths[pathIndex - 1];
const isDelivery = DELIVERY.x === target.x && DELIVERY.y === target.y;
if (isDelivery) {
- setUserInfoPlayer(curPlayer);
+ let cur = localStorage.getItem('playerInfo');
+ if (cur) cur = JSON.parse(cur);
+ setUserInfoPlayer(cur || curPlayer);
submitGem();
}
}
@@ -258,6 +260,12 @@ const Game = () => {
};
const showUserInfo = (player) => {
+ console.log(player);
+ if (player.addr.toLocaleLowerCase() == account.toLocaleLowerCase()) {
+ let cur = localStorage.getItem('playerInfo');
+ if (cur) player = JSON.parse(cur);
+ }
+
setUserInfoPlayer(player);
setUserInfoVisible(true);
}
@@ -390,7 +398,7 @@ const Game = () => {
setUserInfoVisible(false);
}}
gem={userInfoPlayer.gem}
- {...userInfoPlayer.equip}
+ {...userInfoPlayer}
/>
)
}
diff --git a/packages/client/src/pages/home/index.tsx b/packages/client/src/pages/home/index.tsx
index 647de925..983a050b 100644
--- a/packages/client/src/pages/home/index.tsx
+++ b/packages/client/src/pages/home/index.tsx
@@ -166,6 +166,11 @@ const Home = () => {
return url
}
+ const toObject = (obj) => {
+ return JSON.parse(JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value
+ ))
+}
+
const mintAndGo = async () => {
setMinting(true);
try {
@@ -199,6 +204,10 @@ const Home = () => {
setClothes(clothes);
setHandheld(handheld);
setHead(head);
+
+ let player = Object.assign(playerData, {username, clothes, handheld, head, userUrl: url.image, lootUrl: lootUrl.image})
+ console.log(player, 'player')
+ localStorage.setItem('playerInfo', JSON.stringify(toObject(player)));
let result = await Promise.all([setInfo(username, ''), joinBattlefield()])
console.log(result, 'result')