Class: WebGame

Inherits:
Game
  • Object
show all
Defined in:
lib/ruby_ttt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#boardObject

Returns the value of attribute board.



100
101
102
# File 'lib/ruby_ttt.rb', line 100

def board
  @board
end

#player_first_moveObject

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_oneObject

Returns the value of attribute player_one.



100
101
102
# File 'lib/ruby_ttt.rb', line 100

def player_one
  @player_one
end

#player_twoObject

Returns the value of attribute player_two.



100
101
102
# File 'lib/ruby_ttt.rb', line 100

def player_two
  @player_two
end

#uiObject

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

Returns:

  • (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_messageObject



106
107
108
109
110
111
112
113
114
115
# File 'lib/ruby_ttt.rb', line 106

def get_message
  return ui.first_move_message(current_player.marker) if board.empty?
  if board.winner?(current_player.opponent.marker)
    ui.winning_game_message(current_player.opponent.marker)
  elsif !board.moves_remaining?
    ui.tie_game_message
  else
    ui.next_move_message(game.current_player.marker)
  end
end