Class: Judge
- Inherits:
-
Object
- Object
- Judge
- Defined in:
- lib/ttt-cli/judge.rb
Overview
Класс Judge - судья (проверщик).
Constant Summary collapse
- WIN_COMBINATIONS =
[ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6] ].freeze
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
Instance Method Summary collapse
-
#initialize(game) ⇒ Judge
constructor
A new instance of Judge.
-
#is_combo?(player) ⇒ Boolean
основной метод для проверки на выигрыш возвращает true если обнаружена выигрышная комбинация.
Constructor Details
#initialize(game) ⇒ Judge
Returns a new instance of Judge.
13 14 15 |
# File 'lib/ttt-cli/judge.rb', line 13 def initialize(game) @board = game.board.cells end |
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
5 6 7 |
# File 'lib/ttt-cli/judge.rb', line 5 def board @board end |
Instance Method Details
#is_combo?(player) ⇒ Boolean
основной метод для проверки на выигрыш возвращает true если обнаружена выигрышная комбинация
19 20 21 |
# File 'lib/ttt-cli/judge.rb', line 19 def is_combo?(player) !winning_combination(player.token).nil? end |