From f372533e0b849c289aa1db19f696de06a83f6bbf Mon Sep 17 00:00:00 2001 From: LidamaoHub Date: Tue, 24 Oct 2023 17:58:26 +0800 Subject: [PATCH 01/11] Update: --- packages/contracts/.DS_Store | Bin 6148 -> 6148 bytes packages/contracts/jsTest/tools.js | 30 ++++++++++++++--------------- packages/contracts/worlds.json | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/contracts/.DS_Store b/packages/contracts/.DS_Store index 99d1970197fc642c8d045c41c4188805f5bf2cab..5c62b95dfa7ed06829463f4e74d4360fb183e247 100644 GIT binary patch delta 14 VcmZoMXffEJ&Bz$DS%>k47yu%O1aJTV delta 14 VcmZoMXffEJ&B)lfS%>k47yu)d1f2i? diff --git a/packages/contracts/jsTest/tools.js b/packages/contracts/jsTest/tools.js index 7690af30..1feffaca 100644 --- a/packages/contracts/jsTest/tools.js +++ b/packages/contracts/jsTest/tools.js @@ -60,22 +60,22 @@ function getStr(bytes32Value) { } function getMudEvent(args){ - // console.log(args) -// let name = getStr(args[0]); -// console.log(name) -// abiDecoder.addABI(contractABI); -// const decodedData = abiDecoder.decodeMethod(args.data); -// let a = args[1].forEach((e) => { -// console.log(e) -// return getStr(e); -// }) -// console.log(a) -// console.log(decodedData); -// // let i = bytesToString(args[3]); + console.log(args) + let name = getStr(args[0]); + console.log(name) + abiDecoder.addABI(contractABI); + const decodedData = abiDecoder.decodeMethod(args.data); + let a = args[1].forEach((e) => { + console.log(e) + return getStr(e); + }) + console.log(a) +console.log(decodedData); + // let i = bytesToString(args[3]); -// // console.log(a) -// console.log(args[2]) -// console.log(i) + // console.log(a) + console.log(args[2]) + console.log(i) } async function run(name, func) { diff --git a/packages/contracts/worlds.json b/packages/contracts/worlds.json index 6aced72a..445865fc 100644 --- a/packages/contracts/worlds.json +++ b/packages/contracts/worlds.json @@ -4,7 +4,7 @@ "blockNumber": 27950347 }, "31337": { - "address": "0x0712629Ced85A3A62E5BCa96303b8fdd06CBF8dd" + "address": "0xB5AFb7CD0FaDDD27785dFb9bC02Cc5E4C3D4378e" }, "421613": { "address": "0x2Bc1034975c3df48D6f3026802f372677844b85d", From c178c30fee240b96e27dabf3c56ad320f9b4c0bf Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 03:27:19 +0800 Subject: [PATCH 02/11] fix: change the duck's default body --- .../client/src/assets/img/duck_default.png | Bin 5609 -> 7066 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/packages/client/src/assets/img/duck_default.png b/packages/client/src/assets/img/duck_default.png index 879d5899bb3a248d6dbb8909ab6f27d2d5425cb3..659ee2ac0ba864ddf8d555f67469650eb61c4b67 100644 GIT binary patch literal 7066 zcmc&(^;cBUx4$zCEhQi=r2^6+AdS*UC=DZsq#)frq|zYB&?TiPgNk$`-HqhH5YjdD zz`XJM*830MTknUn&OK}0z4zIB-}~90eNMElwkjD3BMATiWa?^4F8~09djtVQ1h@(6 zUS^A%7(A7YJ@s5{J$)?QZ2(1Um)ACI>Q0t+HZN=}t^M43ZDas|Nk&~sQQvoVCx$bXq8#;liGQ*GFrRnp$NLyUcVAe2 z3|CA!m?Vb8J!U>4f-}l>HGBRVVf0eg^9jsa#}#U+t)jqVnzOlP~5?cB5kP z0I(QM3kLuq+#bOI0K-jexbgqARKS_0#0>~;;9~f{zl3ccwB0XbAf&ik^xdkv{?f^* z-JfKelTXpO?Dn>ZC0FDw&FQB~{&umdFzr{b*!ayG(>XXf-GtcyuczML;z3utH5L91 zCG8&~j7l087t+|yC;0gIwLI*A*WafmFISWgsY8BLwh%iSR)huy zu2K)${(Np}$(|$S6{Df4xppn^HS0$UsoA}^)s?qgoMMs4S3F<~m6nco#WTHGsQ0RJn0%@x|EQ+tzePzEE^-whQmvh zm6bnc&CE6WdHk9W#b5&Yd3bs;cS+d*p<3Xi|CV{hdbnL)P?~A=Ta(RL-(Ep(?jE-x z$GJccBf^B30POYI=b)?8u9_}VrpO0?D`?9O(n=ljC$RSlz3I`$b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X(HYq^{J3hYVRzaE(yBA_Z?^B)CW>IR8 zpK@C6Qwt@|vApbI9C_Yzy3(%X^5ACSa3}pm0x_4QZ2#e?smV4q_ThT(hVP5aBe5~n zrI!_!*y(;6Ui9&RY^D*H@AGopd~7k+Rzz_ri(WK;>Nw-bt@#kh8Bnm>pdgk~SRvC9 zqdyF@irbq}VuQkFZ6?EJJvM$tVURQAeUWIsg_t~e{^PyK_{*&xj75*?pWC>y@ypk_ z^&}sTFW(=cJ$luRC}oS05eigRCgL&osN0?hC`Yhd#FuOyS8GiMm0S8!(BsaflS{j5 z96E+a%YhD)I+KYc_++{$EI?UpYj(j0@@=+OxCbDPLq(8Y;ltZ$`^}wpY#|eOAKt4_ z9#%nr;`P7h6qmorg)m=j{$7J(EOYHZ$`;m{K1AcuteYvCfnhrq*7$5!tl^W50 zCge9rK?UC&8?1oP;&Zh29N*T$+wJUg#czs~`du@hO6U@%xgdXsSA2oUVznqf3+O(g z*>ePH=vfUfM} zxdrnNpj#aF{kd)iads@gm}p{m)16muc=;H`pUnzxXq}53xDhlY74F2Sr{#Npe46KM zMA*4ik(5W-d4e5(Ccr-!;%#~3vx#g%{*oX^%{K4M;zi}lo!e~zu{ek{O|m}}kA)HJqd=bgbcJN4@9 z+dsj6hjT;t-}@rTE!*3@wHsv{pabAf+LuIT!qf9S)opEU++81S1$}MGbmMY@mb5WW zGgNgh?HOFT9xd)p*#@u0UqJHzm(d}825NDRY90>)!Y5}(ymIOT=@U`F*uYHxqpoYh F{{Y=<8*=~v From 0adafc51bfb48cbbcd60f80269b59e1b3cd2db7b Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 03:32:56 +0800 Subject: [PATCH 03/11] fix: scale the duck to 1.8 --- packages/client/src/components/Player/styles.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/client/src/components/Player/styles.scss b/packages/client/src/components/Player/styles.scss index c2757484..f4b85b16 100644 --- a/packages/client/src/components/Player/styles.scss +++ b/packages/client/src/components/Player/styles.scss @@ -12,7 +12,13 @@ display: flex; font-size: 16px; font-family: MISS, sans-serif; + left: 0; bottom: 100%; + width: 100%; + } + + .mi-appearance-wrapper { + transform: scale(1.8); } .gem-num { @@ -22,7 +28,9 @@ } .player-username { + flex: 1; color: #000; + text-align: center; text-shadow: #fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0; } From bb88af64bb9dfbd947ddb00f558129ce79177404 Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 04:24:09 +0800 Subject: [PATCH 04/11] fix: add loading tip when the user mint loot --- packages/client/src/common.scss | 4 ++++ .../client/src/components/UserInfo/index.tsx | 23 ++++++++++--------- packages/client/src/pages/home/index.tsx | 23 +++++++++++-------- packages/client/src/type/index.d.ts | 5 ++++ packages/client/src/utils/delay.ts | 14 +++++++++++ packages/client/src/utils/index.ts | 3 ++- 6 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 packages/client/src/type/index.d.ts create mode 100644 packages/client/src/utils/delay.ts diff --git a/packages/client/src/common.scss b/packages/client/src/common.scss index e0259f7f..0ec5c75a 100644 --- a/packages/client/src/common.scss +++ b/packages/client/src/common.scss @@ -56,6 +56,10 @@ button { unicode-range: U+0025-00FF; } +button[disabled] { + cursor: not-allowed; +} + .mi-btn { position: relative; font-family: MISS, sans-serif; diff --git a/packages/client/src/components/UserInfo/index.tsx b/packages/client/src/components/UserInfo/index.tsx index 6d3e91f6..5c6ea5de 100644 --- a/packages/client/src/components/UserInfo/index.tsx +++ b/packages/client/src/components/UserInfo/index.tsx @@ -7,13 +7,14 @@ export interface IUserInfo { head: string; clothes: string; handheld: string; - minting?: boolean; - gem: number; + gem?: number; } const UserInfo = (props: IUserInfo) => { - const { handheld, head, clothes, minting = false, gem } = props; + const { handheld, head, clothes, gem = 0 } = props; + const lootHasLoaded = handheld && head && clothes; + console.log(handheld, head, clothes, lootHasLoaded); return (
@@ -25,7 +26,7 @@ const UserInfo = (props: IUserInfo) => {
-
+
@@ -33,30 +34,30 @@ const UserInfo = (props: IUserInfo) => {
-
+
HP
-
{minting ? 0 : 100}100
+
{lootHasLoaded ? 100 : 0}100
Attack
-
{minting ? 0 : 20}1
+
{lootHasLoaded ? 20 : 0}1
AttackRange
-
{minting ? 0 : 5}1
+
{lootHasLoaded ? 5 : 0}1
Speed
-
{minting ? 0 : 2}2
+
{lootHasLoaded ? 2 : 0}2
Strength
-
{minting ? 0 : 20}1
+
{lootHasLoaded ? 20 : 0}1
Space
-
{minting ? 0 : 10}1
+
{lootHasLoaded ? 10 : 0}1
diff --git a/packages/client/src/pages/home/index.tsx b/packages/client/src/pages/home/index.tsx index 44299792..da467cd6 100644 --- a/packages/client/src/pages/home/index.tsx +++ b/packages/client/src/pages/home/index.tsx @@ -10,6 +10,7 @@ import { UserAddress } from '@/mock/data'; import { UserAddressKey } from '@/config'; import { useNavigate } from 'react-router-dom'; import Duck from '@/config/duck'; +import { delay } from '@/utils'; const Home = () => { @@ -20,7 +21,7 @@ const Home = () => { title: '', }); - const [minting, setMinting] = useState(true); + const [minting, setMinting] = useState(false); const navigate = useNavigate(); @@ -80,13 +81,14 @@ const Home = () => { const clothes = Duck.Clothes[~~(Math.random() * Duck.Clothes.length)]; const handheld = Duck.HandHeld[~~(Math.random() * Duck.HandHeld.length)]; const head = Duck.Head[~~(Math.random() * Duck.Head.length)]; - setClothes(clothes); - setHandheld(handheld); - setHead(head); - setMinting(false); + setMinting(true); - setTimeout(() => { + delay(1000).then(() => { + setClothes(clothes); + setHandheld(handheld); + setHead(head); + }).delay(3000).then(() => { navigate('/game', { state: { username, @@ -95,7 +97,8 @@ const Home = () => { head, } }); - }, 3000) + }) + } const play = () => { @@ -136,8 +139,10 @@ const Home = () => {

HOME

- - + +
) diff --git a/packages/client/src/type/index.d.ts b/packages/client/src/type/index.d.ts new file mode 100644 index 00000000..a3f1a369 --- /dev/null +++ b/packages/client/src/type/index.d.ts @@ -0,0 +1,5 @@ +declare global { + interface Promise { + delay: (t: number) => Promise + } +} \ No newline at end of file diff --git a/packages/client/src/utils/delay.ts b/packages/client/src/utils/delay.ts new file mode 100644 index 00000000..02bee9c8 --- /dev/null +++ b/packages/client/src/utils/delay.ts @@ -0,0 +1,14 @@ +type Resolver = (value: T | PromiseLike) => void; + +export const delay = (t: number, v?: T): Promise => { + return new Promise((resolve: Resolver) => { + setTimeout(resolve.bind(null, v), t) + }) +}; + +Promise.prototype.delay = function(t) { + return this.then(function(v?: any) { + return delay(t, v); + }); +}; + diff --git a/packages/client/src/utils/index.ts b/packages/client/src/utils/index.ts index cd6829f0..a9d5016c 100644 --- a/packages/client/src/utils/index.ts +++ b/packages/client/src/utils/index.ts @@ -1 +1,2 @@ -export { cutMapData, loadMapData, getCellClass, isMovable } from './map' \ No newline at end of file +export { cutMapData, loadMapData, getCellClass, isMovable } from './map'; +export { delay } from './delay'; \ No newline at end of file From bec1731387d427363dfba27aeaf0c959fbbe46d5 Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 04:42:17 +0800 Subject: [PATCH 05/11] fix: update the player's toward when it moves --- packages/client/src/components/Appearance/index.tsx | 6 ++++-- .../client/src/components/Appearance/styles.scss | 1 + packages/client/src/components/Player/index.tsx | 7 +++++-- packages/client/src/components/Player/styles.scss | 4 ++++ packages/client/src/pages/game/index.tsx | 3 ++- packages/client/src/utils/player.ts | 12 ++++++++++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 packages/client/src/utils/player.ts diff --git a/packages/client/src/components/Appearance/index.tsx b/packages/client/src/components/Appearance/index.tsx index cd96f1b6..e616e44c 100644 --- a/packages/client/src/components/Appearance/index.tsx +++ b/packages/client/src/components/Appearance/index.tsx @@ -1,19 +1,21 @@ import React from 'react'; import './styles.scss'; import userImg from '@/assets/img/duck_default.png'; +import { PlayerToward } from '@/components/Player'; interface IProps { head?: string; clothes?: string; handheld?: string; + toward?: PlayerToward; } const Appearance = (props: IProps) => { - const { handheld, head, clothes } = props; + const { handheld, head, clothes, toward } = props; return ( -
+
{ clothes && diff --git a/packages/client/src/components/Appearance/styles.scss b/packages/client/src/components/Appearance/styles.scss index 516cea52..2550faf4 100644 --- a/packages/client/src/components/Appearance/styles.scss +++ b/packages/client/src/components/Appearance/styles.scss @@ -2,6 +2,7 @@ position: relative; width: 100%; height: 100%; + z-index: 1; img { position: absolute; diff --git a/packages/client/src/components/Player/index.tsx b/packages/client/src/components/Player/index.tsx index 0359dbe4..c0d7b385 100644 --- a/packages/client/src/components/Player/index.tsx +++ b/packages/client/src/components/Player/index.tsx @@ -4,12 +4,15 @@ import { CurIdMockData } from '@/mock/data'; import Fog from '@/components/Fog'; import Appearance from '@/components/Appearance'; +export type PlayerToward = 'Left' | 'Right'; + export interface IPlayer { x: number; y: number; id: number; username: string; gem: number; + toward?: PlayerToward; equip: { head: string; handheld: string; @@ -19,7 +22,7 @@ export interface IPlayer { const Player = (props: IPlayer) => { - const { username, id, equip, gem = 0 } = props; + const { username, id, equip, gem = 0, toward } = props; return (
@@ -29,7 +32,7 @@ const Player = (props: IPlayer) => { {username}
- + { id === CurIdMockData && } diff --git a/packages/client/src/components/Player/styles.scss b/packages/client/src/components/Player/styles.scss index f4b85b16..270f566f 100644 --- a/packages/client/src/components/Player/styles.scss +++ b/packages/client/src/components/Player/styles.scss @@ -19,6 +19,10 @@ .mi-appearance-wrapper { transform: scale(1.8); + + &.appearance-right { + transform: rotateY(180deg) scale(1.8); + } } .gem-num { diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index e75212c5..7b4cdde3 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -19,6 +19,7 @@ import TreasureChest from '@/components/TreasureChest'; import UserInfo from '@/components/UserInfo'; import UserInfoDialog from '@/components/UserInfoDialog'; import { DELIVERY } from '@/config/map'; +import { updatePlayerPosition } from '@/utils/player'; const Game = () => { const [renderMapData, setRenderMapData] = useState([]); @@ -88,7 +89,7 @@ const Game = () => { let pathIndex = 0; const interval = setInterval(() => { triggerVertexUpdate(paths[pathIndex], curPlayer); - Object.assign(curPlayer, paths[pathIndex]); + updatePlayerPosition(curPlayer, paths[pathIndex]); pathIndex++; setPlayers([...players]); if (pathIndex === paths.length) { diff --git a/packages/client/src/utils/player.ts b/packages/client/src/utils/player.ts new file mode 100644 index 00000000..6dcb858f --- /dev/null +++ b/packages/client/src/utils/player.ts @@ -0,0 +1,12 @@ +import { IPlayer } from '@/components/Player'; + +export const updatePlayerPosition = (player: IPlayer, next: IPlayer) => { + const updateX = player.x - next.x; + const toward = updateX === 0 ? undefined : ( + updateX < 0 ? 'Right' : 'Left' + ); + Object.assign(player, next); + if (toward) { + player.toward = toward; + } +} \ No newline at end of file From 58cdbb05cdd36f708af00406ccedb38b1b83d75a Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 04:52:29 +0800 Subject: [PATCH 06/11] fix: Tool function detachment --- packages/client/src/pages/game/index.tsx | 39 ++---------------------- packages/client/src/utils/map.ts | 39 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index 7b4cdde3..b3f36299 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -20,6 +20,7 @@ import UserInfo from '@/components/UserInfo'; import UserInfoDialog from '@/components/UserInfoDialog'; import { DELIVERY } from '@/config/map'; import { updatePlayerPosition } from '@/utils/player'; +import { triggerVertexUpdate } from '@/utils/map'; const Game = () => { const [renderMapData, setRenderMapData] = useState([]); @@ -88,7 +89,7 @@ const Game = () => { const movePlayer = (paths, merkelData) => { let pathIndex = 0; const interval = setInterval(() => { - triggerVertexUpdate(paths[pathIndex], curPlayer); + setVertexCoordinate(triggerVertexUpdate(paths[pathIndex], curPlayer, mapDataRef.current, vertexCoordinate)); updatePlayerPosition(curPlayer, paths[pathIndex]); pathIndex++; setPlayers([...players]); @@ -193,42 +194,6 @@ const Game = () => { open(); } - const triggerVertexUpdate = (cur, before) => { - const xDegree = cur.x - before.x; - const yDegree = cur.y - before.y; - const mapData = mapDataRef.current; - if (xDegree === 1) { - const limitExceeded = cur.x - vertexCoordinate.x > LimitSpace.x; - const lessBoundary = - vertexCoordinate.x + MapConfig.visualWidth < mapData[0].length - 1; - if (limitExceeded && lessBoundary) { - vertexCoordinate.x++; - } - } else if (xDegree === -1) { - const limitExceeded = cur.x - vertexCoordinate.x < LimitSpace.x; - const lessBoundary = vertexCoordinate.x > 0; - if (limitExceeded && lessBoundary) { - vertexCoordinate.x--; - } - } else if (yDegree === 1) { - const limitExceeded = cur.y - vertexCoordinate.y > LimitSpace.y; - const lessBoundary = - vertexCoordinate.y + MapConfig.visualHeight < mapData.length - 1; - if (limitExceeded && lessBoundary) { - vertexCoordinate.y++; - } - } else if (yDegree === -1) { - const limitExceeded = cur.y - vertexCoordinate.y < LimitSpace.y; - const lessBoundary = vertexCoordinate.y > 0; - if (limitExceeded && lessBoundary) { - vertexCoordinate.y--; - } - } - - setVertexCoordinate({ - ...vertexCoordinate, - }); - }; useEffect(() => { loadMapData().then((csv) => { diff --git a/packages/client/src/utils/map.ts b/packages/client/src/utils/map.ts index 0e513b00..edaaa0f9 100644 --- a/packages/client/src/utils/map.ts +++ b/packages/client/src/utils/map.ts @@ -2,6 +2,7 @@ import { CellType } from '@/constants'; import { ICoordinate } from '@/components/MapCell'; import { IPlayer } from '@/components/Player'; import MAP_CFG from '@/config/map'; +import { LimitSpace, MapConfig } from '@/config'; export const cutMapData = (mapData, startCoordinate, endCoordinate) => { const { x: startX, y: startY} = startCoordinate; @@ -367,4 +368,40 @@ export const simplifyMapData = (mapData: number[][]) => { return mapData; } return mapData.map((row) => row.map(type => isMovable(type) ? 1 : 0)); -} \ No newline at end of file +} + +export const triggerVertexUpdate = (cur, before, mapData, vertexCoordinate) => { + const xDegree = cur.x - before.x; + const yDegree = cur.y - before.y; + if (xDegree === 1) { + const limitExceeded = cur.x - vertexCoordinate.x > LimitSpace.x; + const lessBoundary = + vertexCoordinate.x + MapConfig.visualWidth < mapData[0].length - 1; + if (limitExceeded && lessBoundary) { + vertexCoordinate.x++; + } + } else if (xDegree === -1) { + const limitExceeded = cur.x - vertexCoordinate.x < LimitSpace.x; + const lessBoundary = vertexCoordinate.x > 0; + if (limitExceeded && lessBoundary) { + vertexCoordinate.x--; + } + } else if (yDegree === 1) { + const limitExceeded = cur.y - vertexCoordinate.y > LimitSpace.y; + const lessBoundary = + vertexCoordinate.y + MapConfig.visualHeight < mapData.length - 1; + if (limitExceeded && lessBoundary) { + vertexCoordinate.y++; + } + } else if (yDegree === -1) { + const limitExceeded = cur.y - vertexCoordinate.y < LimitSpace.y; + const lessBoundary = vertexCoordinate.y > 0; + if (limitExceeded && lessBoundary) { + vertexCoordinate.y--; + } + } + + return({ + ...vertexCoordinate, + }); +}; \ No newline at end of file From 46301c5e611e5c6d763342137dc1b788c9c50f0b Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 05:10:27 +0800 Subject: [PATCH 07/11] fix: add user info --- .../client/src/components/MapCell/index.tsx | 7 ++--- packages/client/src/pages/game/index.tsx | 26 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/client/src/components/MapCell/index.tsx b/packages/client/src/components/MapCell/index.tsx index 5242b895..3b318af8 100644 --- a/packages/client/src/components/MapCell/index.tsx +++ b/packages/client/src/components/MapCell/index.tsx @@ -32,7 +32,6 @@ interface IProps { players?: IPlayer[]; treasureChest?: ITreasureChest[]; onMoveTo: (ICoordinate) => void; - openTreasureChest: (id: number) => void; prevActionCoordinate: ICoordinate; onExeAction: (ICoordinate) => void; } @@ -43,7 +42,7 @@ const MapCell = (props: IProps) => { const [menuVisible, setMenuVisible] = useState(false); const [activePlayerId, setActivePlayerId] = useState(-1); - const { mapData, openTreasureChest, setStartBattle } = useContext(GameContext); + const { mapData, openTreasureChest, setStartBattle, showUserInfo } = useContext(GameContext); const isDelivery = DELIVERY.x === x && DELIVERY.y === y; @@ -78,14 +77,16 @@ const MapCell = (props: IProps) => { const exeAction = (e, action) => { e.stopPropagation(); setMenuVisible(false); + const activePlayer = players!.find((item) => item.id === activePlayerId); switch (action) { case 'move': onMoveTo({x, y}); break; case 'info': + showUserInfo(activePlayer); break; case 'attack': - setStartBattle({x, y}); + setStartBattle(activePlayer); break; } } diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index b3f36299..ba57511b 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -30,8 +30,8 @@ const Game = () => { }); const [players, setPlayers] = useState(PlayersMockData); - const [curPlayerState, setCurPlayerState] = useState(null); const [targetPlayer, setTargetPlayer] = useState(null); + const [userInfoPlayer, setUserInfoPlayer] = useState(); const [treasureChest, setTreasureChest] = useState(TreasureChestMockData); const curId = CurIdMockData; const curPlayer = players.find((item) => item.id === curId); @@ -105,6 +105,11 @@ const Game = () => { // move(merkelData); }; + const showUserInfo = (player) => { + setUserInfoPlayer(player); + setUserInfoVisible(true); + } + const submitGem = () => { setUserInfoVisible(true); @@ -133,13 +138,9 @@ const Game = () => { }, 1000); } - const setStartBattle = ({x, y}) => { - let targetPlayerData = players.find((item) => item.x === x && item.y === y); - if (curPlayer && targetPlayerData) { - setCurPlayerState(curPlayer); - setTargetPlayer(targetPlayerData); - setStartBattleData(true); - } + const setStartBattle = (player) => { + setTargetPlayer(player); + setStartBattleData(true); } const openTreasureChest = (id) => { @@ -218,6 +219,7 @@ const Game = () => { players, mapData: renderMapData, onPlayerMove: movePlayer, + showUserInfo, treasureChest, openTreasureChest, setStartBattle, @@ -245,13 +247,13 @@ const Game = () => { vertexCoordinate={vertexCoordinate} /> { - startBattleData ? : null + startBattleData ? : null }
{ @@ -261,8 +263,8 @@ const Game = () => { onClose={() => { setUserInfoVisible(false); }} - gem={curPlayer.gem} - {...curPlayer.equip} + gem={userInfoPlayer.gem} + {...userInfoPlayer.equip} /> ) } From 83060a586725db970822bc2142325a62eb6d653c Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 05:23:23 +0800 Subject: [PATCH 08/11] fix: better click function --- .../client/src/components/MapCell/index.tsx | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/packages/client/src/components/MapCell/index.tsx b/packages/client/src/components/MapCell/index.tsx index 3b318af8..fcdf7f59 100644 --- a/packages/client/src/components/MapCell/index.tsx +++ b/packages/client/src/components/MapCell/index.tsx @@ -37,12 +37,12 @@ interface IProps { } const MapCell = (props: IProps) => { - const { coordinate: { x, y}, cellClassCache, treasureChest, players, onMoveTo, onExeAction, prevActionCoordinate } = props; + const { coordinate: { x, y}, cellClassCache, treasureChest = [], players = [], onMoveTo, onExeAction, prevActionCoordinate } = props; const [menuVisible, setMenuVisible] = useState(false); const [activePlayerId, setActivePlayerId] = useState(-1); - const { mapData, openTreasureChest, setStartBattle, showUserInfo } = useContext(GameContext); + const { mapData, openTreasureChest, setStartBattle, showUserInfo, curId } = useContext(GameContext); const isDelivery = DELIVERY.x === x && DELIVERY.y === y; @@ -56,6 +56,10 @@ const MapCell = (props: IProps) => { onExeAction({ x, y}); e.preventDefault(); const curMapDataType = mapData[y][x]; + if (players.length > 0 || treasureChest.length > 0) { + onClick(); + return; + } if (isMovable(curMapDataType)) { onMoveTo({ x, y}); } @@ -63,11 +67,11 @@ const MapCell = (props: IProps) => { const onClick = () => { onExeAction({ x, y}); - if (treasureChest) { + if (treasureChest.length > 0) { openTreasureChest(treasureChest[0].id); return; } - if (!players || players?.length === 0) { + if (players.length === 0) { return; } setMenuVisible(true); @@ -77,7 +81,7 @@ const MapCell = (props: IProps) => { const exeAction = (e, action) => { e.stopPropagation(); setMenuVisible(false); - const activePlayer = players!.find((item) => item.id === activePlayerId); + const activePlayer = players.find((item) => item.id === activePlayerId); switch (action) { case 'move': onMoveTo({x, y}); @@ -126,20 +130,20 @@ const MapCell = (props: IProps) => { } { - treasureChest && treasureChest.map((item) => ) + treasureChest.map((item) => ) } { - players && players.map((player) => ) + players.map((player) => ) } { menuVisible && (
{ - players?.length > 1 && ( + players.length > 1 && (
    { - players?.slice(0, 3).map((player) => { + players.slice(0, 3).map((player) => { return (
  • { }
      -
    • - -
    • -
    • - -
    • + { + activePlayerId !== curId && ( +
    • + +
    • + ) + } + { + activePlayerId !== curId && ( +
    • + +
    • + ) + }
    • From c5bab14942b5b8d97588a292d89c061e575b21dc Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Wed, 25 Oct 2023 05:31:02 +0800 Subject: [PATCH 09/11] fix: user info bug fix --- packages/client/src/pages/game/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index ba57511b..4c97b4cb 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -31,7 +31,7 @@ const Game = () => { const [players, setPlayers] = useState(PlayersMockData); const [targetPlayer, setTargetPlayer] = useState(null); - const [userInfoPlayer, setUserInfoPlayer] = useState(); + const [userInfoPlayer, setUserInfoPlayer] = useState(); const [treasureChest, setTreasureChest] = useState(TreasureChestMockData); const curId = CurIdMockData; const curPlayer = players.find((item) => item.id === curId); @@ -52,6 +52,7 @@ const Game = () => { }); const mapDataRef = useRef([]); + const moveInterval = useRef(); const location = useLocation(); const { username = "", @@ -87,17 +88,19 @@ const Game = () => { } const movePlayer = (paths, merkelData) => { + clearInterval(moveInterval.current); let pathIndex = 0; - const interval = setInterval(() => { + moveInterval.current = setInterval(() => { setVertexCoordinate(triggerVertexUpdate(paths[pathIndex], curPlayer, mapDataRef.current, vertexCoordinate)); updatePlayerPosition(curPlayer, paths[pathIndex]); pathIndex++; setPlayers([...players]); if (pathIndex === paths.length) { - clearInterval(interval); + clearInterval(moveInterval.current); const target = paths[pathIndex - 1]; const isDelivery = DELIVERY.x === target.x && DELIVERY.y === target.y; if (isDelivery) { + setUserInfoPlayer(curPlayer); submitGem(); } } From dc13499ab88c75844e3334888a9fd32a6f924796 Mon Sep 17 00:00:00 2001 From: lewis <> Date: Wed, 25 Oct 2023 09:36:05 +0800 Subject: [PATCH 10/11] chore: update global config init --- packages/contracts/script/GlobalConfigInit.sol | 2 +- packages/contracts/worlds.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contracts/script/GlobalConfigInit.sol b/packages/contracts/script/GlobalConfigInit.sol index bfd9c17f..8a4ee293 100644 --- a/packages/contracts/script/GlobalConfigInit.sol +++ b/packages/contracts/script/GlobalConfigInit.sol @@ -8,7 +8,7 @@ import { GLOBAL_CONFIG_KEY } from "../src/Constants.sol"; library GlobalConfigInit { function initGlobalConfig(IWorld _world) internal { - address userContract = 0x0d9B17c2A22539101797db13EAE7d38A8f8A511F; + address userContract = 0x685c65e0c699EC5E52877D2E133d87103d5fa393; GlobalConfig.setUserContract( _world, GLOBAL_CONFIG_KEY, //key diff --git a/packages/contracts/worlds.json b/packages/contracts/worlds.json index 6aced72a..f91aca6a 100644 --- a/packages/contracts/worlds.json +++ b/packages/contracts/worlds.json @@ -1,7 +1,7 @@ { "4242": { - "address": "0x037451EB237700458Af435ffF1CeFcac037247aD", - "blockNumber": 27950347 + "address": "0x6924b42c7e846412891118edc8E4F88266ade31f", + "blockNumber": 28466039 }, "31337": { "address": "0x0712629Ced85A3A62E5BCa96303b8fdd06CBF8dd" From 4aabf5499eed83ce6f70575bdd6a83dd6b475f68 Mon Sep 17 00:00:00 2001 From: LidamaoHub Date: Wed, 25 Oct 2023 13:14:38 +0800 Subject: [PATCH 11/11] add ignore --- packages/contracts/.DS_Store | Bin 6148 -> 0 bytes packages/contracts/.env | 8 --- .../contracts/{.gitignore => .gitignore_temp} | 2 + packages/contracts/jsTest/test.js | 39 ++++++----- packages/contracts/jsTest/tools.js | 61 +++++++++--------- packages/contracts/mud.config.ts | 3 +- packages/contracts/worlds.json | 17 ----- 7 files changed, 55 insertions(+), 75 deletions(-) delete mode 100644 packages/contracts/.DS_Store delete mode 100644 packages/contracts/.env rename packages/contracts/{.gitignore => .gitignore_temp} (84%) delete mode 100644 packages/contracts/worlds.json diff --git a/packages/contracts/.DS_Store b/packages/contracts/.DS_Store deleted file mode 100644 index 5c62b95dfa7ed06829463f4e74d4360fb183e247..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOG*Pl5Unyn26T~?xa=dC8;oJxxQ$B}5+h1Tn1q;pU(U051(&|+D#b|#+y#+W z(EY0GH!}~WyGulLvYU@ZMj}#S7^*2fV&-1gNdympT54?Nb@@D=KDMiMPockPvUfj~ zg>2%*A&uQBVFpFCZm1ceNc0Wv@a$iPt; zz?p4QojGzQ17v^=$csQB KgcBJ!0t26}CoOaU diff --git a/packages/contracts/.env b/packages/contracts/.env deleted file mode 100644 index 0f8cc4a3..00000000 --- a/packages/contracts/.env +++ /dev/null @@ -1,8 +0,0 @@ -# This .env file is for demonstration purposes only. -# -# This should usually be excluded via .gitignore and the env vars attached to -# your deployment enviroment, but we're including this here for ease of local -# development. Please do not commit changes to this file! -# -# Anvil default private key: -PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 diff --git a/packages/contracts/.gitignore b/packages/contracts/.gitignore_temp similarity index 84% rename from packages/contracts/.gitignore rename to packages/contracts/.gitignore_temp index 9527c1f8..34fbfa71 100644 --- a/packages/contracts/.gitignore +++ b/packages/contracts/.gitignore_temp @@ -7,5 +7,7 @@ abi/ types/ broadcast/ .env +.DS_Store +worlds.json # Ignore MUD deploy artifacts deploys/**/*.json diff --git a/packages/contracts/jsTest/test.js b/packages/contracts/jsTest/test.js index bc3a9884..15f087db 100644 --- a/packages/contracts/jsTest/test.js +++ b/packages/contracts/jsTest/test.js @@ -1,26 +1,33 @@ -const { buildABI, getContract,deploy,run,call,wallet } = require('./tools.js'); +const { buildABI, getContract,deploy,run,call,wallet,getStr } = require('./tools.js'); const { root,move } = require('./merkle_tree.js'); const { ethers } = require("ethers"); async function main() { // await buildABI(); - let contract = await getContract(); - // console.log(contract.functions) - await contract.initUserInfo() - await run("成功设置默克尔根",contract.SetMapMerkleRoot(root)) - await run("玩家加入战场",contract.joinBattlefield()) + let a = "0x155015ae9c496f0f6fd931019b5913c67e630cdcf50b1101aeda4bb69f21060e" + console.log(a) + console.log('0x0000000000000000000000000000000047616d65436f6e666967000000000000') + + a = ethers.utils.hexZeroPad(a, 32) + console.log(a) + console.log(getStr(a)) + // let contract = await getContract(); + // // console.log(contract.functions) + // await contract.initUserInfo() + // await run("成功设置默克尔根",contract.SetMapMerkleRoot(root)) + // await run("玩家加入战场",contract.joinBattlefield()) // let r = call("查看当前坐标:",contract.getPosition(wallet.address)) - let r = await contract.getPosition(wallet.address) - let steps = move([[r[0],r[1]+1]]); - await run("移动",contract.move(steps)); + // let r = await contract.getPosition(wallet.address) + // let steps = move([[r[0],r[1]+1]]); + // await run("移动",contract.move(steps)); - let a = ethers.utils - .solidityKeccak256( - ["string"], - ["Player-Key"] - ) - .slice(2) - console.log(a) + // let a = ethers.utils + // .solidityKeccak256( + // ["string"], + // ["Player-Key"] + // ) + // .slice(2) + // console.log(a) } diff --git a/packages/contracts/jsTest/tools.js b/packages/contracts/jsTest/tools.js index 1feffaca..e5c76918 100644 --- a/packages/contracts/jsTest/tools.js +++ b/packages/contracts/jsTest/tools.js @@ -1,7 +1,7 @@ const { ethers } = require("ethers"); require("dotenv").config(); const { exec } = require("child_process"); -const abiDecoder = require('abi-decoder'); +const abiDecoder = require("abi-decoder"); const privateKey = process.env.PRIVATE_KEY; @@ -9,11 +9,11 @@ const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545"); const wallet = new ethers.Wallet(privateKey, provider); console.log("测试钱包地址:", wallet.address); - const contractInfo = require("../worlds.json"); - const contractAddress = contractInfo["31337"].address; - const contractABI = require("../out/IWorld.sol/IWorld.abi.json"); +const contractInfo = require("../worlds.json"); +const contractAddress = contractInfo["31337"].address; +const contractABI = require("../out/IWorld.sol/IWorld.abi.json"); - console.log("测试合约地址:", contractAddress); +console.log("测试合约地址:", contractAddress); async function buildABI() { console.log("正在编译合约..."); return new Promise((resolve, reject) => { @@ -49,7 +49,6 @@ async function deploy() { }); } async function getContract() { - const contract = new ethers.Contract(contractAddress, contractABI, wallet); return contract; } @@ -59,43 +58,40 @@ function getStr(bytes32Value) { return stringValue; } -function getMudEvent(args){ - console.log(args) - let name = getStr(args[0]); - console.log(name) - abiDecoder.addABI(contractABI); - const decodedData = abiDecoder.decodeMethod(args.data); - let a = args[1].forEach((e) => { - console.log(e) - return getStr(e); - }) - console.log(a) -console.log(decodedData); - // let i = bytesToString(args[3]); - - // console.log(a) - console.log(args[2]) - console.log(i) - +function getMudEvent(args) { + console.log(args); + let name = getStr(args[0]); + console.log(name); + abiDecoder.addABI(contractABI); + const decodedData = abiDecoder.decodeMethod(args.data); + let a = args[1].forEach((e) => { + console.log("!",e); + return getStr(e); + }); + console.log(a); + console.log(decodedData); + // let i = bytesToString(args[3]); + + // console.log(a) + console.log(args[2]); + console.log(i); } async function run(name, func) { let a = await func; let b = await a.wait(); console.log(name); b.events.forEach((e) => { - - if ( e.event =="StoreSetField") { - console.log("\x1b[32m%s\x1b[0m", e.eventSignature); - // console.log(e.args, e.args.length); - getMudEvent(e.args) + if (e.event == "StoreSetField") { + console.log("\x1b[32m%s\x1b[0m", e.eventSignature); + // console.log(e.args, e.args.length); + getMudEvent(e.args); } }); - } -async function call(name,func) { +async function call(name, func) { let a = await func; - console.log(name,":",a); + console.log(name, ":", a); return a; } @@ -106,4 +102,5 @@ module.exports = { run, call, wallet, + getStr }; diff --git a/packages/contracts/mud.config.ts b/packages/contracts/mud.config.ts index 40bac437..b7f36bbe 100644 --- a/packages/contracts/mud.config.ts +++ b/packages/contracts/mud.config.ts @@ -12,8 +12,7 @@ export default mudConfig({ }, GMSystem: { name: "gm", - // TODO,测试,正式需要关闭 - openAccess: true, + openAccess: false, accessList: [], }, PlayerSystem: { diff --git a/packages/contracts/worlds.json b/packages/contracts/worlds.json deleted file mode 100644 index 445865fc..00000000 --- a/packages/contracts/worlds.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "4242": { - "address": "0x037451EB237700458Af435ffF1CeFcac037247aD", - "blockNumber": 27950347 - }, - "31337": { - "address": "0xB5AFb7CD0FaDDD27785dFb9bC02Cc5E4C3D4378e" - }, - "421613": { - "address": "0x2Bc1034975c3df48D6f3026802f372677844b85d", - "blockNumber": 46508363 - }, - "11155111": { - "address": "0xec7F8CF3B3640b1C5E8fD3c208776aad056D4fc3", - "blockNumber": 4450305 - } -} \ No newline at end of file