Skip to content

Commit

Permalink
Merge #191
Browse files Browse the repository at this point in the history
191: Broadcast reward r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski authored Jul 31, 2023
2 parents 392d5de + 23ebe51 commit c23c0ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TexasHoldem"
uuid = "6cef90fc-eb55-4a2a-97d0-7ecce2b738fe"
authors = ["Charles Kawczynski <kawczynski.charles@gmail.com>"]
version = "0.1.0"
version = "0.2.0"

[deps]
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down
4 changes: 4 additions & 0 deletions src/game.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ function _deal_and_play!(game::Game)

@cinfo logger "Final bank roll summary: $(bank_roll.(players))"
@assert winners.declared
for player in players
notify_reward(player)
end

@cinfo logger "------ Finished game!"
return winners
Expand Down Expand Up @@ -286,6 +289,7 @@ function reset_game!(game::Game)
for player in players
player.cards = nothing
player.pot_investment = 0
player.game_profit = 0
player.all_in = false
player.round_bank_roll = bank_roll(player)
player.checked = false
Expand Down
4 changes: 4 additions & 0 deletions src/player_type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mutable struct Player{S #=<: AbstractStrategy=#}
seat_number::Int
cards::Union{Nothing,Tuple{<:Card,<:Card}}
bank_roll::Int
game_profit::Int
action_required::Bool
all_in::Bool
round_bank_roll::Int # bank roll at the beginning of the round
Expand All @@ -75,6 +76,7 @@ function Player(strategy, seat_number, cards = nothing; bank_roll = 200)
round_bank_roll = bank_roll
folded = false
pot_investment = 0
game_profit = 0
checked = false
active = true
round_contribution = 0
Expand All @@ -85,6 +87,7 @@ function Player(strategy, seat_number, cards = nothing; bank_roll = 200)
seat_number,
cards,
bank_roll,
game_profit,
action_required,
all_in,
round_bank_roll,
Expand Down Expand Up @@ -118,3 +121,4 @@ pot_investment(player::Player) = player.pot_investment
round_contribution(player::Player) = player.round_contribution
strategy(player::Player) = player.strategy

notify_reward(player) = nothing
2 changes: 2 additions & 0 deletions src/transactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ function distribute_winnings_1_player_left!(players, tm::TransactionManager, tab
amt_contributed = initial_br - bank_roll(player)
∑spw = sidepot_winnings(tm, n)
prof = ∑spw-amt_contributed
player.game_profit = prof
player.bank_roll += ∑spw
if !(∑spw == 0 && player.bank_roll == 0 && amt_contributed == 0)
@cinfo logger "$(name(player)) wins $(∑spw) ($(prof) profit) (all opponents folded)"
Expand Down Expand Up @@ -388,6 +389,7 @@ function distribute_winnings!(players, tm::TransactionManager, table_cards, logg
bc = she.best_cards
"$(name(player)) wins $∑spw ($prof profit) with $bc ($hand_name)!"
end
player.game_profit = prof
player.bank_roll += ∑spw
end
end
Expand Down

2 comments on commit c23c0ac

@charleskawczynski
Copy link
Owner

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/88705

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" c23c0aceedb9c0e61b6119b8dc8a9b055570ef63
git push origin v0.2.0

Please sign in to comment.