Skip to content

Commit

Permalink
fix: game over dialog show
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Oct 11, 2024
1 parent bb04939 commit 3f9e3f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 18 additions & 1 deletion packages/client/src/ui/features/debug/StatePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { useComponentValue, useEntityQuery } from "@dojoengine/react";
import { useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { useDojo } from "../../hooks/useDojo";
import { getComponentValue, HasValue, NotValue } from "@dojoengine/recs";
import {
getComponentValue,
getEntitiesWithValue,
HasValue,
NotValue,
} from "@dojoengine/recs";
import { getPlayerBoardPieceEntity } from "../../lib/utils";
import { zeroEntity } from "../../../utils";
import { getEntityIdFromKeys } from "@dojoengine/utils";

export function StatesPanel() {
const {
Expand All @@ -15,6 +21,7 @@ export function StatesPanel() {
PlayerInvPiece,
Player,
GameStatus,
MatchResult,
},
account: {
account: { address },
Expand All @@ -25,6 +32,11 @@ export function StatesPanel() {

const s = useComponentValue(GameStatus, zeroEntity);

const matchResult = useComponentValue(
MatchResult,
getEntityIdFromKeys([BigInt(s?.currentMatch || 0)])
);

useHotkeys("p", () => {
setStatesShow(!statesShow);
});
Expand Down Expand Up @@ -150,6 +162,11 @@ export function StatesPanel() {

<div>CurrentMatch {s?.currentMatch}</div>
<div>CurrentRound {s?.currentRound}</div>
<div>Played {s?.played.toString()}</div>
<div>Player Value in match {playerValue?.inMatch}</div>
<div>
MatchResult score {matchResult?.score} {matchResult?.index}{" "}
</div>
</div>
);
}
6 changes: 1 addition & 5 deletions packages/client/src/ui/hooks/useControlGameEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export function useGameEnd() {
const end = useMemo(() => {
let e = false;

if (
!playerValue?.inMatch &&
result?.index == playerValue?.inMatch &&
s?.played === true
) {
if (result?.index === playerValue?.inMatch && s?.played === true) {
e = true;
}
return e;
Expand Down

0 comments on commit 3f9e3f6

Please sign in to comment.