From fc89b01224150bd0e4e32e92494539e890dc90ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 21 Oct 2023 17:44:17 +0200 Subject: Forces : #update_control return true if changed --- lib/colonial_twilight/fln_rules.rb | 2 +- lib/colonial_twilight/forces.rb | 4 +++- spec/fln_rules_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/colonial_twilight/fln_rules.rb b/lib/colonial_twilight/fln_rules.rb index 5f8fd48..f260dea 100644 --- a/lib/colonial_twilight/fln_rules.rb +++ b/lib/colonial_twilight/fln_rules.rb @@ -20,7 +20,7 @@ module ColonialTwilight board.search(&method(:may_agitate_in?)) end - def max_fln_to_place_in(space) + def max_placable_flns(space) space.fln_bases.positive? ? space.fln_bases + space.pop - space.fln_cubes : 1 end diff --git a/lib/colonial_twilight/forces.rb b/lib/colonial_twilight/forces.rb index 2048a00..4991c89 100644 --- a/lib/colonial_twilight/forces.rb +++ b/lib/colonial_twilight/forces.rb @@ -130,8 +130,9 @@ module ColonialTwilight end def update_control - return if @control.nil? + return nil if @control.nil? + ctr = @control @control = ( case gov <=> fln when 0 then :uncontrolled @@ -139,6 +140,7 @@ module ColonialTwilight when -1 then :FLN end ) + @control != ctr end end end diff --git a/spec/fln_rules_spec.rb b/spec/fln_rules_spec.rb index 385972a..90fc708 100644 --- a/spec/fln_rules_spec.rb +++ b/spec/fln_rules_spec.rb @@ -28,14 +28,14 @@ describe ColonialTwilight::FLNRules do it 'may place 1 FLN cube' do @board.load :short space = @board.by_name('Mostaganem') - expect(rules.max_fln_to_place_in(space)).to eq(1) + expect(rules.max_placable_flns(space)).to eq(1) end it 'may place 2 FLN cube' do @board.load :short space = @board.by_name('Orleansville') space.add :fln_base - expect(rules.max_fln_to_place_in(space)).to eq(3) + expect(rules.max_placable_flns(space)).to eq(3) end end -- cgit v1.1-2-g2b99