From 708d5a9db41ba3be767a39c2269c471096e8b0dd Mon Sep 17 00:00:00 2001 From: Magnus Kristiansen <37312691+magnusrk-ch@users.noreply.github.com> Date: Sat, 27 Nov 2021 22:00:35 +0100 Subject: [PATCH] Add "Auto pass" button in stock rounds. The button enables the auto pass in stock round program, same as the auto tab, but more accessible. Only displayed for the active player, only in stock around, and does not show up in hotseat games. --- assets/app/view/game/pass.rb | 5 ++++- assets/app/view/game/pass_auto_button.rb | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 assets/app/view/game/pass_auto_button.rb diff --git a/assets/app/view/game/pass.rb b/assets/app/view/game/pass.rb index 20e8759ec1..44334a87d8 100644 --- a/assets/app/view/game/pass.rb +++ b/assets/app/view/game/pass.rb @@ -11,7 +11,10 @@ class Pass < Snabberb::Component def render children = [] - children << h(PassButton, before_process_pass: @before_process_pass) if @actions.include?('pass') + if @actions.include?('pass') + children << h(PassButton, before_process_pass: @before_process_pass) + children << h(PassAutoButton) if @game.round.stock? && @game.active_players_id.index(@user['id']) + end h(:div, children.compact) end end diff --git a/assets/app/view/game/pass_auto_button.rb b/assets/app/view/game/pass_auto_button.rb new file mode 100644 index 0000000000..02ea1cbfe2 --- /dev/null +++ b/assets/app/view/game/pass_auto_button.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'view/game/actionable' + +module View + module Game + class PassAutoButton < Snabberb::Component + include Actionable + + def render + props = { + on: { + click: lambda do + process_action(Engine::Action::ProgramSharePass.new(@game.current_entity)) + end, + }, + } + + h(:button, props, 'Auto pass') + end + end + end +end