Skip to content

Commit

Permalink
attempting github hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunpat committed Mar 3, 2024
1 parent 1866bba commit f61fea2
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 38 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy to GitHub Pages

on:
push:
branches: 'main'

jobs:
build_site:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

# If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`
# - name: Install pnpm
# uses: pnpm/action-setup@v3
# with:
# version: 8

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm install

- name: build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: |
npm run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v3
with:
# this should match the `pages` option in your adapter-static options
path: 'build/'

deploy:
needs: build_site
runs-on: ubuntu-latest

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
9 changes: 8 additions & 1 deletion dixit-server/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum ServerMsg {
stage: RoomStage,
active_player: Option<String>,
player_order: Vec<String>,
round: u16,
},
StartRound {
hand: Vec<String>,
Expand Down Expand Up @@ -89,6 +90,8 @@ struct RoomState {
deck: Vec<String>,
// stage of the game
stage: RoomStage,
// round number
round: u16,
// order of players being "active"
player_order: Vec<String>,
active_player: usize, // index into player_order
Expand Down Expand Up @@ -128,6 +131,7 @@ impl Room {
current_description: "".to_string(),
player_to_current_card: HashMap::new(),
player_to_vote: HashMap::new(),
round: 0,
};

let (tx, _) = broadcast::channel(10);
Expand Down Expand Up @@ -268,8 +272,10 @@ impl Room {
return Err(anyhow!("Not enough players"));
}

state.round += 1;

// finalize players
if state.player_order.len() == 0 {
if state.round == 1 {
// first round
state.active_player = 0;
state.player_order = state.players.keys().cloned().collect::<Vec<_>>();
Expand Down Expand Up @@ -680,6 +686,7 @@ impl Room {
stage: state.stage,
active_player: state.player_order.get(state.active_player).cloned(),
player_order: state.player_order.clone(),
round: state.round,
}
}
}
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@skeletonlabs/skeleton": "2.9.0",
"@skeletonlabs/tw-plugin": "0.3.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.0",
Expand Down
15 changes: 4 additions & 11 deletions src/routes/game/[roomCode]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
let stage: string = 'Joining';
let activePlayer = '';
let description = '';
let roundNum = 0;
// UI state
let displayImages: string[] = [];
Expand Down Expand Up @@ -70,6 +71,7 @@
players = data.RoomState.players;
stage = data.RoomState.stage;
activePlayer = data.RoomState.active_player || '';
roundNum = data.RoomState.round;
if (!rejoin) {
toastStore.trigger({
message: '👋 Connected to room!',
Expand Down Expand Up @@ -122,7 +124,7 @@
<div>
{#if stage !== 'Joining'}
<div class="p-5">
<Leaderboard {players} {stage} {pointChange} {activePlayer} />
<Leaderboard {players} {stage} {pointChange} {activePlayer} {roundNum} />
</div>
{/if}
</div>
Expand All @@ -136,16 +138,7 @@
{:else if stage === 'Voting'}
<Voting {displayImages} {activePlayer} {name} {gameServer} {description} />
{:else if stage === 'Results'}
<Results
{displayImages}
{activePlayer}
{name}
{gameServer}
{description}
{playerToCurrentCard}
{playerToVote}
{activeCard}
/>
<Results {displayImages} {gameServer} {playerToCurrentCard} {playerToVote} {activeCard} />
{/if}
</div>
<!-- {#if stage !== 'Joining'}
Expand Down
26 changes: 15 additions & 11 deletions src/routes/game/[roomCode]/ActiveChooses.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
<div class="py-5">
{#if activePlayer === name}
<h1 class="text-2xl">Choose a card and write a one-word description</h1>
{:else}
<h1 class="text-3xl">Sit tight!</h1>
<p>
Waiting for <span class="boujee-text">{activePlayer}</span> to choose a card and description
</p>
{/if}
</div>

<h1 class="text-xl">{name}, your six cards:</h1>
<Images {displayImages} bind:selectedImage selectable={activePlayer === name} />

{#if activePlayer === name}
<div class="mt-5">
<input
type="text"
placeholder="Description"
Expand All @@ -40,23 +53,14 @@
{#if descriptionBox.includes(' ')}
<p class="text-red-500">Description must be one word</p>
{/if}

<div class="flex justify-center">
<button
class="btn variant-filled"
disabled={selectedImage === '' || descriptionBox === ''}
on:click={activePlayerChoose}>Choose</button
>
</div>
{:else}
<h1 class="text-2xl">Sit tight!</h1>
<p>
Waiting for <span class="boujee-text">{activePlayer}</span> to choose a card and description
</p>
{/if}
</div>

<h1 class="text-xl">{name}, your six cards:</h1>
<Images {displayImages} bind:selectedImage selectable={activePlayer === name} />
</div>
{/if}
</div>
</div>
2 changes: 1 addition & 1 deletion src/routes/game/[roomCode]/Joining.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1 class="text-3xl text-center">Hi {name}, let's play Talespin!</h1>
<h2 class="text-xl text-center">
You are in room
<code class=" code">{roomCode}</code>
<code class="code text-lg">{roomCode}</code>
</h2>
<div class="container flex flex-wrap justify-center gap-4 mt-10">
{#each Object.entries(players) as [key, value]}
Expand Down
5 changes: 3 additions & 2 deletions src/routes/game/[roomCode]/Leaderboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export let stage = '';
export let activePlayer = '';
export let pointChange: { [key: string]: number } = {};
export let roundNum: number;
let sortedPlayersList: string[] = [];
$: {
Expand All @@ -17,10 +18,10 @@

<div class="flex w-80/10 justify-center">
<div class="card light p-4">
<h2 class="text-xl">Points</h2>
<h2 class="text-xl">Round {roundNum}</h2>
<div>
{#each sortedPlayersList as player, i}
<div class="flex space-between w-52">
<div class="flex space-between w-44">
<div class="flex-auto">
{i + 1}.
<span
Expand Down
15 changes: 9 additions & 6 deletions src/routes/game/[roomCode]/PlayersChoose.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,24 @@
<div>
<div class="py-5">
{#if activePlayer === name}
<h1 class="text-2xl">Sit tight!</h1>
<h1 class="text-3xl">Sit tight!</h1>
<p>Players are choosing cards that match "{description}"</p>
{:else}
<h1 class="text-2xl">Your turn!</h1>
<p>
Choose a card that <span class="boujee-text">{activePlayer}</span> would put for "{description}"
</p>
<div class="flex justify-center mt-5">
<button class="btn variant-filled" disabled={selectedImage === ''} on:click={choose}
>Choose</button
>
</div>
{/if}
</div>
<h1 class="text-xl">Your hand:</h1>
<Images {displayImages} bind:selectedImage selectable={activePlayer !== name} />

{#if activePlayer !== name}
<div class="flex justify-center mt-5">
<button class="btn variant-filled" disabled={selectedImage === ''} on:click={choose}
>Choose</button
>
</div>
{/if}
</div>
</div>
8 changes: 4 additions & 4 deletions src/routes/game/[roomCode]/Results.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
export let displayImages: string[] = [];
export let activeCard = '';
export let activePlayer = '';
export let name = '';
export let description = '';
// export let activePlayer = '';
// export let name = '';
// export let description = '';
export let gameServer: GameServer;
export let playerToCurrentCard: { [key: string]: string } = {};
export let playerToVote: { [key: string]: string } = {};
Expand Down Expand Up @@ -64,7 +64,7 @@
</div>
</div>

<button class="btn variant-filled mt-5" on:click={() => gameServer.ready()}>Ready</button>
<button class="btn variant-filled mt-5" on:click={() => gameServer.ready()}>Next Round</button>

<style>
@property --bg-angle {
Expand Down
12 changes: 10 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-auto';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
Expand All @@ -12,7 +12,15 @@ const config = {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
adapter: adapter({
// default options are shown. On some platforms
// these options are set automatically — see below
pages: 'build',
assets: 'build',
fallback: '404.html',
precompress: false,
strict: true
})
}
};
export default config;

0 comments on commit f61fea2

Please sign in to comment.