Class: Player_manager
- Inherits:
-
Object
- Object
- Player_manager
- Defined in:
- lib/player_manager.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#second ⇒ Object
readonly
Returns the value of attribute second.
Instance Method Summary collapse
- #get_player(mark) ⇒ Object
-
#initialize(first, ai_one, second, ai_two) ⇒ Player_manager
constructor
A new instance of Player_manager.
- #other_mark(mark) ⇒ Object
Constructor Details
#initialize(first, ai_one, second, ai_two) ⇒ Player_manager
Returns a new instance of Player_manager.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/player_manager.rb', line 6 def initialize(first, ai_one, second, ai_two) @first = first @second = second @players = {} if ai_one == true @players[@first] = Ai.new(@first, self) else @players[@first] = "human" end if ai_two == true @players[@second] = Ai.new(@second, self) else @players[@second] = "human" end end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
4 5 6 |
# File 'lib/player_manager.rb', line 4 def first @first end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
4 5 6 |
# File 'lib/player_manager.rb', line 4 def second @second end |
Instance Method Details
#get_player(mark) ⇒ Object
32 33 34 |
# File 'lib/player_manager.rb', line 32 def get_player(mark) @players[mark] end |
#other_mark(mark) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/player_manager.rb', line 24 def other_mark(mark) if mark == @first @second else @first end end |