feat: add status bar with each player's card count

dev
LeRoyce Pearson 2024-02-19 23:48:41 -07:00
parent 41ede6d1cb
commit 99ba7fad7a
1 changed files with 22 additions and 0 deletions

View File

@ -217,6 +217,8 @@ function handler_start_of_turn(action)
textx=60, texty=40, textx=60, texty=40,
}) })
build_player_status_bar(elements, players_hands)
local space_around=((240-24)/(2)) local space_around=((240-24)/(2))
local x=space_around local x=space_around
table.insert(elements, { table.insert(elements, {
@ -356,6 +358,22 @@ function build_hand_ui(elements, hand, draft, can_select)
end end
end end
function build_player_status_bar(elements, hands)
local y=80
for i,hand in ipairs(hands) do
local x=10
table.insert(elements, {
visual="#"..i,
x=x, y=y
})
table.insert(elements, {
visual=#hand,
x=x+20, y=y
})
y=y+8
end
end
function handler_draw_card(action) function handler_draw_card(action)
local cards_in_hand=players_hands[current_player] local cards_in_hand=players_hands[current_player]
@ -373,6 +391,7 @@ function handler_draw_card(action)
local elements={} local elements={}
build_player_status_bar(elements, players_hands)
build_meld_ui(elements, cards_in_meld_draft, false) build_meld_ui(elements, cards_in_meld_draft, false)
build_draw_discard_ui(elements, { is_drawing=true }) build_draw_discard_ui(elements, { is_drawing=true })
build_hand_ui(elements, cards_in_hand, cards_in_meld_draft, false) build_hand_ui(elements, cards_in_hand, cards_in_meld_draft, false)
@ -423,6 +442,7 @@ function handler_player_action(action)
local elements={} local elements={}
build_player_status_bar(elements, players_hands)
build_meld_ui(elements, cards_in_meld_draft, true) build_meld_ui(elements, cards_in_meld_draft, true)
build_draw_discard_ui(elements, { build_draw_discard_ui(elements, {
discard_action=(#cards_in_meld_draft==1 and "Discard" or nil), discard_action=(#cards_in_meld_draft==1 and "Discard" or nil),
@ -465,6 +485,7 @@ function handler_player_secondary_action(action)
local elements={} local elements={}
build_player_status_bar(elements, players_hands)
build_meld_ui(elements, cards_in_meld_draft, false) build_meld_ui(elements, cards_in_meld_draft, false)
build_draw_discard_ui(elements, { build_draw_discard_ui(elements, {
discard_action=(#cards_in_meld_draft==1 and "Discard" or nil), discard_action=(#cards_in_meld_draft==1 and "Discard" or nil),
@ -485,6 +506,7 @@ function handler_discard_confirm(action)
local elements={} local elements={}
build_player_status_bar(elements, players_hands)
build_meld_ui(elements, cards_in_meld_draft, false) build_meld_ui(elements, cards_in_meld_draft, false)
build_draw_discard_ui(elements, { build_draw_discard_ui(elements, {
end_turn_action="End\nTurn", end_turn_action="End\nTurn",