Jofthomas commited on
Commit
859baa3
·
1 Parent(s): 9a87bcf
src/components/Game.tsx CHANGED
@@ -98,7 +98,7 @@ export default function Game() {
98
  }
99
  console.log("humanTokenIdentifier",humanTokenIdentifier)
100
  const playerId = [...game.world.players.values()].find(
101
- (p) => p.id === humanTokenIdentifier,
102
  )?.id;
103
  console.log("playerId",playerId)
104
 
 
98
  }
99
  console.log("humanTokenIdentifier",humanTokenIdentifier)
100
  const playerId = [...game.world.players.values()].find(
101
+ (p) => game.playerDescriptions.get(p.id)?.name === humanTokenIdentifier,
102
  )?.id;
103
  console.log("playerId",playerId)
104
 
src/components/PixiGame.tsx CHANGED
@@ -30,8 +30,9 @@ export const PixiGame = (props: {
30
  const oauth = JSON.parse(localStorage.getItem('oauth'));
31
  const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
32
  const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId: props.worldId, oauthToken }) ?? null;
 
33
  const humanPlayerId = [...props.game.world.players.values()].find(
34
- (p) => p.human === humanTokenIdentifier,
35
  )?.id;
36
 
37
  const moveTo = useSendInput(props.engineId, 'moveTo');
 
30
  const oauth = JSON.parse(localStorage.getItem('oauth'));
31
  const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
32
  const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId: props.worldId, oauthToken }) ?? null;
33
+
34
  const humanPlayerId = [...props.game.world.players.values()].find(
35
+ (p) => props.game.playerDescriptions.get(p.id)?.name === humanTokenIdentifier,
36
  )?.id;
37
 
38
  const moveTo = useSendInput(props.engineId, 'moveTo');
src/components/PlayerDetails.tsx CHANGED
@@ -30,7 +30,9 @@ export default function PlayerDetails({
30
  const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId, oauthToken });
31
 
32
  const players = [...game.world.players.values()];
33
- const humanPlayer = players.find((p) => p.human === humanTokenIdentifier);
 
 
34
  const humanConversation = humanPlayer ? game.world.playerConversation(humanPlayer) : undefined;
35
  // Always select the other player if we're in a conversation with them.
36
  if (humanPlayer && humanConversation) {
 
30
  const humanTokenIdentifier = useQuery(api.world.userStatus, { worldId, oauthToken });
31
 
32
  const players = [...game.world.players.values()];
33
+ const humanPlayer = [...game.world.players.values()].find(
34
+ (p) => game.playerDescriptions.get(p.id)?.name === humanTokenIdentifier,
35
+ );
36
  const humanConversation = humanPlayer ? game.world.playerConversation(humanPlayer) : undefined;
37
  // Always select the other player if we're in a conversation with them.
38
  if (humanPlayer && humanConversation) {
src/components/buttons/InteractButton.tsx CHANGED
@@ -19,7 +19,7 @@ export default function InteractButton() {
19
  const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
20
  const humanTokenIdentifier = useQuery(api.world.userStatus, worldId ? { worldId, oauthToken } : 'skip');
21
  const userPlayerId =
22
- game && [...game.world.players.values()].find((p) => p.human === humanTokenIdentifier)?.id;
23
  const join = useMutation(api.world.joinWorld);
24
  const leave = useMutation(api.world.leaveWorld);
25
  const isPlaying = !!userPlayerId;
 
19
  const oauthToken = oauth ? oauth.userInfo.fullname : undefined;
20
  const humanTokenIdentifier = useQuery(api.world.userStatus, worldId ? { worldId, oauthToken } : 'skip');
21
  const userPlayerId =
22
+ game && [...game.world.players.values()].find((p) => game?.playerDescriptions.get(p.id)?.name === humanTokenIdentifier)?.id;
23
  const join = useMutation(api.world.joinWorld);
24
  const leave = useMutation(api.world.leaveWorld);
25
  const isPlaying = !!userPlayerId;