diff options
Diffstat (limited to 'model.lisp')
-rw-r--r-- | model.lisp | 75 |
1 files changed, 61 insertions, 14 deletions
@@ -1,31 +1,78 @@ ;;;; model.lisp +(in-package :arclade) + (defclass player () ((name :initarg :name :reader name) (games :accessor games))) -(defclass game () - ((name :initarg :name :reader name) +(defclass game (db:store-object) + ((name :initarg :name :reader name + :index-type idx:string-unique-index + :index-reader game-with-name + :index-values all-games) (rating :accessor rating) (playtime :accessor playtime) (icon-url :accessor icon-url) - (last-played :accessor last-played))) + (last-played :accessor last-played)) + (:metaclass db:persistent-class)) (defclass steam-game (game) - ((appid :initarg :appid :reader appid))) + ((appid :initarg :appid :reader appid + :index-type idx:unique-index + :index-initargs (:test #'equal) + :index-reader steam-game-with-appid)) + (:metaclass db:persistent-class)) (defmethod print-object ((object steam-game) stream) (format stream "#<STEAM GAME ~a>" (name object))) -(defclass feat () - ((game :initarg :game :reader game) - (player :initarg :player :reader player) - (date :accessor date - :initform (multiple-value-list (date-calc:today-and-now))) - (description :accessor description :initform ""))) - -(defclass achievement (feat) - ((name :initarg :name :reader name))) +(defclass feat (db:store-object) + ((game + :reader game + :initarg :game + :initform (error "Feats must belong to a GAME.") + :type game + :index-type idx:hash-index + :index-reader feats-for-game + :documentation "Game object to which this feat belongs.") + (name + :initarg :name + :reader name + :type string + :initform "" + :documentation "Optional name of the feat.") + (fulfillment + :initarg :fulfillment + :initform nil + :accessor fulfillment + :documentation "Ideally a date and time when the feat was fulfilled. +If nil, implies the feat is yet to be fulfilled.") + (description + :initarg :description + :accessor description + :initform "" + :type string + :documentation "Free text feat flattery.")) + (:metaclass db:persistent-class) + (:documentation "Base class for a notable event performed in GAME. +Example: + Castlevania - 2003-10-31 (guess) + Defeated Dracula and finished the game!")) (defclass score (feat) - ((points :initarg :points :accessor points))) + ((points :initarg :points :accessor points)) + (:metaclass db:persistent-class) + (:documentation "Feat subclass specific to score based games.")) + +(defclass steam-achievement (feat) + ((icongray :accessor icongray) + (icon :accessor icon) + (apiname :accessor apiname)) + (:metaclass db:persistent-class) + (:documentation "Feat with Steam specific slots.")) + +;;; "queries" + +(defun feats-fulfilled () + (remove-if-not #'fulfillment (db:store-objects-with-class 'feat))) |