Skip to content

Commit

Permalink
fix: buy exp conflict with enter round 4
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Nov 10, 2024
1 parent 2f301c5 commit a526015
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
42 changes: 1 addition & 41 deletions packages/client/src/ui/features/guide/GuidePage.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,13 @@
import { useEffect } from "react";
import { ShowItem, usePersistUIStore, useUIStore } from "../../../store";
import { Dialog } from "../../components/Dialog";
import { GreenButton } from "../../components/GreenButton";
import { HomeBg } from "../../components/HomeBg";
import { useDojo } from "../../hooks/useDojo";
import { useComponentValue } from "@dojoengine/react";
import { zeroEntity } from "../../../utils";
import { GameStatusEnum } from "../../../dojo/types";

export function GuidePage() {
const show = useUIStore((state) => state.getShow(ShowItem.GuidePage));
const setShow = useUIStore((state) => state.setShow);
const { setField, guideIndex, guideRun, getShow } = useUIStore();

const { setField } = useUIStore();
const { setSkipGuide } = usePersistUIStore((state) => state);

const {
clientComponents: { Player, GameStatus },
account: { playerEntity },
} = useDojo();

const playerValue = useComponentValue(Player, playerEntity);
const gStatus = useComponentValue(GameStatus, zeroEntity);

useEffect(() => {
if (
(playerValue?.coin ?? 0) >= 4 &&
guideIndex === 4 &&
guideRun === false &&
gStatus?.status == GameStatusEnum.Prepare
) {
setField("guideRun", true);
}
}, [
guideIndex,
guideRun,
playerValue?.coin,
setField,
gStatus?.status,
gStatus?.dangerous,
getShow,
]);

// useEffect(() => {
// if () {
// setField("guideRun", false);
// }
// }, [getShow, setField]);

if (!show) {
return null;
}
Expand Down
42 changes: 40 additions & 2 deletions packages/client/src/ui/features/guide/InteractiveGuide.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { ShowItem, usePersistUIStore, useUIStore } from "../../../store";
import ReactJoyride, { Step } from "react-joyride";
import { logDebug } from "../../lib/utils";
import { useDojo } from "../../hooks/useDojo";
import { useComponentValue } from "@dojoengine/react";
import { zeroEntity } from "../../../utils";
import { useEffect } from "react";
import { GameStatusEnum } from "../../../dojo/types";

export function InterActiveGuide() {
const { setField, guideIndex, guideRun } = useUIStore();
const { setField, guideIndex, guideRun, getShow, shows } = useUIStore();
const show = useUIStore((state) =>
state.getShow(ShowItem.InterActiveGuide)
);

const {
clientComponents: { Player, GameStatus },
account: { playerEntity },
} = useDojo();
const playerValue = useComponentValue(Player, playerEntity);
const gStatus = useComponentValue(GameStatus, zeroEntity);
const shadeShow = getShow(ShowItem.Shade);

const { setSkipGuide } = usePersistUIStore((state) => state);

const steps: Step[] = [
Expand Down Expand Up @@ -165,6 +178,27 @@ export function InterActiveGuide() {
},
},
];
useEffect(() => {
if (
(playerValue?.coin ?? 0) >= 4 &&
guideIndex === 4 &&
guideRun === false &&
gStatus?.status == GameStatusEnum.Prepare &&
!shadeShow
) {
setField("guideRun", true);
}
}, [
guideIndex,
guideRun,
playerValue?.coin,
setField,
gStatus?.status,
gStatus?.dangerous,
getShow,
shadeShow,
shows,
]);

if (!show) {
return null;
Expand All @@ -180,7 +214,11 @@ export function InterActiveGuide() {
if (guideIndex === 5) {
setTimeout(() => {
setField("guideIndex", guideIndex + 1);
setField("guideRun", false);

// resolve when buy exp conflict with enter round 4
if (gStatus?.currentRound !== 4) {
setField("guideRun", false);
}
}, 1000);
}

Expand Down

0 comments on commit a526015

Please sign in to comment.