1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# frozen_string_literal: true
require './lib/colonial_twilight/turn'
require './spec/mock_board'
describe ColonialTwilight::Turn do
before do
@turn = ColonialTwilight::Turn.new
@a = Sector.new
@b = Sector.new
end
describe 'Validation' do
it 'validate operation' do
expect { @turn.operation_in(:rall, @a, 0) }.to raise_error(Exception)
end
it 'validate special activity' do
expect { @turn.special_activity_in(:bush, @a, 0) }.to raise_error(Exception)
end
it '1 operation only' do
@turn.operation_in(:march, @a, 0)
expect { @turn.operation_in(:rally, @b, 0) }.to raise_error(Exception)
end
it '1 special activity only' do
@turn.special_activity_in(:extort, @a, 0)
expect { @turn.special_activity_in(:ambush, @b, 0) }.to raise_error(Exception)
end
it 'only 1 operation in limited operation' do
@turn.reset(true)
@turn.operation_in(:rally, @a, 0)
expect { @turn.operation_in(:rally, @a, 0) }.to raise_error(Exception)
end
it 'no special activity in limited operation' do
@turn.reset(true)
expect { @turn.special_activity_in(:ambush, @a, 0) }.to raise_error(Exception)
end
it 'select a sector once for the operation' do
@turn.operation_in(:rally, @a, 0)
expect { @turn.operation_in(:rally, @a, 0) }.to raise_error(Exception)
end
it 'select a sector once for the special activity' do
@turn.special_activity_in(:ambush, @a, 0)
expect { @turn.special_activity_in(:ambush, @a, 0) }.to raise_error(Exception)
end
it 'agitate in an unselected space' do
expect { @turn.agitate_n(@a, 0, 0, false) }.to raise_error(Exception)
end
end
describe 'interrogations' do
it 'operation done' do
expect(@turn.operation_done?).to be false
@turn.operation_in(:rally, @b, 2)
expect(@turn.operation_done?).to be true
end
it 'activity done' do
expect(@turn.special_activity_done?).to be false
@turn.special_activity_in(:ambush, @a, 3)
expect(@turn.special_activity_done?).to be true
end
it 'activity done' do
expect(@turn.may_special_activity?(:ambush)).to be true
@turn.special_activity_in(:extort, @b, 4).extort
expect(@turn.may_special_activity?(:extort)).to be true
expect(@turn.may_special_activity?(:ambush)).to be false
end
it 'operation cost' do
a = @turn.operation_in(:rally, @a, 1)
@turn.operation_in(:rally, @b, 2)
b = @turn.special_activity_in(:ambush, @a, 3)
@turn.special_activity_in(:ambush, @b, 4)
expect(@turn.operation_cost).to be 3
expect(a.name == 'Rally').to be true
expect(b.name == 'Ambush').to be true
end
it 'activity cost' do
@turn.operation_in(:rally, @a, 1)
@turn.operation_in(:rally, @b, 2)
@turn.special_activity_in(:ambush, @a, 3)
@turn.special_activity_in(:ambush, @b, 4)
expect(@turn.special_activity_cost).to be 7
end
it 'cost' do
@turn.operation_in(:rally, @a, 1)
@turn.operation_in(:rally, @b, 2)
@turn.special_activity_in(:ambush, @a, 3)
@turn.special_activity_in(:ambush, @b, 4)
expect(@turn.cost).to be 10
end
it 'selected spaces' do
@turn.operation_in(:rally, @a, 1)
@turn.operation_in(:rally, @b, 2)
@turn.special_activity_in(:ambush, @a, 3)
expect(@turn.selected_spaces).to be 2
end
it 'inspect' do
@turn.operation_in(:rally, @a, 1)
@turn.operation_in(:rally, @b, 2)
@turn.special_activity_in(:ambush, @a, 3)
expect(@turn.inspect.instance_of?(String)).to be true
end
end
describe 'Operations' do
it 'Pass' do
@turn.pass(1)
expect(@turn.cost).to eq(-1)
expect(@turn.actions.size).to eq 1
expect(@turn.actions[0].steps.size).to eq 1
expect(@turn.actions[0].steps[0][:kind]).to be :pass
end
it 'activate' do
@turn.special_activity_in(:ambush, @space, 1).activate(1)
expect(@turn.cost).to eq(1)
expect(@turn.actions[0].steps.size).to eq 1
expect(@turn.actions[0].steps[0][:kind]).to be :activate
end
it 'transfer' do
h = { @a => 2, @b => 3 }
@turn.operation_in(:rally, @space, 1)
.transfer_to(:available, :fln_active, 1)
.transfer_from(:available, :fln_bases)
.transfer_steps(h)
expect(@turn.cost).to eq(1)
expect(@turn.actions.size).to eq 1
expect(@turn.actions[0].steps.size).to eq 4
expect(@turn.actions[0].steps[0][:kind]).to be :transfer
expect(@turn.actions[0].steps[1][:kind]).to be :transfer
expect(@turn.actions[0].steps[2][:kind]).to be :transfer
expect(@turn.actions[0].steps[3][:kind]).to be :transfer
end
it 'shift' do
@turn.operation_in(:rally, @space, 1)
.shift(3)
expect(@turn.cost).to eq(1)
expect(@turn.actions.size).to eq 1
expect(@turn.actions[0].steps.size).to eq 1
expect(@turn.actions[0].steps[0][:kind]).to be :shift
end
it 'extort' do
@turn.operation_in(:rally, @space, -1)
.extort
expect(@turn.cost).to eq(-1)
expect(@turn.actions.size).to eq 1
expect(@turn.actions[0].steps.size).to eq 1
expect(@turn.actions[0].steps[0][:kind]).to be :extort
end
it 'terror' do
@turn.operation_in(:terror, @space, 1)
.terror
expect(@turn.cost).to eq(1)
expect(@turn.actions.size).to eq 1
expect(@turn.actions[0].steps.size).to eq 2
expect(@turn.actions[0].steps[0][:kind]).to be :set
expect(@turn.actions[0].steps[0][:kind]).to be :set
end
it 'agitate raise if not :rally' do
@turn.pass(1)
expect { @turn.agitate_in(@a, 1, 0) }.to raise_error(Exception)
end
it 'agitate' do
@turn.operation_in(:rally, @space, 1)
@turn.agitate_in(@space, 2, 1)
expect(@turn.cost).to eq 4
expect(@turn.actions.size).to eq 2
expect(@turn.actions[1].steps.size).to eq 1
expect(@turn.actions[1].steps[0][:kind]).to be :agitate
expect(@turn.actions[1].steps[0][:terror]).to eq 2
expect(@turn.actions[1].steps[0][:shift]).to eq 1
end
it 'sanitize!' do
act = @turn.special_activity_in(:subvert, @a, 0)
.transfer_to(:available, :algerian_police, 1)
.transfer_from(:available, :fln_underground, 1)
act.steps[0].merge!(:src_control=>:uncontrolled)
act.steps[1].merge!(:dst_control=>:FLN)
act.sanitize!
expect(act.steps[0].key?(:src_control)).to be false
expect(act.steps[1][:dst_control]).to be :FLN
end
end
end
|