summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/fln_bot_rules.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/colonial_twilight/fln_bot_rules.rb')
-rw-r--r--lib/colonial_twilight/fln_bot_rules.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb
index 8173d10..f82cb39 100644
--- a/lib/colonial_twilight/fln_bot_rules.rb
+++ b/lib/colonial_twilight/fln_bot_rules.rb
@@ -192,15 +192,21 @@ module ColonialTwilight
# 8.1.2 - Procedure Guidelines
def _filter(spaces, &block)
+ return spaces if spaces.empty?
+
(f = spaces.select(&block)).empty? ? spaces : f
end
def _max(spaces, sym)
+ return spaces if spaces.empty?
+
v = spaces.max { |a, b| a.send(sym) <=> b.send(sym) }.send(sym)
spaces.select { |s| s.send(sym) == v }
end
def _min(spaces, sym)
+ return spaces if spaces.empty?
+
v = spaces.min { |a, b| a.send(sym) <=> b.send(sym) }.send(sym)
spaces.select { |s| s.send(sym) == v }
end