Class: GameMachine::DefaultHandlers::TeamHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/game_machine/default_handlers/team_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTeamHandler

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

#teamsObject (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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Returns:

  • (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_teamsObject



11
12
13
# File 'lib/game_machine/default_handlers/team_handler.rb', line 11

def update_teams
  @teams = GameMachine::Models::Teams.find('teams')
end