Files
lispostory/main.lisp
2026-01-05 21:22:19 -05:00

82 lines
3.4 KiB
Common Lisp

(in-package :lispostory)
(defparameter *chronostory-map-url-format* "https://chronostory.onrender.com/api/map-info?mapId=~a")
(defparameter *chronostory-gacha-search-format* "https://chronostory.onrender.com/api/gacha-search?itemId=~a")
(defparameter *chronostory-gacha-url-format "https://chronostory.onrender.com/api/gacha-items?gachaId=~a")
(defun print-version-information ()
(let* ((program-name (car sb-ext:*posix-argv*))
(write-time (file-write-date program-name)))
(multiple-value-bind (second minute hour date month year)
(decode-universal-time write-time)
(let ((dt (format nil "~4,'0d-~2,'0d-~2,'0d ~2,'0d:~2,'0d:~2,'0d"
year month date hour minute second)))
(format t "lispostory, created ~a~%" dt)))))
(defun get-arg (opt args)
"Get's the argument for a given command line option. Expects <program opt arg>"
(loop :for (current next) :on args
:while next
:when (string-equal current opt)
:return next))
(defun refresh-data (data-type maybe-file-path)
(string-case data-type
("drops" (refresh (maybe-pass #'make-drop-data-source maybe-file-path)))
("items" (refresh (maybe-pass #'make-item-data-source maybe-file-path)))
("mobs" (refresh (maybe-pass #'make-mob-data-source maybe-file-path)))
("spawns" (refresh (maybe-pass #'make-spawn-data-source maybe-file-path)))))
(defun main ()
(sb-ext:disable-debugger)
(let ((args (rest sb-ext:*posix-argv*)))
(when (find-string "--fail" args)
(error "Simulated error!"))
(when (find-string "--version" args)
(print-version-information))
(when-let ((arg (get-arg "refresh" args)))
(let ((maybe-file-path (get-arg "--output" args)))
(refresh-data arg maybe-file-path)))))
(defun create-exe-and-die ()
(sb-ext:save-lisp-and-die
"lispostory"
:toplevel 'lispostory:main
:executable t
:save-runtime-options :accept-runtime-options))
(comment
(maybe-pass #'make-spawn-data-source (get-arg "--output" '("/root/lispostory/lispostory" "refresh" "spawns" "--output" "/root/api/chronostory/spawns.json")))
(defvar foo nil)
(setf foo (serapeum/bundle:random-elt *chronostory-mobs*)
*chronostory-drops*)
(let ((spawns (coerce (gethash "LUDIBRIUM" (data (make-spawn-data-source))) 'list)))
(find-if (lambda (hm) (string-equal (gethash "MobName" hm) "Master Death Teddy")) spawns))
(let* ((mobs (coerce (data(make-mob-data-source)) 'list)))
(filter-map (lambda (hm)
(let ((item-name (string-downcase (gethash "ItemName" hm))))
(when (or
(string-contains-p "orange goldrunners" item-name)
(string-contains-p "blue goldrunners" item-name))
(@ (find-if (lambda (mhm)
(= (parse-integer (@ mhm "mob" "mob_id"))
(gethash "DropperID" hm)))
mobs) "mob" "mob_name"))))
(coerce (data (make-drop-data-source)) 'list)))
(reload-item-data
(filter-map
(lambda (m)
(when (= (parse-integer (gethash "DROPPERID" m))
(parse-integer (href foo "mob" "mob_id")))
(gethash "ITEMNAME" m))
(coerce *chronostory-drops* 'list)
(hash-table-keys (aref (@ *chronostory-spawns* :el-nath) 0))
(hash-table-keys (aref *chronostory-drops* 0))))))