Class: ProconBypassMan::Procon::UserOperation
- Inherits:
-
Object
- Object
- ProconBypassMan::Procon::UserOperation
- Defined in:
- lib/procon_bypass_man/procon/user_operation.rb
Overview
ボタンを押しているか判断するクラス。バイナリの書き換えはしない
Constant Summary collapse
- ASCII_ENCODING =
"ASCII-8BIT"
Instance Attribute Summary collapse
-
#binary ⇒ Object
readonly
Returns the value of attribute binary.
Instance Method Summary collapse
- #apply_left_analog_stick_cap(cap:) ⇒ Object
-
#initialize(binary) ⇒ UserOperation
constructor
A new instance of UserOperation.
- #is_button?(button) ⇒ Boolean
- #is_stick?(step) ⇒ Boolean
- #merge(target_binary) ⇒ void
- #press_button(button) ⇒ Object
- #press_button_only_or_tilt_sticks(macro_step) ⇒ Object
- #pressing_all_buttons?(buttons) ⇒ Boolean
- #pressing_button?(button) ⇒ Boolean
- #set_no_action! ⇒ Object
- #unpress_button(button) ⇒ Object
Constructor Details
#initialize(binary) ⇒ UserOperation
Returns a new instance of UserOperation.
10 11 12 13 14 15 16 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 10 def initialize(binary) unless binary.encoding.name == ASCII_ENCODING raise "おかしいです" end @binary = ProconBypassMan::Domains::ProcessingProconBinary.new(binary: binary) end |
Instance Attribute Details
#binary ⇒ Object (readonly)
Returns the value of attribute binary.
5 6 7 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 5 def binary @binary end |
Instance Method Details
#apply_left_analog_stick_cap(cap:) ⇒ Object
22 23 24 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 22 def apply_left_analog_stick_cap(cap: ) binary.write_as_apply_left_analog_stick_cap(cap: cap) end |
#is_button?(button) ⇒ Boolean
78 79 80 81 82 83 84 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 78 def () = [] if not .is_a?(Array) .all? do |b| !!ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[b.to_sym] || b.to_sym == ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE end end |
#is_stick?(step) ⇒ Boolean
87 88 89 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 87 def is_stick?(step) !!(step =~ /\Atilt_/) end |
#merge(target_binary) ⇒ void
This method returns an undefined value.
58 59 60 61 62 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 58 def merge(target_binary) binary.write_as_merge!( ProconBypassMan::Domains::ProcessingProconBinary.new(binary: target_binary) ) end |
#press_button(button) ⇒ Object
33 34 35 36 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 33 def () return if () binary.() end |
#press_button_only_or_tilt_sticks(macro_step) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 39 def (macro_step) macro_step = [macro_step] if not macro_step.is_a?(Array) # スティック操作を含む時はボタン入力を通す binary.set_no_action! if (macro_step) macro_step.uniq.each do |ms| next if ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == ms if (ms) binary.(ms) elsif is_stick?(ms) binary.write_as_tilt_left_stick(ms) else warn "知らないmacro stepです" end end end |
#pressing_all_buttons?(buttons) ⇒ Boolean
72 73 74 75 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 72 def () aware = ProconBypassMan::PressButtonAware.new(@binary.raw) .all? { |b| aware.(b) } end |
#pressing_button?(button) ⇒ Boolean
66 67 68 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 66 def () ([]) end |
#set_no_action! ⇒ Object
18 19 20 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 18 def set_no_action! binary.set_no_action! end |
#unpress_button(button) ⇒ Object
27 28 29 30 |
# File 'lib/procon_bypass_man/procon/user_operation.rb', line 27 def () return if not () binary.() end |