Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackAmes committed Nov 15, 2024
1 parent 90f7208 commit 34ae187
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 31 deletions.
1 change: 0 additions & 1 deletion client/src/lib/3d/Scene.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,4 @@
<Map />
<Characters />
<Bullets />
<Inspector />
</T.Group>
4 changes: 3 additions & 1 deletion client/src/lib/3d/components/Cameras/BirdView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
import { T } from '@threlte/core'
import { OrbitControls } from '@threlte/extras'
import { useThrelte } from '@threlte/core'
import { Vector3 } from 'three'
export let camera
let {renderer} = useThrelte()
</script>

<T.PerspectiveCamera
makeDefault
position={[15, 30, 20]}
position={[48, 5, 48]}
on:create={({ ref }) => {
camera = ref
camera.lookAt(new Vector3(0, 4, 0))
}}
>
<OrbitControls />
Expand Down
9 changes: 5 additions & 4 deletions client/src/lib/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { account, username } from '$stores/account';
import { dojoStore } from '$src/stores/dojoStore';
import { get } from 'svelte/store';

export const mapmakerContract = '0x11e7a657668ca83c556f7545ab5bde00c1a1275c6c9ed17bea33104fcda2f3b'
export const spawnContract = '0x57a72dd6f0bf3b0ced0fd50e54696643b8e3b38e226a150a1471c658355921e'
export const startContract = '0x44ce069fe53c5c7941eec521bc9e876907d5da6ca273a98b78f1cbbcfea5b62'
export const actionsContract = '0x11de1871e7fa8ac97e62c36724c32ee584982f4a5892b4f62fd545d7ab2d506'
export const actionsContract = "0x7a9e8de4cf849402d115efdae32b892235dddbf29e15dcde2222fbcd928a30c"
export const planeteloContract = "0x52e3d09dd643e4d4f491b3d022d3c67f48c0bf2ceda8e7b3fc83f45d06711bd"

export const controllerMainnet = new Controller({
Expand All @@ -31,6 +28,10 @@ export const controllerSepolia = new Controller({
{
target: planeteloContract,
method: "settle",
},
{
target: actionsContract,
method: "move",
}

// ... other policies
Expand Down
4 changes: 1 addition & 3 deletions client/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if (!$account) {
await connect(config);
}
goto(`${config}/client/games/openGames`);
goto(`${config}/client/matchmaking`);
}
onMount(() => {
Expand All @@ -40,8 +40,6 @@
<img src="/logos/LOGO_15.png" alt="OCTOGUNS" width="300" height="300" />
</div>
<div>
<Button on:click={() => connectAndGoto('mainnet')}>Play Mainnet</Button>
<Button on:click={() => connectAndGoto('slot')}>Play Slot</Button>
<Button on:click={() => connectAndGoto('sepolia')}>Play Sepolia</Button>
</div>
</div>
Expand Down
67 changes: 45 additions & 22 deletions client/src/routes/[slug]/client/matchmaking/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
let {config, dojoProvider}: any = get(dojoStore);
const actions = new Contract(config.manifest.contracts[4].abi, config.manifest.contracts[4].address, dojoProvider.provider).typedv2(config.manifest.contracts[4].abi);
console.log(actions)
//@ts-ignore
let name = "octoguns".toString(16);
console.log(name)
Expand Down Expand Up @@ -59,11 +60,11 @@
$: buttonText = status === 0 ? 'Queue'
: status === 1 ? 'Matchmake'
: status === 2 && result == 1 ? 'Play' : 'Settle';
: status === 2 && result == 0 ? 'Play' : 'Settle';
$: buttonClass = status === 0 ? ''
: status === 1 ? 'queuing'
: status === 2 && result == 1 ? 'playing' : 'settle';
: status === 2 && result == 0 ? 'playing' : 'settle';
async function handleSettle() {
let res = await $account?.execute(
Expand All @@ -88,7 +89,7 @@
queue_length = parseInt(await planetelo.get_queue_length(game_key, "0x0"));
if (status == 2) {
game_id = parseInt(await planetelo.get_player_game_id($account!.address, game_key, "0x0"));
let result = parseInt(await actions.get_result(game_id));
result = parseInt(await actions.get_result(game_id));
console.log(result)
}
console.log(status)
Expand All @@ -110,26 +111,36 @@
</script>

{#if $dojoStore}
<div class="queue-container">
<div class="stats">
<p>ELO: {elo}</p>
<p>Players in Queue: {queue_length}</p>
</div>
<button
class="queue-button {buttonClass}"
on:click={status == 0 ? handleQueue : status == 1 ? handleMatchmake : status == 2 && result == 1 ? handleGame : handleSettle}
>
{buttonText}
</button>
{#if status === 1}
<p class="status">Finding a match...</p>
{/if}
<div class="queue-container">
<div class="stats">
<p>ELO: {elo}</p>
<p>Players in Queue: {queue_length}</p>
</div>
{:else}
<p>Setting up...</p>
{/if}

{#if status === 2}
{#if result === 0}
<p class="status-message">In Game</p>
{:else}
<p class="status-message">Game Over</p>
{/if}
{/if}

<button
class="queue-button {buttonClass}"
on:click={status == 0 ? handleQueue : status == 1 ? handleMatchmake : status == 2 && result == 0 ? handleGame : handleSettle}
>
{buttonText}
</button>

{#if status === 1}
<p class="status">Finding a match...</p>
{/if}
</div>
{:else}
<p>Setting up...</p>
{/if}

<style>
<style>
.grid-fill {
grid-template-columns: repeat(auto-fill, 330px);
}
Expand Down Expand Up @@ -214,5 +225,17 @@
.queue-button.settle {
background-color: #9C27B0;
}
</style>
.status {
font-size: 1.2rem;
color: #555;
}
.status-message {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 1rem;
text-align: center;
}
</style>

0 comments on commit 34ae187

Please sign in to comment.