From 1e21c64a1880e15a079e888af497dde13f28b51e Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Thu, 19 Jan 2023 12:33:51 -0600 Subject: [PATCH] Fixed using File.exists? instead of File.exist?, updated Randomizer to PowerPlay (with ducks), misc. tweaking. --- lib/backend.rb | 6 +++--- lib/game_clock/randomizer.rb | 12 ++++++++++-- lib/pages/simulator.rb | 2 +- lib/window.rb | 6 +----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/backend.rb b/lib/backend.rb index 86cab13..381e96c 100644 --- a/lib/backend.rb +++ b/lib/backend.rb @@ -42,13 +42,13 @@ module TAC end def move_config(old_name, new_name) - if not File.exists?("#{TAC::CONFIGS_PATH}/#{old_name}.json") or + if not File.exist?("#{TAC::CONFIGS_PATH}/#{old_name}.json") or File.directory?("#{TAC::CONFIGS_PATH}/#{old_name}.json") # move_config: Can not move config file "#{old_name}" does not exist! return false end - if File.exists?("#{TAC::CONFIGS_PATH}/#{new_name}.json") && + if File.exist?("#{TAC::CONFIGS_PATH}/#{new_name}.json") && !File.directory?("#{TAC::CONFIGS_PATH}/#{old_name}.json") # move_config: Config file "#{new_name}" already exist! return false @@ -61,7 +61,7 @@ module TAC end def delete_config(config_name) - FileUtils.rm("#{TAC::CONFIGS_PATH}/#{config_name}.json") if File.exists?("#{TAC::CONFIGS_PATH}/#{config_name}.json") + FileUtils.rm("#{TAC::CONFIGS_PATH}/#{config_name}.json") if File.exist?("#{TAC::CONFIGS_PATH}/#{config_name}.json") end diff --git a/lib/game_clock/randomizer.rb b/lib/game_clock/randomizer.rb index b1173d8..254378e 100644 --- a/lib/game_clock/randomizer.rb +++ b/lib/game_clock/randomizer.rb @@ -23,14 +23,22 @@ module TAC when 2, 5 #Blue and Red: Center - @ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 512, die_size: @size) - @ducks << Ducky.new(window: window, alliance: :red, slot: 2, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size) + + @ducks << Ducky.new(window: window, alliance: :red, slot: 3, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 512, die_size: @size) when 3, 6 # Blue: Left # Red: Right @ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :red, slot: 3, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :red, slot: 2, speed: 512, die_size: @size) + @ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 512, die_size: @size) end end diff --git a/lib/pages/simulator.rb b/lib/pages/simulator.rb index 9e167fe..71105ba 100644 --- a/lib/pages/simulator.rb +++ b/lib/pages/simulator.rb @@ -49,7 +49,7 @@ robot.forward 100 robot.turn -90 robot.forward 100" - source_code = File.read(SOURCE_FILE_PATH) if File.exists?(SOURCE_FILE_PATH) + source_code = File.read(SOURCE_FILE_PATH) if File.exist?(SOURCE_FILE_PATH) @source_code = edit_box source_code, width: 1.0, height: 1.0 end diff --git a/lib/window.rb b/lib/window.rb index cba393f..ca704a1 100644 --- a/lib/window.rb +++ b/lib/window.rb @@ -32,11 +32,7 @@ module TAC end def needs_redraw? - if current_state.is_a?(Editor) - current_state.needs_repaint? || @notification_manager.instance_variable_get(:@drivers).size.positive? - else - true - end + states.any?(&:needs_repaint?) || @notification_manager.instance_variable_get(:@drivers).size.positive? end def toast(title, message = nil)