summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2023-11-08 22:14:00 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2023-11-08 22:14:00 +0100
commit44e9358965f31a6453fcb1cbaca6bcbb4756ba16 (patch)
treef8f786342936f5fb2d2824f791343777405c7f27
parent23781f394d16c84d761a1b9fa3ad1e65576a2a82 (diff)
downloadcolonial-twilight-44e9358965f31a6453fcb1cbaca6bcbb4756ba16.zip
colonial-twilight-44e9358965f31a6453fcb1cbaca6bcbb4756ba16.tar.gz
Spaces: fix #shift_terror
-rw-r--r--lib/colonial_twilight/spaces.rb4
-rw-r--r--spec/spaces_spec.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/colonial_twilight/spaces.rb b/lib/colonial_twilight/spaces.rb
index 909e9db..6eaf3c7 100644
--- a/lib/colonial_twilight/spaces.rb
+++ b/lib/colonial_twilight/spaces.rb
@@ -147,9 +147,9 @@ module ColonialTwilight
end
def shift_terror(num = 1)
- @terror += num
+ raise "terror cant be negative" if @terror.zero? and num.negative?
- raise "terror cant be negative" if @terror.negative?
+ @terror += num
end
def resettled?
diff --git a/spec/spaces_spec.rb b/spec/spaces_spec.rb
index 0c7e6bc..d7af8e5 100644
--- a/spec/spaces_spec.rb
+++ b/spec/spaces_spec.rb
@@ -80,7 +80,7 @@ describe ColonialTwilight::Sector do
it 'terror' do
expect(@s.terror?).to be false
expect(@s.terror).to eq 0
- @s.shift_terror 2
+ expect(@s.shift_terror(2)).to eq 2
expect(@s.terror?).to be true
expect(@s.terror).to eq 2
expect { @t.shift_terrort(-3) }.to raise_error(Exception)