Initial entity design
This commit is contained in:
1237
package-lock.json
generated
1237
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,17 +14,21 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@sveltejs/adapter-node": "^5.2.2",
|
||||
"@sveltejs/kit": "^2.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||
"@types/eslint": "^9.6.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0",
|
||||
"globals": "^15.0.0",
|
||||
"postcss": "^8.4.41",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
"svelte": "^5.0.0-next.1",
|
||||
"svelte-check": "^3.6.0",
|
||||
"tailwindcss": "^3.4.10",
|
||||
"typescript": "^5.0.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^5.0.3",
|
||||
|
||||
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
4
src/app.css
Normal file
4
src/app.css
Normal file
@@ -0,0 +1,4 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
6
src/lib/components/BracketBoard.svelte
Normal file
6
src/lib/components/BracketBoard.svelte
Normal file
@@ -0,0 +1,6 @@
|
||||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<slot />
|
||||
</div>
|
||||
27
src/lib/components/OneOnOne/OneOnOneBracket.svelte
Normal file
27
src/lib/components/OneOnOne/OneOnOneBracket.svelte
Normal file
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { OneOnOneBracket } from "$lib/match";
|
||||
|
||||
|
||||
export let bracket: OneOnOneBracket;
|
||||
</script>
|
||||
<div>
|
||||
Bracket: {bracket.id}
|
||||
<div>
|
||||
Configuration:
|
||||
<div>
|
||||
Type: {bracket.config.bracketType}
|
||||
</div>
|
||||
<div>
|
||||
Games Per Set: {bracket.config.gamesPerSet}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{#each bracket.setLookup as round, i }
|
||||
<div>
|
||||
Round {i}
|
||||
{#each round as set }
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
13
src/lib/components/OneOnOne/OneOnOneSetCell.svelte
Normal file
13
src/lib/components/OneOnOne/OneOnOneSetCell.svelte
Normal file
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { OneOnOneSet } from "$lib/match";
|
||||
let set: OneOnOneSet;
|
||||
|
||||
</script>
|
||||
<div>
|
||||
<div>
|
||||
{set.p1.name}
|
||||
</div>
|
||||
<div>
|
||||
{set.p2.name}
|
||||
</div>
|
||||
</div>
|
||||
102
src/lib/match.ts
Normal file
102
src/lib/match.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
export enum BracketType {
|
||||
DOUBLE_ELIM = "Double Elimination",
|
||||
SINGLE_ELIM = "Single Elimination",
|
||||
ROUND_ROBIN = "Round Robin",
|
||||
LADDER = "Ladder",
|
||||
SWISS = "Swiss",
|
||||
}
|
||||
|
||||
export class BracketConfig {
|
||||
bracketType: BracketType;
|
||||
gamesPerSet: number;
|
||||
constructor(bracketType?: BracketType, gamesPerSet?: number) {
|
||||
if(bracketType)
|
||||
this.bracketType = bracketType;
|
||||
else
|
||||
this.bracketType = BracketType.DOUBLE_ELIM;
|
||||
if(gamesPerSet)
|
||||
this.gamesPerSet = gamesPerSet;
|
||||
else
|
||||
this.gamesPerSet = 3;
|
||||
}
|
||||
}
|
||||
|
||||
export interface SetGame {
|
||||
p1Rounds?: number;
|
||||
p2Rounds?: number;
|
||||
|
||||
winner: MatchIdentity;
|
||||
}
|
||||
export interface BaseSet<T extends MatchIdentity> {
|
||||
id: string;
|
||||
p1: T | null;
|
||||
p2: T | null;
|
||||
|
||||
setGames: Array<SetGame>;
|
||||
}
|
||||
|
||||
export interface BaseBracket<T extends BaseSet<MatchIdentity>> {
|
||||
id: string;
|
||||
sets: Array<T>;
|
||||
config: BracketConfig;
|
||||
}
|
||||
|
||||
export interface Lookup<TKey, TValue> {
|
||||
key: TKey;
|
||||
value: TValue;
|
||||
}
|
||||
|
||||
export class OneOnOneBracket implements BaseBracket<OneOnOneSet> {
|
||||
id: string;
|
||||
sets = new Array<OneOnOneSet>();
|
||||
setLookup = new Array<Array<Lookup<string, OneOnOneSet>>>();
|
||||
config: BracketConfig;
|
||||
|
||||
constructor(id: string, config: BracketConfig) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
completeSet(set: OneOnOneSet){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class OneOnOneSet implements BaseSet<Player> {
|
||||
id: string;
|
||||
p1: Player | null;
|
||||
p2: Player | null;
|
||||
setGames = new Array<SetGame>();
|
||||
|
||||
constructor(id: string, player1: Player | null = null, player2: Player | null = null) {
|
||||
this.id = id;
|
||||
this.p1 = player1;
|
||||
this.p2 = player2;
|
||||
}
|
||||
|
||||
addSetGame(setGame: SetGame){
|
||||
this.setGames.push(setGame);
|
||||
}
|
||||
|
||||
removeSetGame(setGame: SetGame) {
|
||||
const setGameIndex = this.setGames.indexOf(setGame);
|
||||
if(setGameIndex > -1) {
|
||||
this.setGames.splice(setGameIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface MatchIdentity {
|
||||
name: string;
|
||||
}
|
||||
export interface Player extends MatchIdentity {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface PlayerGroup extends MatchIdentity {
|
||||
|
||||
groupId: string;
|
||||
players: Array<Player>;
|
||||
}
|
||||
5
src/routes/+layout.svelte
Normal file
5
src/routes/+layout.svelte
Normal file
@@ -0,0 +1,5 @@
|
||||
<script lang="ts">
|
||||
import "../app.css";
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
24
src/routes/bracket/OneOnOne/+page.svelte
Normal file
24
src/routes/bracket/OneOnOne/+page.svelte
Normal file
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import BracketBoard from "$lib/components/BracketBoard.svelte";
|
||||
import { type Lookup, type Player, BracketConfig, OneOnOneBracket as BracketEntity, BracketType, OneOnOneSet } from "$lib/match";
|
||||
import OneOnOneBracket from "$lib/components/OneOnOne/OneOnOneBracket.svelte";
|
||||
|
||||
const config = new BracketConfig(BracketType.DOUBLE_ELIM, 3);
|
||||
const bracket = new BracketEntity("A1", config);
|
||||
const testPlayer1 = { id: "tp1", name: "Test Player 1" } as Player;
|
||||
const testPlayer2 = { id: "tp2", name: "Test Player 2" } as Player;
|
||||
const testPlayer3 = { id: "tp3", name: "Test Player 3" } as Player;
|
||||
const testPlayer4 = { id: "tp4", name: "Test Player 4" } as Player;
|
||||
const testSet1 = new OneOnOneSet("A1-1", testPlayer1, testPlayer2);
|
||||
const testSet2 = new OneOnOneSet("A1-2", testPlayer1, testPlayer2);
|
||||
const testSet3 = new OneOnOneSet("A1-3", null, null, testSet1.id, testSet2.id);
|
||||
bracket.sets.push(testSet1);
|
||||
const round1 = new Array<Lookup<string, OneOnOneSet>>();
|
||||
</script>
|
||||
|
||||
<BracketBoard>
|
||||
<OneOnOneBracket {bracket}>
|
||||
</OneOnOneBracket>
|
||||
</BracketBoard>
|
||||
|
||||
|
||||
9
tailwind.config.js
Normal file
9
tailwind.config.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ['./src/**/*.{html,js,svelte,ts}'],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user