diff --git a/rummy.lua b/rummy.lua index cf91845..7b5b304 100644 --- a/rummy.lua +++ b/rummy.lua @@ -31,7 +31,7 @@ function BOOT() discard_pile = draw_pile:draw_stack(1) - current_handler=handler_draw_card + current_handler=handler_main_menu melds_on_tabletop={} end @@ -46,8 +46,6 @@ function TIC() end while not current_page do - trace(current_handler) - trace(request) local response=current_handler(request) if response.redirect then current_handler=response.redirect @@ -146,6 +144,40 @@ function TIC() end end +function handler_main_menu(action) + local player_count_cards={ + Card:new(1, 1), + Card:new(2, 2), + Card:new(3, 3), + Card:new(4, 4), + } + + local elements={} + + table.insert(elements, { + visual="Rummy", + textx=100, texty=10, + }) + + table.insert(elements, { + visual="Select the number of players", + textx=60, texty=40, + }) + + local space_around=((240-(#player_count_cards*24))/(#player_count_cards+1)) + local x=space_around + for i,card in ipairs(player_count_cards) do + table.insert(elements, { + visual=card, + x=x, y=68, + action=card, + }) + x=x+24+space_around + end + + return { page=elements } +end + function get_actions_from_page(page) local actions={} for i,element in ipairs(page) do @@ -188,7 +220,6 @@ function build_meld_ui(elements, draft, new_meld_allowed) textx=meld_x, texty=meld_y+7, x=meld_x, y=meld_y, action=((new_meld_allowed and rummy_is_valid_meld(draft)) and "New\nMeld" or nil), - action_x=meld_x, action_y=meld_y, }) end