Skip to content

Refactor animatePlayerMoveGeneric to delegate logic to game.execute_move()#54

Open
durangogt with Copilot wants to merge 3 commits into
feature/aggravation-mechanicsfrom
copilot/sub-pr-34-again
Open

Refactor animatePlayerMoveGeneric to delegate logic to game.execute_move()#54
durangogt with Copilot wants to merge 3 commits into
feature/aggravation-mechanicsfrom
copilot/sub-pr-34-again

Conversation

Copilot AI commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Eliminates code duplication between UI layer (animatePlayerMoveGeneric) and game engine (execute_move). Previously, aggravation logic was independently implemented in both locations, creating maintenance burden and potential for inconsistency between GUI and headless modes.

Changes

  • Centralized game logic: animatePlayerMoveGeneric now calls game.execute_move() upfront for all move logic including aggravation detection
  • Removed duplicate code: Deleted direct calls to find_marble_at_position() and send_marble_home() from UI layer
  • Animation driven by result: Aggravation animation triggered by move_result['aggravated_opponent'] flag instead of redundant detection
  • Consistency check: Added validation to ensure animation position matches execute_move calculation

Before

# UI layer duplicated aggravation logic
opponent = game.find_marble_at_position(final_pos)
if opponent is not None and opponent[0] != player:
    opp_player, opp_marble_idx = opponent
    opp_old_pos = game.send_marble_home(opp_player, opp_marble_idx)

After

# Single source of truth in game engine
move_result = game.execute_move(player, marble_idx, moves)
if move_result['aggravated_opponent']:
    agg_info = move_result['aggravated_info']
    # Use result to drive animation only

This establishes execute_move() as the single source of truth for game rules, ensuring GUI and headless simulation remain in sync.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 6, 2026 05:28
Co-authored-by: durangogt <10979447+durangogt@users.noreply.github.com>
Co-authored-by: durangogt <10979447+durangogt@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor animatePlayerMoveGeneric to use game.execute_move Refactor animatePlayerMoveGeneric to delegate logic to game.execute_move() Feb 6, 2026
Copilot AI requested a review from durangogt February 6, 2026 05:35
@durangogt
durangogt marked this pull request as ready for review February 6, 2026 05:37
durangogt added a commit that referenced this pull request Feb 7, 2026
Feature/aggravation mechanics - all fixed except for the details in this pull - #54

so hopefully we can fix this after this merge once we see how it works w/ the web version
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