Class: Berlin::AI::Game
- Inherits:
-
Object
- Object
- Berlin::AI::Game
- Includes:
- Internal
- Defined in:
- lib/ai/game.rb,
lib/ai/game_internal.rb
Overview
Game keeps track of current games played by the server, indexing them on their uniq id.
Defined Under Namespace
Modules: Internal
Instance Attribute Summary collapse
-
#current_turn ⇒ Object
Returns the value of attribute current_turn.
-
#id ⇒ Object
Returns the value of attribute id.
-
#map ⇒ Object
Returns the value of attribute map.
-
#maximum_number_of_turns ⇒ Object
Returns the value of attribute maximum_number_of_turns.
-
#moves ⇒ Object
Returns the value of attribute moves.
-
#number_of_players ⇒ Object
Returns the value of attribute number_of_players.
-
#player_id ⇒ Object
Returns the value of attribute player_id.
-
#time_limit_per_turn ⇒ Object
Returns the value of attribute time_limit_per_turn.
-
#turns_left ⇒ Object
Returns the value of attribute turns_left.
Instance Method Summary collapse
Methods included from Internal
Instance Attribute Details
#current_turn ⇒ Object
Returns the value of attribute current_turn.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def current_turn @current_turn end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def id @id end |
#map ⇒ Object
Returns the value of attribute map.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def map @map end |
#maximum_number_of_turns ⇒ Object
Returns the value of attribute maximum_number_of_turns.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def maximum_number_of_turns @maximum_number_of_turns end |
#moves ⇒ Object
Returns the value of attribute moves.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def moves @moves end |
#number_of_players ⇒ Object
Returns the value of attribute number_of_players.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def number_of_players @number_of_players end |
#player_id ⇒ Object
Returns the value of attribute player_id.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def player_id @player_id end |
#time_limit_per_turn ⇒ Object
Returns the value of attribute time_limit_per_turn.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def time_limit_per_turn @time_limit_per_turn end |
#turns_left ⇒ Object
Returns the value of attribute turns_left.
7 8 9 |
# File 'lib/ai/game.rb', line 7 def turns_left @turns_left end |
Instance Method Details
#add_move(from, to, number_of_soldiers) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ai/game.rb', line 10 def add_move(from, to, number_of_soldiers) # remove moving soldiers from from node from.available_soldiers -= number_of_soldiers # adding incoming soldiers to next node to.incoming_soldiers += number_of_soldiers # add move @moves << {:from => from.to_i, :to => to.to_i, :number_of_soldiers => number_of_soldiers.to_i} end |