Skip to content

Commit

Permalink
fix: fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TiyoSheng committed Nov 11, 2023
2 parents f791e5e + 75b0c19 commit 7fa1717
Show file tree
Hide file tree
Showing 13 changed files with 2,846 additions and 2,816 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/_theme.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$cellSize: 72px;
$cellSize: 48px;
22 changes: 19 additions & 3 deletions packages/client/src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Game = () => {
const navigate = useNavigate();
const {
components: { Player, PlayerAddon, BattleList, BoxList, GlobalConfig, LootList1, LootList2, PlayerLocationLock, PlayerSeason, SyncProgress },
systemCalls: { move, openBox, revealBox, getCollections, battleInvitation, unlockUserLocation, submitGem, goHome },
systemCalls: { move, openBox, revealBox, getCollections, battleInvitation, unlockUserLocation, submitGem, goHome, joinBattlefield },
network,
} = useMUD();

Expand Down Expand Up @@ -256,7 +256,7 @@ const Game = () => {
message.success('You win the battle');
} else {
// 对方跑了
message.info('Target has escaped');
message.info('Target has escaped,You are locked');
timeout = setTimeout(() => {
unlockUserLocation();
timeout = null
Expand Down Expand Up @@ -383,10 +383,26 @@ const Game = () => {
setUserInfoVisible(true);
}

const goHomeFun = async () => {
if (!curPlayer.waiting) {
try {
await goHome();
await joinBattlefield()
} catch (error) {
console.log(error)
}
} else {
console.log('waiting')
setTimeout(() => {
goHomeFun();
}, 500)
}
}

const submitGemFun = async () => {
setUserInfoVisible(true);
try {
goHome();
goHomeFun()
if (curPlayer.oreBalance > 0) {
await submitGem();
setContent(
Expand Down
13 changes: 8 additions & 5 deletions packages/client/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import indexDuckImg from '@/assets/img/duck_index.svg';
import lootAbi from '../../../../contracts/out/Loot.sol/MLoot.abi.json'
import userAbi from '../../../../contracts/out/User.sol/MUser.abi.json'
import pluginAbi from '../../../../contracts/out/Plugin.sol/MPlugin.abi.json'
import { async } from 'rxjs';

let userContract: any
let lootContract: any
Expand Down Expand Up @@ -223,10 +222,14 @@ const Home = () => {
})
await mint()
}
// if (curPlayer?.state >= 2) {
// navigate('/game');
// return;
// }
if (curPlayer?.state >= 2) {
navigate('/game');
return;
} else if (curPlayer?.state == 1) {
await joinBattlefield()
navigate('/game');
return
}
let userTokenId = userTokenIds[userTokenIds?.length - 1].toString()
let lootTokenId = lootTokenIds[lootTokenIds?.length - 1].toString()

Expand Down
14 changes: 12 additions & 2 deletions packages/client/src/pages/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ const Test = () => {
setBattlesData(battlesDataTemp)
}

const CreateBoxFun = async (boxi) => {
const CreateBoxMoreFun = async (boxi) => {
if (boxi == undefined) boxi = 0
let box = boxData1[boxi]
console.log(box, 'box', boxi,boxData1 )
Expand All @@ -332,6 +332,10 @@ const Test = () => {
}
}

const CreateBoxFun = async () => {
CreateBox(boxData[0], boxData[1]);
}

const openBoxFun = () => {
openBox(boxId);
}
Expand Down Expand Up @@ -496,14 +500,20 @@ const Test = () => {
<div className="input"></div>
<div className="btn" onClick={revealBattleFun}>确认</div>
</div>
<div className="section">
<div className="title">批量创建宝箱</div>
<div className="input"></div>
<div className="btn" onClick={() => CreateBoxMoreFun(0)}>确认</div>
</div>
<div className="section">
<div className="title">创建宝箱</div>
<div className="input">
<input type="text" onChange={(e) => boxChange(e, 0)} placeholder='x' />
<input type="text" onChange={(e) => boxChange(e, 1)} placeholder='y' />
</div>
<div className="btn" onClick={() => CreateBoxFun(0)}>确认</div>
<div className="btn" onClick={CreateBoxFun}>确认</div>
</div>

<div className="section">
<div className="title">打开宝箱</div>
<div className="input">
Expand Down
3 changes: 0 additions & 3 deletions packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export default mudConfig({
addr: "address",
},
schema: {
suitId : "uint256",
equipmentId : "uint256",
x : "uint16",
y : "uint16",
hp : "uint256",
Expand All @@ -75,7 +73,6 @@ export default mudConfig({
maxHp: "uint256",
name: "string",
url: "string",

}
},
PlayerAddon:{
Expand Down
Loading

0 comments on commit 7fa1717

Please sign in to comment.