Skip to content

[Contract]-Bonus matches with a points multiplier #971

@grantfox-oss

Description

@grantfox-oss

Creators may want to make certain matches (e.g. a tournament final) worth more
than others to build excitement toward the end of a campaign.

Goal

Let a creator mark a match with a points_multiplier (e.g. 2 = double
points). Grading (Issue 3) multiplies the earned points by this value.

Requirements

  1. Match struct gains:

    pub points_multiplier: u32, // 1 = normal (default), 2 = double, etc.
  2. r#match::create_match (Issue 1) gains an optional
    points_multiplier: u32 param. New MatchError variant:

    • InvalidPointsMultiplier = 7points_multiplier == 0 || points_multiplier > 3
      (cap at 3x to keep totals bounded; document the cap as a named constant
      MAX_POINTS_MULTIPLIER in storage_types.rs)
    • If you don't want to change create_match's signature again so soon
      after Issue 1, an acceptable alternative is a separate
      set_match_points_multiplier(caller, match_id, multiplier) admin/creator-only
      function called before the match starts. Pick whichever the maintainers
      prefer — flag this in the PR description.
  3. Grading change in oracle::submit_match_result (from Issue 3):

    let base_points = if exact_correct { POINTS_CORRECT_RESULT + POINTS_EXACT_SCORE }
                       else if result_correct { POINTS_CORRECT_RESULT }
                       else { 0 };
    let points = base_points * match_record.points_multiplier;
  4. list_event_matches / get_match naturally surface points_multiplier
    since it's just a struct field — no extra view needed, but confirm the
    frontend types doc (if any) is updated.

Acceptance criteria

  • Matches default to points_multiplier == 1 (no behavior change for
    existing/normal matches)
  • A 2x match awards 0 / 2 / 8 points instead of 0 / 1 / 4
  • Multiplier is validated at creation (1–3 inclusive)

Testing checklist

  • test_create_match_with_double_points_multiplier
  • test_create_match_invalid_multiplier_rejected0 and 4 both rejected
  • test_grading_applies_points_multiplier — 2x match, exact score → points_earned == Some(8)
  • test_leaderboard_reflects_multiplied_points (integration with Issue 4)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions