progress
This commit is contained in:
parent
e517bed681
commit
b47325a0dc
0
.gitignore → backend/.gitignore
vendored
0
.gitignore → backend/.gitignore
vendored
0
Cargo.lock → backend/Cargo.lock
generated
0
Cargo.lock → backend/Cargo.lock
generated
@ -32,6 +32,7 @@ struct MyState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
struct GamestateJson {
|
struct GamestateJson {
|
||||||
state: GameState,
|
state: GameState,
|
||||||
dealer_upcard: Option<Card>,
|
dealer_upcard: Option<Card>,
|
||||||
@ -60,5 +61,5 @@ pub fn build() -> Rocket<Build> {
|
|||||||
|
|
||||||
rocket::build()
|
rocket::build()
|
||||||
.manage(state)
|
.manage(state)
|
||||||
.mount("/", routes![get_state, post_move])
|
.mount("/api", routes![get_state, post_move])
|
||||||
}
|
}
|
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
12
frontend/index.html
Normal file
12
frontend/index.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Blackjack</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
2898
frontend/package-lock.json
generated
Normal file
2898
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
frontend/package.json
Normal file
24
frontend/package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
||||||
|
"@tsconfig/svelte": "^5.0.2",
|
||||||
|
"autoprefixer": "^10.4.19",
|
||||||
|
"postcss": "^8.4.38",
|
||||||
|
"svelte": "^4.2.12",
|
||||||
|
"svelte-check": "^3.6.7",
|
||||||
|
"tailwindcss": "^3.4.3",
|
||||||
|
"tslib": "^2.6.2",
|
||||||
|
"typescript": "^5.2.2",
|
||||||
|
"vite": "^5.2.0"
|
||||||
|
}
|
||||||
|
}
|
6
frontend/postcss.config.js
Normal file
6
frontend/postcss.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
}
|
22
frontend/src/App.svelte
Normal file
22
frontend/src/App.svelte
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {fetchState} from "./functions/fetchState";
|
||||||
|
import { CardSuit } from "./types/CardSuit";
|
||||||
|
|
||||||
|
async function getState() {
|
||||||
|
let state = await fetchState();
|
||||||
|
console.debug(state);
|
||||||
|
|
||||||
|
if (state.dealerUpcard.suit == CardSuit.Spades){
|
||||||
|
console.debug("Heureka");
|
||||||
|
}else{
|
||||||
|
console.debug("FUCK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div>Hello world</div>
|
||||||
|
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" on:click={getState}>Get state</button>
|
||||||
|
</main>
|
6
frontend/src/functions/fetchState.ts
Normal file
6
frontend/src/functions/fetchState.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import type { Gamestate } from "../types/Gamestate";
|
||||||
|
|
||||||
|
export async function fetchState(): Promise<Gamestate>{
|
||||||
|
let res = await fetch("/api/state");
|
||||||
|
return await res.json();
|
||||||
|
}
|
3
frontend/src/index.css
Normal file
3
frontend/src/index.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
9
frontend/src/lib/Card.svelte
Normal file
9
frontend/src/lib/Card.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Card } from "../types/Card";
|
||||||
|
|
||||||
|
export let card: Card;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="w-2 h-5">
|
||||||
|
I am a {card.index} of {card.suit}!
|
||||||
|
</div>
|
8
frontend/src/main.ts
Normal file
8
frontend/src/main.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import "./index.css"
|
||||||
|
import App from './App.svelte'
|
||||||
|
|
||||||
|
const app = new App({
|
||||||
|
target: document.getElementById('app')!,
|
||||||
|
})
|
||||||
|
|
||||||
|
export default app
|
7
frontend/src/types/Card.ts
Normal file
7
frontend/src/types/Card.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import type { CardIndex } from "./CardIndex";
|
||||||
|
import type { CardSuit } from "./CardSuit";
|
||||||
|
|
||||||
|
export interface Card {
|
||||||
|
suit: CardSuit,
|
||||||
|
index: CardIndex,
|
||||||
|
}
|
15
frontend/src/types/CardIndex.ts
Normal file
15
frontend/src/types/CardIndex.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export enum CardIndex {
|
||||||
|
A = "A",
|
||||||
|
K = "K",
|
||||||
|
Q = "Q",
|
||||||
|
J = "J",
|
||||||
|
N10 = "N10",
|
||||||
|
N9 = "N9",
|
||||||
|
N8 = "N8",
|
||||||
|
N7 = "N7",
|
||||||
|
N6 = "N6",
|
||||||
|
N5 = "N5",
|
||||||
|
N4 = "N4",
|
||||||
|
N3 = "N3",
|
||||||
|
N2 = "N2",
|
||||||
|
}
|
6
frontend/src/types/CardSuit.ts
Normal file
6
frontend/src/types/CardSuit.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export enum CardSuit {
|
||||||
|
Spades = "Spades",
|
||||||
|
Clubs = "Clubs",
|
||||||
|
Hearts = "Hearts",
|
||||||
|
Diamonds = "Diamonds",
|
||||||
|
}
|
5
frontend/src/types/Gamestate.ts
Normal file
5
frontend/src/types/Gamestate.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import type { Card } from "./Card";
|
||||||
|
|
||||||
|
export interface Gamestate{
|
||||||
|
dealerUpcard: Card,
|
||||||
|
}
|
2
frontend/src/vite-env.d.ts
vendored
Normal file
2
frontend/src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/// <reference types="svelte" />
|
||||||
|
/// <reference types="vite/client" />
|
7
frontend/svelte.config.js
Normal file
7
frontend/svelte.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
|
||||||
|
// for more information about preprocessors
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
}
|
12
frontend/tailwind.config.js
Normal file
12
frontend/tailwind.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
export default {
|
||||||
|
content: [
|
||||||
|
"./index.html",
|
||||||
|
"./src/**/*.{js,ts,jsx,tsx,svelte}",
|
||||||
|
],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
20
frontend/tsconfig.json
Normal file
20
frontend/tsconfig.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
/**
|
||||||
|
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||||
|
* Disable checkJs if you'd like to use dynamic types in JS.
|
||||||
|
* Note that setting allowJs false does not prevent the use
|
||||||
|
* of JS in `.svelte` files.
|
||||||
|
*/
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"isolatedModules": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||||
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
|
}
|
10
frontend/tsconfig.node.json
Normal file
10
frontend/tsconfig.node.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
12
frontend/vite.config.ts
Normal file
12
frontend/vite.config.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [svelte()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
"/api" : "http://127.0.0.1:8000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user