Instruction file imported from patrikvalentiny/kongekampen (
.github/instructions/kongekampen.instructions.md). Copyright stays with the author.
Instructions: Dodgeball Tournament App (Kongekampen Style)
This guide outlines the development of a tournament management app for a 32-team dodgeball event. The format is 8 groups of 4 teams, with group winners advancing to Quarter-finals. Scoring is based on "players remaining."
1. Tech Stack
- Frontend: React (Vite)
- UI Components: DaisyUI + Tailwind CSS
- Backend/Database: Supabase
- Icons: Lucide React
2. Specialized Database Schema
'tournament'
id: uuid (PK)name: text (e.g., "Kongekampen 2024")
groups
id: uuid (PK)name: text (e.g., "Group A")tournament_id: uuid (FK)
teams
id: uuid (PK)group_id: uuid (FK)name: texttournament_id: uuid (FK)
matches
id: uuid (PK)group_id: uuid (FK, null for knockouts)stage: text ('group', 'quarter', 'semi', 'final')team_a_id: uuid (FK)team_b_id: uuid (FK)team_a_players_left: int (Score for Team A)team_b_players_left: int (Score for Team B)winner_id: uuid (FK)status: text ('to be played', 'in progress', 'completed')tournament_id: uuid (FK)
3. Scoring & Advancement Logic (Dodgeball Rules)
Group Stage Ranking Criteria
The standings are determined primarily by Match Points. In the event of a tie between teams, the following tie-breakers will be applied in descending order:
1. Match Points (MP)
Points are awarded based on the result of the single-set match:
- Win: 2 Points
- Draw: 1 Point (Only if time expires with an equal number of players on court)
- Loss: 0 Points
2. Tie-Breaking Hierarchy
If two or more teams are level on Match Points, the following metrics determine the higher rank:
| Priority | Metric | Definition |
|---|---|---|
| 1st | Head-to-Head | The result of the specific match between the tied teams. |
| 2nd | Player Difference (PD) | Total players remaining for your team minus total players remaining for opponents. |
| 3rd | Players Remaining (PR) | Total cumulative players left on the court for your team across all matches. |
| 4th | Sudden Death | A 1-on-1 "Showdown" or a 2-minute "Golden Goal" set. |
Note on Player Difference (PD): This acts as the "Goal Difference" of dodgeball. For example, if you win a match 4-0, your PD is +4. If you lose 0-2, your PD is -2.
Advancement
- Only the 1st place team from each of the 8 groups advances.
- Quarter-final seeding:
- Match 1: Winner A vs Winner B
- Match 2: Winner C vs Winner D
- Match 3: Winner E vs Winner F
- Match 4: Winner G vs Winner H
4. UI/UX Requirements (DaisyUI)
- Standings Table:
- Columns: Team, P (Played), W, D, L, PD (Player Difference), Pts.
- Use
table-zebraand highlight the top row (Rank 1) inbg-primary/10to show advancement status.
- Score Input Modal:
- Use a DaisyUI
modal. - Input fields should be labeled "Players Remaining (Team A)" and "Players Remaining (Team B)".
- Max input value should likely be capped (e.g., 6 or 10 depending on starting team size).
- Use a DaisyUI
- Match Cards:
- Show the count of surviving players as the primary score.
- Example: "Team Alpha (4) vs (0) Team Beta".
5. Implementation Steps for the LLM
- Database Setup: Initialize tables with a focus on the
players_leftintegers instead of standard "goals." - Standings Logic: Write a PostgreSQL View to calculate the "Player Difference" tiebreaker from the match results.
- Scheduler: A script to auto-generate the 48 group matches (6 per group).
- Knockout Trigger: A function that monitors group completion. Once all 6 matches in Group A and Group B are 'completed', it automatically identifies the winners and creates the Quarter-final match record.