Skip to content

Implemented split and added comprehensive test#204

Merged
Birdmannn merged 8 commits intoPrometheus-A:v1from
truthixify:fix-95
Oct 9, 2025
Merged

Implemented split and added comprehensive test#204
Birdmannn merged 8 commits intoPrometheus-A:v1from
truthixify:fix-95

Conversation

@truthixify
Copy link
Contributor

Implemented split and added comprehensive test

Related issues

Closes #95

Changes Made

  • Core Pot Splitting Logic: Added _split_pots_with_kickers_internal() function handling all scenarios
  • Multi-Pot Support: Main pot and side pots with different player eligibilities
  • Kicker Integration: Works with existing compare_hands() for tie-breaking
  • Casino Cut: 20% collection from non-winning players
  • Casino Funds Model: CasinoFunds model tracks house collections
  • Events: PotSplit and CasinoCollection events for transparency
  • Integration: Auto-executes during round resolution
  • Comprehensive Tests: 8+ test scenarios covering all cases
  • Documentation: Complete documentation in POT_SPLITTING_DOCUMENTATION.md

How to Test

# Run all tests (106 passing, 0 failing)
sozo test

# Run pot splitting tests only (8 passing)
sozo test -f test_pot_splitting

# Test specific scenario
sozo test -f test_single_winner_takes_all

Screenshots (if applicable)

Checklist

  • My code follows the project's coding style.
  • I have tested these changes locally.
  • Documentation has been updated where necessary.

Copy link
Collaborator

@Birdmannn Birdmannn left a comment

Choose a reason for hiding this comment

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

Nice job @truthixify 🫡🎉🔥💯. I'll take this PR adjustments from here. You've done very well

break;
}
};
assert(found, 'Winner not in game');
Copy link
Collaborator

Choose a reason for hiding this comment

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

let mut player: Player = world.read_model(player_addr);

let mut share = share_per_player;
// Give remainder to first player
Copy link
Collaborator

Choose a reason for hiding this comment

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

Catch ✅ Nice job on the remainder

}

/// Split pot evenly among multiple winners
fn _split_pot_among_winners(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function and _split_pot_among_eligible are identical. So it's only normal that one must go. Then it's to put in the last argument to the function appropriately.


let mut winner: Player = world.read_model(*winner_addr);
winner.chips += pot_amount;
world.write_model(@winner);
Copy link
Collaborator

Choose a reason for hiding this comment

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

just updating the chips field of the Player can be done with

let winner_chips = world.read_member(Model::<Player>::ptr_from_keys(winner_adr), selector!("chips")); 
world.write_member(Model::<Player>::ptr_from_keys(winner_adr), selector!("chips"), winner_chips + pot_amount);

Comment on lines +1791 to +1803
fn _update_player_chips_and_emit(
ref self: ContractState,
player_addr: ContractAddress,
amount: u256,
game_id: u64,
pot_index: u32,
total_pot: u256,
) {
let mut _world = self.world_default();
let mut player: Player = _world.read_model(player_addr);
player.chips += amount;
_world.write_model(@player);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

game_id, pot_index, and total_pot are never used.
That said, I could swear I saw this logic standalone somewhere else in another function... 🙂

@Birdmannn Birdmannn merged commit 333f486 into Prometheus-A:v1 Oct 9, 2025
1 check passed
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.

[Feat][Chief Surgeon] Implement split

2 participants