Class: GameMachine::DefaultHandlers::TeamHandler
- Inherits:
-
Object
- Object
- GameMachine::DefaultHandlers::TeamHandler
- Defined in:
- lib/game_machine/default_handlers/team_handler.rb
Instance Attribute Summary collapse
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
Instance Method Summary collapse
-
#can_add_member?(team_name, member) ⇒ Boolean
return true if member has rights to join team.
-
#can_create_team?(team_name, member) ⇒ Boolean
return true if member has rights to create team.
- #destroy_on_owner_leave? ⇒ Boolean
-
#initialize ⇒ TeamHandler
constructor
A new instance of TeamHandler.
-
#match!(team_name) ⇒ Object
Should return a Match object if a match is found, otherwise nil.
-
#match_started(match) ⇒ Object
Called when Game Machine has started the match.
-
#teams_filter(teams, teams_request) ⇒ Object
Filter you can apply to the teams list sent to clients You can add whatever extra fields you want to the TeamsRequest class on the client and they will show up here.
- #update_teams ⇒ Object
Constructor Details
#initialize ⇒ TeamHandler
Returns a new instance of TeamHandler.
7 8 9 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 7 def initialize update_teams end |
Instance Attribute Details
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
6 7 8 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 6 def teams @teams end |
Instance Method Details
#can_add_member?(team_name, member) ⇒ Boolean
return true if member has rights to join team
42 43 44 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 42 def can_add_member?(team_name,member) true end |
#can_create_team?(team_name, member) ⇒ Boolean
return true if member has rights to create team
37 38 39 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 37 def can_create_team?(team_name,member) true end |
#destroy_on_owner_leave? ⇒ Boolean
46 47 48 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 46 def destroy_on_owner_leave? true end |
#match!(team_name) ⇒ Object
Should return a Match object if a match is found, otherwise nil
16 17 18 19 20 21 22 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 16 def match!(team_name) GameMachine.logger.info "match! team_name:#{team_name} teams:#{teams}" if team = teams.teams.select {|team| team.name != team_name}.first return GameMachine::Models::StartMatch.new(:team_names => [team_name,team.name]) end nil end |
#match_started(match) ⇒ Object
Called when Game Machine has started the match
25 26 27 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 25 def match_started(match) end |
#teams_filter(teams, teams_request) ⇒ Object
Filter you can apply to the teams list sent to clients You can add whatever extra fields you want to the TeamsRequest class on the client and they will show up here.
32 33 34 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 32 def teams_filter(teams,teams_request) teams end |
#update_teams ⇒ Object
11 12 13 |
# File 'lib/game_machine/default_handlers/team_handler.rb', line 11 def update_teams @teams = GameMachine::Models::Teams.find('teams') end |