From 420487be4001873a7168db25fc6a52f4fe6fabcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Dec 2023 11:40:14 +0100 Subject: FLNBotRules : fix rally_9_priority with infinite resources --- lib/colonial_twilight/fln_bot_rules.rb | 4 ++-- spec/fln_bot_rules_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb index 3f04ed5..463ea8c 100644 --- a/lib/colonial_twilight/fln_bot_rules.rb +++ b/lib/colonial_twilight/fln_bot_rules.rb @@ -151,8 +151,8 @@ module ColonialTwilight end def rally_9_priority(spaces, resources) - f = _filter(spaces) { |s| s.support? && resources > s.terror } - _filter(f) { |s| s.neutral? && resources > s.terror } + f = _filter(spaces) { |s| s.support? && (resources.zero? || resources > s.terror) } + _filter(f) { |s| s.neutral? && (resources.zero? || resources > s.terror) } end # Extort diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb index 2fe0216..2d46f0b 100644 --- a/spec/fln_bot_rules_spec.rb +++ b/spec/fln_bot_rules_spec.rb @@ -463,6 +463,13 @@ describe ColonialTwilight::FLNBotRules do c = Sector.new(terror: 2, neutral: true) expect(@rules.rally_9_priority([a, b, c], 3)[0]).to be c end + + it 'rally_9_priority infinite resources' do + a = Sector.new(terror: 1, oppose: true) + b = Sector.new(terror: 3, support: true) + c = Sector.new(terror: 2, support: true) + expect(@rules.rally_9_priority([a, b, c], 0).size).to be 2 + end end describe 'Extort' do -- cgit v1.1-2-g2b99