Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: aabe397059
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (32 sloc) 0.735 kb
class Game
COLOURS = %w{ blue brown red yellow }
attr_accessor :players
def initialize
self.players = []
end
def create_player(uuid)
(players << Player.new(uuid, player_colour, spawn_point, self)).last
end
def delete_player(uuid)
players.delete_if{|player| player.uuid == uuid}
end
def player_colour
COLOURS[self.players.size] rescue COLOURS.first
end
def spawn_point
case players.size
when 0 then [0,0]
when 1 then [6,0]
when 2 then [0,6]
when 3 then [6,6]
end
end
def player_states
players.inject({}) do |sum, player|
sum.merge( {player.uuid => player.to_param } )
end
end
def full?
players.size == 4
end
end
Jump to Line
Something went wrong with that request. Please try again.