Class: Game
- Inherits:
-
Object
- Object
- Game
- Defined in:
- lib/herostats/game.rb
Instance Attribute Summary collapse
-
#players ⇒ Object
An Hash of Player in the current game.
-
#teams ⇒ Object
An Hash of Team in the current game.
Instance Method Summary collapse
-
#add_player(player) ⇒ Object
Adds a player to the.
-
#blue_team ⇒ Object
Alias for team 1.
-
#initialize ⇒ Game
constructor
A new instance of Game.
-
#red_team ⇒ Object
Alias for team 2.
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
6 7 8 9 |
# File 'lib/herostats/game.rb', line 6 def initialize @players = {} @teams = {1 => Team.new, 2 => Team.new} end |
Instance Attribute Details
#players ⇒ Object
An Hash of Player in the current game
3 4 5 |
# File 'lib/herostats/game.rb', line 3 def players @players end |
#teams ⇒ Object
An Hash of Team in the current game
5 6 7 |
# File 'lib/herostats/game.rb', line 5 def teams @teams end |
Instance Method Details
#add_player(player) ⇒ Object
Adds a player to the
13 14 15 |
# File 'lib/herostats/game.rb', line 13 def add_player(player) @players[@players.count + 1] = player end |
#blue_team ⇒ Object
Alias for team 1
18 19 20 |
# File 'lib/herostats/game.rb', line 18 def blue_team teams[1] end |
#red_team ⇒ Object
Alias for team 2
22 23 24 |
# File 'lib/herostats/game.rb', line 22 def red_team teams[2] end |