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
|
# frozen_string_literal: true
class Sector
attr_reader :name
attr_writer :data
def initialize(data = { name: 'sector', pop: 0, fln_bases: 0, fln_active: 0, fln_underground: 0, gov_cubes: 0, independent: true, support: false, terror: 0 })
@name = data[:name] || 'sector'
@data = data
end
def sector?
@name == 'sector'
end
def city?
@name == 'city'
end
def country?
@name == 'country'
end
def max_bases
3
end
def independent?
@data[:independent]
end
def support?
@data[:support] || false
end
def oppose?
@data[:oppose] || false
end
def neutral?
@data[:neutral] || false
end
def terror
@data[:terror] || 0
end
def terror?
terror.positive?
end
def pop
@data[:pop] || 0
end
def guerrillas
fln_active + fln_underground
end
def fln_bases
@data[:fln_bases] || 0
end
def fln_active
@data[:fln_active] || 0
end
def fln_underground
@data[:fln_underground] || 0
end
def fln
fln_active + fln_underground + fln_bases
end
def gov_cubes
@data[:gov_cubes] || (french_cubes + algerian_cubes)
end
def gov_bases
@data[:gov_bases] || 0
end
def gov
gov_cubes + gov_bases
end
def troops
@data[:troops] || (french_troops + algerian_troops)
end
def police
@data[:police] || (french_police + algerian_police)
end
def french_cubes
french_police + french_troops
end
def french_police
@data[:french_police] || 0
end
def french_troops
@data[:french_troops] || 0
end
def algerian_cubes
algerian_police + algerian_troops
end
def algerian_police
@data[:algerian_police] || 0
end
def algerian_troops
@data[:algerian_troops] || 0
end
def fln_control?
fln > gov
end
def gov_control?
gov > fln
end
end
class Board
attr_reader :sector, :spaces
attr_accessor :fln_resources, :available_fln_underground, :available_fln_bases, :france_track
def initialize
@fln_resources = 0
@france_track = 0
@available_fln_bases = 1
@available_fln_underground = 0
@sector = Sector.new
@spaces = []
end
def apply(action, keep)
@fln_resources -= action.cost
spaces.delete(action.space) unless keep
end
def has(&block)
block.call(@sector)
end
def search(&block)
@spaces.select(&block)
end
def count(&block)
block.call(@sector)
end
end
class Options
def debug
@debug || 0
end
end
class Game
attr_reader :action, :actions, :current_card
attr_accessor :board, :options, :keep
def initialize
@actions = []
@board = Board.new
@options = Options.new
@keep = false
end
def set(hash)
@board.spaces << Sector.new(hash)
end
def d6
3
end
def apply(_faction, action)
if @options.debug.positive?
puts '** _apply'
puts action.inspect
end
@action = action
@actions << action
@board.apply(action, @keep)
true
end
end
|