Skip to content

Commit

Permalink
fix events + add button to navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Apr 2, 2024
1 parent c2219b8 commit 926ae9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 4 additions & 4 deletions indexer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ const StratagemsIndexerProcessor: JSProcessor<ContractsABI, Data> = {
epoch,
cells: {},
};
}
state.placements.unshift(epochEvents);
if (state.placements.length > 7) {
state.placements.pop();
state.placements.unshift(epochEvents);
if (state.placements.length > 7) {
state.placements.pop();
}
}

const stratagemsContract = new StratagemsContract(state, 7);
Expand Down
17 changes: 17 additions & 0 deletions web/src/lib/ui/components/PositionInfo.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts">
import {camera} from '$lib/render/camera';
import {eventsView} from '../events/eventsView';
import {menu} from '../menu/menu';
export let x: number;
export let y: number;
function navigate() {
console.log({x, y});
camera.navigate(x, y, 128);
eventsView.set({open: false});
menu.set({open: false});
}
</script>

<button on:click={() => navigate()}>{x},{y}</button>
4 changes: 3 additions & 1 deletion web/src/lib/ui/events/EventsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import EventInfo from './EventInfo.svelte';
import type {CellPlacements} from 'stratagems-indexer';
import {bigIntIDToXY} from 'stratagems-common';
import PositionInfo from '../components/PositionInfo.svelte';
type Placements = {
epoch: number;
Expand Down Expand Up @@ -42,8 +43,9 @@
header: 'position',
accessor: (event) => {
const {x, y} = bigIntIDToXY(event.position);
return `${x},${y}`;
return {x, y};
},
cell: ({value}) => createRender(PositionInfo, value),
}),
table.column({
header: 'players',
Expand Down

0 comments on commit 926ae9d

Please sign in to comment.