Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat-mvp' into feat-mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivomo committed Oct 30, 2023
2 parents 91f8732 + 982e477 commit 7ec7288
Show file tree
Hide file tree
Showing 18 changed files with 598 additions and 303 deletions.
2 changes: 1 addition & 1 deletion packages/client/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_CHAIN_ID=31337
VITE_CHAIN_ID=4242
287 changes: 187 additions & 100 deletions packages/client/src/components/Battle/index.tsx

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion packages/client/src/components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { bfs, simplifyMapData } from '@/utils/map';
import useMerkel from '@/hooks/useMerkel';
import { ITreasureChest } from '@/components/TreasureChest';
import GameContext from '@/context';
import { main } from '../../utils/createMerkelTree';

interface IProps {
width: number;
Expand Down Expand Up @@ -57,9 +58,21 @@ const Map = (props: IProps) => {
const cellClassCache = useRef<ICellClassCache>({});

const onMoveTo = (coordinate) => {
const { x, y} = players.find((player) => player.id === curId);
console.log(players, coordinate, 'onMoveTo', curId)
const { x, y} = players.find((player) => player.addr.toLocaleLowerCase() === curId.toLocaleLowerCase());
const paths = bfs(simpleMapData, { x, y }, coordinate).slice(1);
onPlayerMove(paths, formatMovePath(paths));
// 全是1的地图
// const player = players.find((e) => e.addr.toLocaleLowerCase() === curId.toLocaleLowerCase());
// let from = {x: player.x, y: player.y}
// let to = coordinate
// let map_info = [];
// let line = Array.from({ length: 100 }, () => 1);
// for (let i = 0; i < 10; i++) {
// map_info.push(line);
// }
// let {merkelData, paths} = main(from, to);
// onPlayerMove(paths, merkelData);
}


Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/components/Rank/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ interface IProps {
const Rank = (props: IProps) => {

const { data, curId } = props;
const curIndex = data.findIndex(item => item.id === curId);
console.log(data)
const curIndex = data.findIndex(item => item.id === 1);
const [visible, setVisible] = useState(false);

const toggleVisible = () => {
Expand Down
10 changes: 7 additions & 3 deletions packages/client/src/components/UserInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IUserInfo {

const UserInfo = (props: IUserInfo) => {

const { handheld, head, clothes, gem = 0 } = props;
const { handheld, head, clothes, gem = 0, userUrl, lootUrl } = props;
const lootHasLoaded = handheld && head && clothes;
console.log(handheld, head, clothes, lootHasLoaded);

Expand All @@ -28,10 +28,14 @@ const UserInfo = (props: IUserInfo) => {
</div>
<div className={`loot-wrapper ${lootHasLoaded ? 'loaded' : ''}`}>
<div className="loot-detail">

{
userUrl ? <img src={userUrl} alt=""/> : null
}
</div>
<div className="loot-detail">

{
lootUrl ? <img src={lootUrl} alt=""/> : null
}
</div>
</div>
<div className={`user-attr-wrapper ${lootHasLoaded ? 'loaded' : ''}`}>
Expand Down
10 changes: 0 additions & 10 deletions packages/client/src/components/UserInfo/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@
justify-content: space-between;
flex-direction: column;
height: 100%;

&.loaded {
.loot-detail:nth-child(1) {
background: url("../../assets/img/loot1.png") no-repeat center / 100%;
}

.loot-detail:nth-child(2) {
background: url("../../assets/img/loot2.png") no-repeat center / 100%;
}
}
}

.loot-detail {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/UserPackage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const UserPackage = (props: IProps) => {
<h3>{props.title}</h3>
<div className="package-items-wrapper">
{
arr.map((count) => {
arr.map((count, index) => {
return (
<div className='package-item'>
<div className='package-item' key={index}>
{
count > 0 && (<>
<img src={gemImg} alt="" className={'package-item-gem'}/>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/hooks/useModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function useModal(config = { title: '' }) {
<Modal
{...config}
className="mi-modal"
visible={visible}
open={visible}
onCancel={close}
footer={null}
>
Expand Down
3 changes: 0 additions & 3 deletions packages/client/src/mud/createSystemCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ export function createSystemCalls(
}

const selectUserNft = async (tokenId: any) => {
console.log(tokenId, 'tokenId')
const tx = await worldContract.write.selectUserNft([tokenId]);
console.log(new Date().getTime(), tx, 'tx')
await waitForTransaction(tx);
console.log(new Date().getTime(), tx, 'tx')
}

const openBox = async (boxId: any) => {
Expand Down
Loading

0 comments on commit 7ec7288

Please sign in to comment.