Skip to content

Instantly share code, notes, and snippets.

@svs
Created October 14, 2012 10:16
Show Gist options
  • Save svs/3888175 to your computer and use it in GitHub Desktop.
Save svs/3888175 to your computer and use it in GitHub Desktop.
naive game controller
# POST /games/1/join_game {:id => <game_id>, :user_id => <player_id> }
def join_game
@game = Game.find(params[:id])
@game.players << User.find(:user_id)
...
end
# POST /games/1/leave_game {:id => <game_id>, :user_id => <player_id> }
def leave_game
@game = Game.find(params[:id])
@game.players -= User.find(:user_id)
...
end
# POST /games/1/make_move {:id => <game_id>, :move => {:user_id => <player_id>, :x => <x-coord>, :y => <y-coord>}}
def make_move
@game = Game.find(params[:id])
@game.add_move(params[:move])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment