Skip to content

fix(sports): align the odds row, and honour the offsets that control it - #268

Merged
ChuckBuilds merged 6 commits into
mainfrom
fix/odds-alignment-and-offsets
Aug 12, 2026
Merged

fix(sports): align the odds row, and honour the offsets that control it#268
ChuckBuilds merged 6 commits into
mainfrom
fix/odds-alignment-and-offsets

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Reported as odds looking too low on some sports and too high on others. It's two separate problems.

1. The same element sat in three different places

Plugin Odds y Result
baseball status_bbox[3] + 2 + offset 8–10px down — a whole text row lower
basketball 0 + odds_y_offset top edge
football, soccer, afl, nrl, ufc 0 top edge

Measured with the real fonts: 8px with 4x6, 10px with PressStart2P. On a 32px card that put baseball's odds a third of the card lower than everyone else's.

Baseball now uses the top edge too — but its lower row was not arbitrary. It's the only scoreboard with text centred on that row (the inning), and the odds are drawn hard left and hard right, so on a narrow panel they meet:

64x32 panel   "O/U: 8.5"   clears the inning by +2px
64x32 panel   "O/U: 12.5"  overlaps by -1px
64x32 "▼12"   "O/U: 12.5"  overlaps by -3px

Double-digit over/unders are ordinary in baseball, so this is a real collision, not a corner case.

So the odds start at the top edge and step down one row only when the actual strings would collide — measured, not keyed to a panel size, because it's the text widths that decide. Verified:

   panel     O/U   odds_y  behaviour
64x32        8.5     0     top edge
64x32       12.5     8     stepped down
128x32      12.5     0     top edge
256x64      12.5     0     top edge
512x64      12.5     0     top edge

A 64px panel still uses the top edge whenever the text fits; everything 128px and wider is unconditionally top-aligned.

2. Controls that did nothing

Football and ufc both declare customization.layout.odds in their config schemas, so the web UI renders x_offset and y_offset fields — and both renderers drew at a fixed 0,0 and never read them. grep for _layout_offset('odds'…) returned 0 matches in football, in a file that uses the same helper for score. A control that visibly does nothing is worse than no control: it tells the user the position can't be fixed.

Soccer, afl and nrl had no odds control at all. They get the same schema block and wiring, so the element behaves the same way everywhere.

schema declares renderer reads after
baseball, basketball yes yes unchanged
football, ufc yes no now reads it
soccer, afl, nrl no no both added

A static check confirms every odds coordinate in all seven renderers now involves an offset (6–10 coordinates each, all covered).

Verification

  • New test_odds_placement.py in baseball: 20 checks — top edge across four panel sizes with one- and two-digit over/unders, the step-down triggering only on a genuine collision, the step being about one text row, both manual offsets still applying, and empty odds drawing nothing.
  • Plugin suites: 43 passed, 1 skipped, 0 failed across the six.
  • Safety harness: 24/16/24/24/24/24 renders, exit 0, no failures.
  • Module-collision and display-contract gates clean.

Versions: baseball, football, ufc are PATCH (fixes); soccer, afl, nrl are MINOR (new config option).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5

Summary by CodeRabbit

  • New Features
    • Added configurable horizontal and vertical positioning for betting odds across AFL, Football, NRL, Soccer, and UFC scoreboards.
    • Odds placement preserves side-specific and centered layouts while supporting manual adjustments.
  • Bug Fixes
    • Improved baseball odds placement to avoid overlapping inning, date, and status text.
    • Fixed odds rendering when totals are provided without a spread.
    • Improved positioning across panel sizes and odds formats.
  • Documentation
    • Updated plugin versions and release histories to reflect the latest improvements.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChuckBuilds, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bfd25b14-786b-497f-b194-3917f785a5d5

📥 Commits

Reviewing files that changed from the base of the PR and between f6e5ab2 and 2db4bba.

📒 Files selected for processing (4)
  • plugins.json
  • plugins/baseball-scoreboard/game_renderer.py
  • plugins/baseball-scoreboard/manifest.json
  • plugins/baseball-scoreboard/test_odds_placement.py
📝 Walkthrough

Walkthrough

The PR adds configurable betting-odds X/Y offsets to several scoreboard plugins. Baseball odds now avoid measured overlap with top-row text. Regression scripts, plugin manifests, and catalog versions are updated.

Changes

Betting Odds Layout

Layer / File(s) Summary
Shared odds offset configuration and rendering
plugins/afl-scoreboard/..., plugins/football-scoreboard/..., plugins/nrl-scoreboard/..., plugins/soccer-scoreboard/..., plugins/ufc-scoreboard/...
AFL, NRL, and Soccer add customization.layout.odds offset settings. AFL, Football, NRL, Soccer, and UFC apply the configured offsets to spread and over/under positions. Regression scripts cover totals-only and other odds combinations.
Baseball collision-aware odds placement
plugins/baseball-scoreboard/game_renderer.py, plugins/baseball-scoreboard/test_odds_placement.py, plugins/baseball-scoreboard/manifest.json
Baseball odds render at the top edge by default and move down one row when measured top-row text overlaps. The test script validates placement, offsets, and empty odds.
Catalog version synchronization
plugins.json
The catalog versions are updated for the affected scoreboard plugins.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ScoreboardCard
  participant GameRenderer
  participant TextMeasurement
  ScoreboardCard->>GameRenderer: Pass game data and rendered top-row text
  GameRenderer->>TextMeasurement: Measure top-row and odds text
  TextMeasurement-->>GameRenderer: Return overlap result
  GameRenderer->>ScoreboardCard: Draw odds at the top or one row lower
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: aligning odds placement and applying configurable odds offsets across sports plugins.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/odds-alignment-and-offsets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

codacy-production Bot commented Aug 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 78 complexity

Metric Results
Complexity 78

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/afl-scoreboard/game_renderer.py`:
- Around line 914-915: Move the odds_x_offset and odds_y_offset assignments in
the odds-rendering method before the if favored_spread is not None branch. Keep
the existing offset values and ensure the over/under path can use them when no
negative spread is present, including the corresponding logic around the
alternate referenced lines.

In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 997-1010: Update the collision-check flow using _inning_text so it
measures the actual top-row text for each card type: recent cards should use
“Final” and upcoming cards should use their rendered time or date, with the
matching font. Pass this rendered text and font into the collision check or
provide card-specific obstacle text, then add placement coverage for recent and
upcoming cards across the required panel sizes.

In `@plugins/baseball-scoreboard/test_odds_placement.py`:
- Around line 104-109: Update the odds_y test case for the narrow panel and long
“FINAL” label to pass is_final=True alongside inning_half="top". Extend odds_y
with an is_final argument if needed, ensuring this case measures the FINAL label
rather than the default ▲3 text.

In `@plugins/nrl-scoreboard/game_renderer.py`:
- Around line 886-897: Move the odds_x_offset and odds_y_offset initialization
using _layout_offset before the favored_spread conditional so both
favorite-spread and over/under rendering can use them safely. Apply this change
in plugins/nrl-scoreboard/game_renderer.py at lines 886-897 and
plugins/soccer-scoreboard/game_renderer.py at lines 886-897; no other behavior
needs changing.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b06f1333-c61f-43b9-bec4-2cda360bf61e

📥 Commits

Reviewing files that changed from the base of the PR and between 8dd8f07 and 943accd.

📒 Files selected for processing (17)
  • plugins.json
  • plugins/afl-scoreboard/config_schema.json
  • plugins/afl-scoreboard/game_renderer.py
  • plugins/afl-scoreboard/manifest.json
  • plugins/baseball-scoreboard/game_renderer.py
  • plugins/baseball-scoreboard/manifest.json
  • plugins/baseball-scoreboard/test_odds_placement.py
  • plugins/football-scoreboard/game_renderer.py
  • plugins/football-scoreboard/manifest.json
  • plugins/nrl-scoreboard/config_schema.json
  • plugins/nrl-scoreboard/game_renderer.py
  • plugins/nrl-scoreboard/manifest.json
  • plugins/soccer-scoreboard/config_schema.json
  • plugins/soccer-scoreboard/game_renderer.py
  • plugins/soccer-scoreboard/manifest.json
  • plugins/ufc-scoreboard/manifest.json
  • plugins/ufc-scoreboard/sports.py

Comment thread plugins/afl-scoreboard/game_renderer.py Outdated
Comment thread plugins/baseball-scoreboard/game_renderer.py
Comment on lines +104 to +109
print("\nthe step is decided by the text, not the panel size")
# A long inning label ("FINAL") is wider than a short one, so it can push
# the odds down at a width where a short label does not.
y_final, _ = odds_y(64, 32, 8.5, inning_half="top")
check("a narrow panel with short strings still uses the top edge",
y_final == 0, "y=%s" % y_final)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise the FINAL collision case.

Line 107 passes inning_half="top". The helper does not set is_final, so this test measures ▲3 instead of FINAL.

Add an is_final argument to odds_y() and set it for this case. This will test the long top-row label described by the comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/baseball-scoreboard/test_odds_placement.py` around lines 104 - 109,
Update the odds_y test case for the narrow panel and long “FINAL” label to pass
is_final=True alongside inning_half="top". Extend odds_y with an is_final
argument if needed, ensuring this case measures the FINAL label rather than the
default ▲3 text.

Comment thread plugins/nrl-scoreboard/game_renderer.py Outdated
claude added 5 commits August 12, 2026 13:27
The same element sat in three different places. Baseball drew the odds a
whole text row below the top -- status_bbox[3] + 2, which measures 8px
with the 4x6 font and 10px with PressStart2P -- while basketball drew
them at the top edge with an offset applied, and football, soccer, afl,
nrl and ufc drew them at a fixed 0,0. On a 32px card that put baseball's
odds a third of the card lower than everyone else's.

Baseball now uses the top edge too. Its lower row was not arbitrary: it
is the only scoreboard with text centred on that row, and the odds are
drawn hard left and hard right, so on a narrow panel they meet. That is
now decided by measuring the actual strings rather than by assuming --
on a 64px panel "O/U: 8.5" clears the inning by 2px while "O/U: 12.5"
overlaps it, and double-digit over/unders are ordinary in baseball. The
odds start at the top edge and step down one row only when these
particular strings would collide, so every panel 128px and wider is
unconditionally top-aligned and a 64px panel keeps the top edge whenever
the text fits.

Football and ufc declare customization.layout.odds in their config
schemas, so the web UI offered x_offset and y_offset, and both renderers
ignored them entirely. A control that visibly does nothing is worse than
no control: it tells the user the position cannot be fixed. Both now
apply them.

Soccer, afl and nrl had no odds control at all. They get the same
schema block and the same wiring, so the element behaves the same way
everywhere.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
The plugin modules load under bare names, so a static analyser resolving
`game_renderer` across the repo can bind another plugin's copy, whose
_draw_dynamic_odds takes one argument fewer. Naming the parameter makes
the call unambiguous to both a reader and a checker.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
Two defects this PR introduced, both found by CodeRabbit.

The layout offsets were read inside `if favored_spread is not None`,
while the over/under block below uses them unconditionally. A game
priced with a total and no spread -- ordinary enough -- raised
UnboundLocalError, and the bare except around the method swallowed it,
so the card drew no odds at all rather than drawing the total. Affects
afl, nrl and soccer; the offsets are now read before either branch.

Baseball's collision check always measured the live card's inning
indicator, but _draw_dynamic_odds is called from three renderers and
they do not centre the same string: a recent card draws "Final" and an
upcoming card a time or a date. On a narrow panel the odds were being
placed against a string that was not on the screen. Each caller now
passes what it actually draws, and the upcoming card's choice is derived
in one place so it cannot drift from the code that draws it.

The three new tests fail exactly the total-with-no-spread case against
the previous commit; the baseball placement test gains recent and
upcoming cases across panel sizes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
Codacy resolves the bare `game_renderer` module name across plugins, so
it can bind another scoreboard's copy -- whose _draw_dynamic_odds takes
fewer arguments -- and reports the extra positional ones as an error. It
flagged the two call sites this branch changed, the same complaint that
was already settled once on the test file. Naming the optional
parameters makes the calls unambiguous to a reader and to the checker.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
The afl test acquired a second module-level import block partway down
the file, for the core-path shim its renderer needs, which reads as two
misplaced imports. os moves up with the other standard-library imports;
the plugin import has to stay after the sys.path work and now says so
explicitly rather than leaving a checker to guess.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
@ChuckBuilds
ChuckBuilds force-pushed the fix/odds-alignment-and-offsets branch from 076b3c0 to f6e5ab2 Compare August 12, 2026 17:30

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 827-838: Update _upcoming_top_row_text and the related
_odds_would_hit_top_row flow to measure the actual rendered top-row bounds,
including the selected font and X position from _draw_upcoming_game_status.
Preserve swap_date_time behavior so the date uses detail and
layout.date.x_offset rather than re-centering the time. Add coverage for 64×32
with swap_date_time enabled and a nonzero date X offset, while preserving
correct placement at 128×32, 128×64, and 256×32.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1ad4fe7-2db6-4f52-b667-74cf6eb24b70

📥 Commits

Reviewing files that changed from the base of the PR and between b6481ca and f6e5ab2.

📒 Files selected for processing (6)
  • plugins.json
  • plugins/afl-scoreboard/test_odds_without_spread.py
  • plugins/baseball-scoreboard/game_renderer.py
  • plugins/football-scoreboard/manifest.json
  • plugins/nrl-scoreboard/test_odds_without_spread.py
  • plugins/soccer-scoreboard/test_odds_without_spread.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/afl-scoreboard/test_odds_without_spread.py
  • plugins/soccer-scoreboard/test_odds_without_spread.py

Comment thread plugins/baseball-scoreboard/game_renderer.py Outdated
The collision check took the top-row text and measured it itself, always
with the `time` font and always perfectly centred. An upcoming card with
swap_date_time draws the date in `detail` instead, shifted by that
element's configured x_offset, so the check could move the odds down
when nothing was in the way or leave them overlapping when something
was. Reported by CodeRabbit.

Callers now pass the span they actually drew. That also removes the last
place where the measurement could drift from the drawing, which is the
same defect this file already had once: the check used to measure a live
card's inning on recent and upcoming cards too.

"Nothing on the top row" and "the caller did not say" were both None,
so a card that genuinely centres nothing fell back to measuring an
inning it does not draw. A sentinel separates them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
@ChuckBuilds
ChuckBuilds merged commit 0099e67 into main Aug 12, 2026
4 checks passed
@ChuckBuilds
ChuckBuilds deleted the fix/odds-alignment-and-offsets branch August 12, 2026 18:05
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.

2 participants