Class: ConnectN::HumanPlayer

Inherits:
Player
  • Object
show all
Defined in:
lib/connect_n/player/human_player/human_player.rb

Instance Attribute Summary collapse

Attributes inherited from Player

#disc, #name

Instance Method Summary collapse

Constructor Details

#initialize(name: 'Human', disc: '🔥', save_key: ':w') ⇒ HumanPlayer

Returns a new instance of HumanPlayer.



11
12
13
14
# File 'lib/connect_n/player/human_player/human_player.rb', line 11

def initialize(name: 'Human', disc: '🔥', save_key: ':w')
  @save_key = save_key
  super name: name, disc: disc
end

Instance Attribute Details

#save_keyObject

Returns the value of attribute save_key.



9
10
11
# File 'lib/connect_n/player/human_player/human_player.rb', line 9

def save_key
  @save_key
end

Instance Method Details

#pickObject



16
17
18
19
# File 'lib/connect_n/player/human_player/human_player.rb', line 16

def pick
  input = PROMPT.ask('Please enter a column number : ')
  input == save_key ? input : input.to_i - 1
end