summaryrefslogtreecommitdiffstats
path: root/spec/mock_board.rb
blob: e75ba73b8288d09928ee330c797eafbdf3047b96 (plain)
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
# 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]
  end

  def terror
    @data[:terror]
  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 gov_cubes
    @data[:gov_cubes] || 0
  end
end

class Board
  attr_reader :sector
  attr_accessor :fln_resources, :available_fln_bases

  def initialize
    @fln_resources = 0
    @available_fln_bases = 1
    @sector = Sector.new
  end

  def has(&block)
    block.call(@sector)
  end

  def count(&block)
    block.call(@sector)
  end
end