Created
          June 16, 2011 18:08 
        
      - 
      
 - 
        
Save r-moeritz/1029843 to your computer and use it in GitHub Desktop.  
    game related functions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (defun game-from-name (name) | |
| (clsql:locally-enable-sql-reader-syntax) | |
| (car (clsql:select 'game | |
| :where [= [slot-value 'game 'name] name]))) | |
| (defun games () | |
| (sort (clsql:select 'game) #'> :key #'(lambda (g) (apply #'game-votes g)))) | |
| (defun add-game (name) | |
| (unless (game-stored? name) | |
| (let ((g (make-instance 'game :name name))) | |
| (clsql:update-record-from-slots g '(name votes))))) | |
| (defmethod vote-for (user-selected-game) | |
| (let ((g (car user-selected-game))) | |
| (incf (game-votes g)) | |
| (clsql:update-record-from-slots g '(votes)))) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment