Skip to content

Add set-based scoring support for matches - #43

Merged
davidohnee merged 8 commits into
mainfrom
copilot/fix-6b9ef98d-23e4-4543-913c-fcb334ab9e68
Oct 26, 2025
Merged

davidohnee merged 8 commits into
mainfrom
copilot/fix-6b9ef98d-23e4-4543-913c-fcb334ab9e68

Conversation

Copilot AI commented Oct 4, 2025 •

Copy link
Copy Markdown
Contributor

This PR implements set-based scoring for matches, enabling tournaments to track individual set scores (e.g., 6-4, 7-5 for tennis or volleyball) with automatic match score calculation.

Overview

The feature allows tournament organizers to:

  1. Enable set-based scoring when creating a tournament (for sports that support it)
  2. Add and manage individual set scores in the match editor
  3. Have match scores automatically calculated based on sets won (1 point per set)
  4. Manually override scores if needed, with a clear warning and ability to sync back

Implementation Details

Type System

Added new types to support set-based scoring:

  • SetScore type for individual set scores (team1 vs team2)
  • sets array on Match interface to store set scores
  • manualScoreOverride flag to track when scores don't match sets
  • useSets flag in tournament config to enable the feature

Sport Configuration

Extended sport defaults with supportsSets flag. Currently enabled for the "Other" sport type, but can easily be extended to tennis, volleyball, and other set-based sports.

Score Calculation

Implemented calculateScoresFromSets() helper function that counts the number of sets won by each team. The match score automatically updates as set scores are entered.

User Interface

Tournament Creation:
When selecting a sport that supports sets, a checkbox appears to enable set-based scoring with helpful descriptive text.

Set-based scoring option

Match Editor - Sets Section:
Added a dedicated "Sets" section in the match editor modal with:

  • "Add Set" button to dynamically add sets
  • Labeled set rows (Set 1, Set 2, etc.) with score inputs
  • Remove button for each set
  • Clean, intuitive layout

Match editor with sets

Automatic Score Calculation:
As users enter set scores, the main match score automatically updates. In this example, Team 16 won the first set 6-4, so their match score shows 1:

Auto-calculated scores

Manual Override Warning:
If users manually change the match score to differ from the sets, a warning banner appears with a "Sync with sets" button to restore automatic calculation:

Manual override warning

Example Usage

// Tournament config with sets enabled
const tournament = {
  config: {
    sport: "other",
    useSets: true,
    // ... other config
  }
};

// Match with set scores
const match = {
  teams: [
    { ref: team1, score: 2 },  // Won 2 sets
    { ref: team2, score: 1 }   // Won 1 set
  ],
  sets: [
    { team1: 6, team2: 4 },  // Set 1: 6-4
    { team1: 7, team2: 5 },  // Set 2: 7-5
    { team1: 4, team2: 6 }   // Set 3: 4-6
  ],
  manualScoreOverride: false
};

Code Quality

  • ✅ All TypeScript compilation passes
  • ✅ All linters pass (oxlint, eslint)
  • ✅ Maintains existing code patterns and conventions
  • ✅ Fully type-safe implementation
  • ✅ Backward compatible (sets are optional)

Fixes #6

Original prompt

This section details on the original issue you should resolve

<issue_title>Match: support sets</issue_title>
<issue_description>Acceptance criteria

  • Match creator: allow enabling "sets" when selecting the Sport
  • Score input: allow adding sets and setting the set sore
    ** The match score is automatically computed (1 point for each won set for each side)
    ** The match score can manually be overwritten. A warning is then displayed ("not in sync with sets") and a button to use the automatic computation.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #42

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 4, 2025 •

Copy link
Copy Markdown

Deploying bracketeer with  Cloudflare Pages  Cloudflare Pages

Latest commit: d699774
Status: ✅  Deploy successful!
Preview URL: https://f1407b03.bracketeer-3cf.pages.dev
Branch Preview URL: https://copilot-fix-6b9ef98d-23e4-45.bracketeer-3cf.pages.dev

View logs

Copilot AI and others added 2 commits October 4, 2025 11:46
Co-authored-by: davidohnee <48208462+davidohnee@users.noreply.github.com>
Co-authored-by: davidohnee <48208462+davidohnee@users.noreply.github.com>
Copilot AI changed the title [WIP] Match: support sets Add set-based scoring support for matches Oct 4, 2025
Copilot AI requested a review from davidohnee October 4, 2025 12:34
@davidohnee
davidohnee requested review from Copilot and removed request for davidohnee October 26, 2025 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements set-based scoring for matches, enabling tournaments to track individual set scores (e.g., 6-4, 7-5) with automatic match score calculation based on sets won.

Key Changes:

  • Added type system support for set scores with SetScore type and sets array on the Match interface
  • Implemented automatic score calculation that counts sets won by each team
  • Created UI for managing set scores in the match editor with add/remove functionality and manual override warnings

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types/tournament.ts Added SetScore type and optional sets array to Match interface, plus useSets flag in tournament config
src/helpers/scoring.ts Implemented calculateScoresFromSets() function to compute match scores from set wins
src/helpers/defaults.ts Restructured sport defaults with courtLabel as nested object and added sets configuration with supported and default flags
src/views/Create/BasicsView.vue Added checkbox UI for enabling set-based scoring when creating tournaments, with computed property to check sport support
src/components/modals/MatchEditorModal.vue Added sets management UI with add/remove buttons, score inputs, sync functionality, and out-of-sync detection
src/assets/css/dialogs.css Added max-height: 80vh constraint to dialogs and increased close button font size

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/views/Create/BasicsView.vue Resolved
@davidohnee
davidohnee force-pushed the copilot/fix-6b9ef98d-23e4-4543-913c-fcb334ab9e68 branch from 5083a1e to b5be4a8 Compare October 26, 2025 16:28
Repository owner deleted a comment from Copilot AI Oct 26, 2025
@davidohnee
davidohnee force-pushed the copilot/fix-6b9ef98d-23e4-4543-913c-fcb334ab9e68 branch from b5be4a8 to db0b6fe Compare October 26, 2025 16:31
@davidohnee
davidohnee requested a review from Copilot October 26, 2025 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helpers/defaults.ts Resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@davidohnee
davidohnee marked this pull request as ready for review October 26, 2025 16:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@davidohnee
davidohnee self-requested a review October 26, 2025 18:27
@davidohnee
davidohnee merged commit 3dd47f2 into main Oct 26, 2025
@davidohnee
davidohnee deleted the copilot/fix-6b9ef98d-23e4-4543-913c-fcb334ab9e68 branch October 26, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match: support sets

3 participants