Skip to content

Commit

Permalink
allow to see as other players
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Apr 20, 2024
1 parent e8083b7 commit a99c89a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions web/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ export const globalQueryParams = [
'snapshot',
'debugTools',
'missiv',
'asPlayer',
];

export const hashParams = getHashParamsFromLocation();
export const {params} = getParamsFromLocation();

export const dev = 'dev' in params ? params['dev'] === 'true' : devEnvironment;

export const asPlayer = 'asPlayer' in params ? params['asPlayer'] : undefined;

export const debugTools = 'debugTools' in params ? params['debugTools'] === 'true' : false;

function noEndSlash(str: string) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/state/ViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import type {OnChainAction, OnChainActions} from '$lib/account/base';
import {createDraft} from 'immer';
import {parseEther, parseUnits} from 'viem';
import {initialContractsInfos} from '$lib/config';
import {asPlayer, initialContractsInfos} from '$lib/config';

export type ViewCell = ContractCell & {
localState?: 'pending' | 'planned';
Expand Down Expand Up @@ -169,7 +169,7 @@ function merge(
const viewCell = {
next,
future,
currentPlayer: cellOwner === account.address?.toLowerCase(),
currentPlayer: cellOwner === (asPlayer || account.address?.toLowerCase()),
};
viewState.viewCells[xyToXYID(x, y)] = viewCell;
viewState.cells[xyToXYID(x, y)] = copyState.cells[cellID];
Expand Down

0 comments on commit a99c89a

Please sign in to comment.