#|

If you wanted to add an item, you would add to the end of the list
or the matching position in the list to the matching DEFPARAMETER
and DEFCLASS.

These are all extracted from cardinfo.php

|#

(in-package #:cl-deck-builder2.models.ygoprodeck.fields)

;; TODO Merge this with YGO-CARD-NAME? What is even going on
;; here. This could be mixed with any DAO/table with a NAME
;; column. That *feels* like it's a lot more general than I
;; realize....
(defclass variant ()
  ((name :col-type :text
         :initarg :name)) 
  (:metaclass registered-table-class))

(defmethod name-of ((obj variant))
    (slot-value obj 'name))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun create-variant (class variant)
  (or (mito:find-dao class :name variant)
      (mito:create-dao class :name variant)))

(defun create-variants (class &rest variants)
  (with-connection (db)
    (with-transaction
      (dolist (v variants)
        (create-variant class v)))))

(defmacro define-variant-list (name &rest lst)
  `(progn
     (defclass ,name (variant)
       ()
       (:metaclass registered-table-class))
     (create-table ',name)
     (create-variants (find-class ',name) ,@lst)))

;; Card Conditions
(define-variant-list variant-condition
  "Near Mint" "Lightly Played" "Moderately Played" "Heavily Played" "Damaged")

;; Languages
(define-variant-list variant-language
  "English" "French" "Italian" "Spanish" "German" "Portuguese")

;; Ban List Info
(define-variant-list ygo-banlist-name
  "Unlimited" "Semi-Limited" "Limited" "Banned")

;; Formats
(define-variant-list ygo-format-name
  "Common Charity" "Duel Links" "Edison" "GOAT" "OCG" "OCG GOAT" "Speed Duel" "TCG")

;; Link Markers
(define-variant-list ygo-linkmarker-name
  "Top" "Top-Right" "Right" "Bottom-Right" "Bottom" "Bottom-Left" "Left" "Top-Left")
