Class: WebGame
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
-
#player_first_move ⇒ Object
Returns the value of attribute player_first_move.
-
#player_one ⇒ Object
Returns the value of attribute player_one.
-
#player_two ⇒ Object
Returns the value of attribute player_two.
-
#ui ⇒ Object
Returns the value of attribute ui.
Instance Method Summary collapse
- #computer_player?(type_one, type_two) ⇒ Boolean
- #get_message ⇒ Object
-
#initialize(settings) ⇒ WebGame
constructor
A new instance of WebGame.
Methods inherited from Game
#advance_game, #current_player, #game_status_check, #total_markers, #verify_move
Constructor Details
#initialize(settings) ⇒ WebGame
Returns a new instance of WebGame.
101 102 103 104 |
# File 'lib/ruby_ttt.rb', line 101 def initialize(settings) super @ui = WebUI.new end |
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
100 101 102 |
# File 'lib/ruby_ttt.rb', line 100 def board @board end |
#player_first_move ⇒ Object
Returns the value of attribute player_first_move.
100 101 102 |
# File 'lib/ruby_ttt.rb', line 100 def player_first_move @player_first_move end |
#player_one ⇒ Object
Returns the value of attribute player_one.
100 101 102 |
# File 'lib/ruby_ttt.rb', line 100 def player_one @player_one end |
#player_two ⇒ Object
Returns the value of attribute player_two.
100 101 102 |
# File 'lib/ruby_ttt.rb', line 100 def player_two @player_two end |
#ui ⇒ Object
Returns the value of attribute ui.
100 101 102 |
# File 'lib/ruby_ttt.rb', line 100 def ui @ui end |
Instance Method Details
#computer_player?(type_one, type_two) ⇒ Boolean
117 118 119 |
# File 'lib/ruby_ttt.rb', line 117 def computer_player?(type_one, type_two) ((type_one.downcase) == COMPUTER_PLAYER) || ((type_two.downcase) == COMPUTER_PLAYER) end |
#get_message ⇒ Object
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ruby_ttt.rb', line 106 def return ui.(current_player.marker) if board.empty? if board.winner?(current_player.opponent.marker) ui.(current_player.opponent.marker) elsif !board.moves_remaining? ui. else ui.(game.current_player.marker) end end |