Skip to content

Commit

Permalink
Merge #225
Browse files Browse the repository at this point in the history
225: Make seat number optional in Players constructor r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski committed Aug 29, 2023
2 parents bc0b10d + 920acdf commit 4ab6a39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
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.4.1"
version = "0.4.2"

[deps]
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down
2 changes: 1 addition & 1 deletion src/player_type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Base.show(io::IO, player::Player)
print(io, "$(name(player)): $(player.cards)")
end

function Player(strategy, seat_number, cards = nothing; bank_roll = 200)
function Player(strategy, seat_number = -1, cards = nothing; bank_roll = 200)
action_required = true
all_in = false
round_bank_roll = bank_roll
Expand Down
7 changes: 7 additions & 0 deletions src/players.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ coincide.
struct Players{PS<:Union{Tuple,AbstractArray}}
players::PS
function Players(players)
n = length(players)
if all(x->seat_number(x)==-1, players)
for i in 1:n
players[i].seat_number = i
end
end
@assert allunique(map(x->seat_number(x), players))
spbsn = sortperm_by_seat_number(players)
splayers = map(sp->players[sp], spbsn)
@assert issorted(map(x->seat_number(x), splayers))
@assert seat_number(splayers[n]) n
return new{typeof(splayers)}(splayers)
end
end
Expand Down

2 comments on commit 4ab6a39

@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/90411

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.4.2 -m "<description of version>" 4ab6a3961eb0ca95b325cee4fb4bf62def7ebf6f
git push origin v0.4.2

Please sign in to comment.