Skip to content

fix(basketball,baseball): add odds layout offsets and align customization#74

Merged
ChuckBuilds merged 3 commits intomainfrom
fix/sports-odds-customization
Mar 30, 2026
Merged

fix(basketball,baseball): add odds layout offsets and align customization#74
ChuckBuilds merged 3 commits intomainfrom
fix/sports-odds-customization

Conversation

@ChuckBuilds
Copy link
Copy Markdown
Owner

@ChuckBuilds ChuckBuilds commented Mar 30, 2026

Summary

  • Basketball: Odds now render in scroll mode (render_game_card was missing the _draw_dynamic_odds call). User-configurable layout offsets applied to odds positions in both display modes.
  • Baseball: Added missing font customization entries (period_text, team_name, rank_text) and odds layout offset to config schema, aligning with football/basketball. Layout offsets applied to odds rendering.

Test plan

  • Basketball: verify odds appear in scroll mode
  • Basketball: adjust odds x/y offsets in web UI, verify positioning changes
  • Baseball: verify new font customization sections appear in web UI settings
  • Baseball: verify odds layout offset section appears under Layout Positioning
  • Baseball: adjust odds offsets and verify rendering

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added customizable layout offsets for odds display positioning in baseball and basketball scoreboards, allowing users to fine-tune odds placement via configuration.
  • Chores

    • Updated basketball-scoreboard plugin version to 1.5.5.

…tion

Basketball:
- Add odds rendering to scroll mode (render_game_card now calls
  _draw_dynamic_odds, matching baseball's behavior)
- Apply user-configurable layout offsets to odds positioning in both
  switch mode (sports.py) and scroll mode (game_renderer.py)

Baseball:
- Add missing font customization entries: period_text, team_name,
  rank_text (aligns with football/basketball)
- Add odds layout offset to config schema
- Apply user-configurable layout offsets to odds positioning
- Update x-propertyOrder to include new entries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6db03a09-3391-4627-8fbd-e35c4fc354ca

📥 Commits

Reviewing files that changed from the base of the PR and between 125bf95 and 43963a9.

📒 Files selected for processing (4)
  • plugins/baseball-scoreboard/game_renderer.py
  • plugins/baseball-scoreboard/sports.py
  • plugins/basketball-scoreboard/game_renderer.py
  • plugins/basketball-scoreboard/manifest.json

📝 Walkthrough

Walkthrough

The PR adds configurable layout offsets for odds rendering across baseball and basketball scoreboard plugins, introducing a _get_layout_offset() helper method to read offset values from configuration and applying them to odds text positioning in both horizontal and vertical axes.

Changes

Cohort / File(s) Summary
Baseball Scoreboard Odds Layout
plugins/baseball-scoreboard/game_renderer.py, plugins/baseball-scoreboard/sports.py
Added _get_layout_offset() method to read per-element layout offsets from config with fallback defaults. Updated _draw_dynamic_odds to apply configurable odds_x_offset and odds_y_offset to favored spread and over/under text positioning instead of using fixed coordinates.
Basketball Scoreboard Odds Layout
plugins/basketball-scoreboard/game_renderer.py, plugins/basketball-scoreboard/sports.py
Added identical _get_layout_offset() helper method and updated _draw_dynamic_odds to apply configurable x/y offsets to all odds text placements. Introduced conditional odds rendering in render_game_card when odds data is present.
Version Update
plugins/basketball-scoreboard/manifest.json
Bumped basketball scoreboard plugin version from 1.5.4 to 1.5.5 with release date 2026-03-30. Updated versions array with prior releases shifted down.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: adding odds layout offsets and aligning customization across basketball and baseball plugins.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sports-odds-customization

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
plugins/baseball-scoreboard/game_renderer.py (1)

530-538: Consider aligning _get_layout_offset behavior with SportsCore for consistency.

Right now this parser is stricter and quieter than the one in plugins/baseball-scoreboard/sports.py (e.g., string float handling and warning logs). Matching behavior would reduce cross-mode config surprises.

Consistency-oriented refactor
 def _get_layout_offset(self, element: str, axis: str, default: int = 0) -> int:
     """Get layout offset for a specific element and axis from config."""
     try:
         layout_config = self.config.get('customization', {}).get('layout', {})
         element_config = layout_config.get(element, {})
         offset_value = element_config.get(axis, default)
-        return int(offset_value) if offset_value is not None else default
-    except (TypeError, ValueError):
+        if isinstance(offset_value, (int, float)):
+            return int(offset_value)
+        if isinstance(offset_value, str):
+            try:
+                return int(float(offset_value))
+            except (TypeError, ValueError):
+                self.logger.warning(
+                    "Invalid layout offset value for %s.%s: %r, using default %d",
+                    element, axis, offset_value, default
+                )
+                return default
+        return default
+    except Exception:
         return default
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/baseball-scoreboard/game_renderer.py` around lines 530 - 538, The
_get_layout_offset method is stricter than SportsCore; update it to mirror
SportsCore's behavior by accepting numeric strings (including floats), coercing
them to int via int(float(value)) when needed, and emitting a warning when such
coercion occurs or when a non-numeric value is ignored; keep the same default
fallback on failure. Locate _get_layout_offset and the SportsCore parsing logic
in plugins/baseball-scoreboard/sports.py for reference, use the instance logger
(e.g., self.logger.warning) to report conversions or parse failures, and
preserve the TypeError/ValueError fallback to return default.
plugins/basketball-scoreboard/game_renderer.py (1)

462-470: Keep offset parsing behavior consistent with sports.py.

This helper currently rejects numeric strings like "2.0" (falls back to default), while SportsCore._get_layout_offset accepts them. Aligning the coercion logic will avoid mode-to-mode config inconsistencies.

Suggested refactor
     def _get_layout_offset(self, element: str, axis: str, default: int = 0) -> int:
         """Get layout offset for a specific element and axis from config."""
         try:
             layout_config = self.config.get('customization', {}).get('layout', {})
             element_config = layout_config.get(element, {})
             offset_value = element_config.get(axis, default)
-            return int(offset_value) if offset_value is not None else default
-        except (TypeError, ValueError):
+            if isinstance(offset_value, (int, float)):
+                return int(offset_value)
+            if isinstance(offset_value, str):
+                return int(float(offset_value))
+            return default
+        except (TypeError, ValueError):
             return default
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/basketball-scoreboard/game_renderer.py` around lines 462 - 470, The
_get_layout_offset helper currently returns default for numeric strings like
"2.0"; update _get_layout_offset so it mirrors SportsCore._get_layout_offset by
coercing values more flexibly: retrieve offset_value from self.config as now,
then if offset_value is None return default, else try to convert to int
directly, and if that fails for ValueError on strings attempt
float(offset_value) then int() that result, and still catch TypeError/ValueError
to return default; reference the function name _get_layout_offset and the local
variables layout_config/element_config/offset_value when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/baseball-scoreboard/manifest.json`:
- Line 4: The manifest's release metadata is inconsistent: update the top entry
in the "versions" array to add the new release first and bump it to a minor
version (e.g., 1.6.0) to reflect schema additions, then set the "version" field
to the same value (ensure the top "versions" entry and the "version" field
match). Locate and update any other occurrences of the older version string in
the manifest (e.g., additional version lists or metadata entries) so all
references are consistent and reflect the new minor release.

In `@plugins/basketball-scoreboard/manifest.json`:
- Line 4: The manifest's "version" field ("version": "1.5.5") and the first
entry of the "versions" array are out of sync (top entry still "1.5.4"); update
the "versions" array by inserting a new entry for "1.5.5" at the front (most
recent first) so versions[0] equals the "version" field, and ensure any related
metadata in the new entry mirrors the format of other entries (timestamp,
changelog, etc.) so both the "version" key and versions[0] remain aligned.

---

Nitpick comments:
In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 530-538: The _get_layout_offset method is stricter than
SportsCore; update it to mirror SportsCore's behavior by accepting numeric
strings (including floats), coercing them to int via int(float(value)) when
needed, and emitting a warning when such coercion occurs or when a non-numeric
value is ignored; keep the same default fallback on failure. Locate
_get_layout_offset and the SportsCore parsing logic in
plugins/baseball-scoreboard/sports.py for reference, use the instance logger
(e.g., self.logger.warning) to report conversions or parse failures, and
preserve the TypeError/ValueError fallback to return default.

In `@plugins/basketball-scoreboard/game_renderer.py`:
- Around line 462-470: The _get_layout_offset helper currently returns default
for numeric strings like "2.0"; update _get_layout_offset so it mirrors
SportsCore._get_layout_offset by coercing values more flexibly: retrieve
offset_value from self.config as now, then if offset_value is None return
default, else try to convert to int directly, and if that fails for ValueError
on strings attempt float(offset_value) then int() that result, and still catch
TypeError/ValueError to return default; reference the function name
_get_layout_offset and the local variables
layout_config/element_config/offset_value when making the change.
🪄 Autofix (Beta)

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

Run ID: 97883777-b6e5-4c34-86d9-e7b04392eb17

📥 Commits

Reviewing files that changed from the base of the PR and between 0107328 and 125bf95.

📒 Files selected for processing (7)
  • plugins/baseball-scoreboard/config_schema.json
  • plugins/baseball-scoreboard/game_renderer.py
  • plugins/baseball-scoreboard/manifest.json
  • plugins/baseball-scoreboard/sports.py
  • plugins/basketball-scoreboard/game_renderer.py
  • plugins/basketball-scoreboard/manifest.json
  • plugins/basketball-scoreboard/sports.py

ChuckBuilds and others added 2 commits March 30, 2026 12:43
- Baseball manifest: bump to 1.6.0 (schema additions warrant minor),
  add versions array entry, update last_updated to 2026-03-30
- Basketball manifest: add missing 1.5.5 entry to versions array so
  versions[0] matches the version field
- Both game_renderer.py _get_layout_offset: align with SportsCore
  pattern — handle string values via int(float(value)) and log
  warnings on invalid values instead of silently returning default

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChuckBuilds ChuckBuilds merged commit ffd2f5a into main Mar 30, 2026
1 check was pending
@ChuckBuilds ChuckBuilds deleted the fix/sports-odds-customization branch March 30, 2026 17:12
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.

1 participant