9400cbc309c678802387d528736589eac127e3ba
commit 9400cbc309c678802387d528736589eac127e3ba
Author: spesk <spw01@protonmail.com>
Date: Mon Feb 13 23:17:55 2023 -0500

More on the CLOS conversion

Quite a bit of work figuring out how I wanted result-slots to work.

In short, it's sorted, and mainly just progress converting everything
to CLOS.

diff --git a/clwars.lisp b/clwars.lisp
index ac14e6f..78f2ff2 100644
--- a/clwars.lisp
+++ b/clwars.lisp
@@ -1,3 +1,4 @@
+(ql:quickload "closer-mop")
(load "~/Repos/clwars/game.lisp")

(defun reload()
diff --git a/game.lisp b/game.lisp
index a7aa223..77c18a1 100644
--- a/game.lisp
+++ b/game.lisp
@@ -70,9 +70,9 @@ Actions:
(defparameter *top-level-opt-lookup* (list (cons 'sector-info 'sector-info)
(cons '1 'sector-info)
(cons 'sei 'sector-info)
- (cons 'ship-info 'ship-info)
- (cons 'si 'ship-info)
- (cons '2 'ship-info)
+ (cons 'ship-info (cons 'ship-info *player-ship*))
+ (cons 'si (cons 'ship-info *player-ship*))
+ (cons '2 (cons 'ship-info *player-ship*))
(cons 'trade 'trade-menu)
(cons 't 'trade-menu)
(cons '3 'trade-menu)
diff --git a/plumbing.lisp b/plumbing.lisp
index e30e34a..b530265 100644
--- a/plumbing.lisp
+++ b/plumbing.lisp
@@ -62,4 +62,4 @@
"When given a string and a list 'lookup table' call the
function associated with the opt used"
(let ((handler (cdr (assoc opt lookup-table))))
- (if handler (funcall handler) (format t "Invalid opt~%~%"))))
+ (if handler (funcall (car handler) (cdr handler)) (format t "Invalid opt~%~%"))))
diff --git a/ship.lisp b/ship.lisp
index 8701cc8..cd92ed2 100644
--- a/ship.lisp
+++ b/ship.lisp
@@ -8,19 +8,16 @@
(format T "~%")
(format-table T crew-names :column-label '("Name" "Buff" "Buff Amount"))))

-(defun display-inventory ()
- (let ((inventory-list (list
- (list "Credits" (player-ship-credits *player-ship*))
- (list "Petrofuel" (player-inventory-petrofuel (player-ship-inventory *player-ship*)))
- (list "Gruel" (player-inventory-gruel (player-ship-inventory *player-ship*)))
- (list "Spice" (player-inventory-spice (player-ship-inventory *player-ship*)))
- (list "Ammo" (player-inventory-ammo (player-ship-inventory *player-ship*)))
- (list "Archeotech" (player-inventory-archeotech (player-ship-inventory *player-ship*))))))
+(defun display-inventory (player-ship-obj)
+ (let* ((inventory (inventory player-ship-obj))
+ (inventory-list (loop for slot in (return-slots inventory)
+ collect (list
+ slot (slot-value inventory slot)))))
(format T "~%INVENTORY~%")
(format-table T inventory-list :column-label '("Resource" "Amount"))))


-(defun ship-info ()
- (display-crew)
- (display-inventory))
+(defun ship-info (player-ship-obj)
+ (display-crew player-ship-obj)
+ (display-inventory player-ship-obj))
;;; SHIP INFO END ;;;
diff --git a/structs.lisp b/structs.lisp
index 48a602f..35f0bfe 100644
--- a/structs.lisp
+++ b/structs.lisp
@@ -69,9 +69,8 @@
:accessor crew-members)))

;; "Given an object, return the names of it's slots"
-(defgeneric return-slots (obj))
-(defmethod return-slots ((market market))
- (map 'list #'closer-mop:slot-definition-name (closer-mop:class-slots (class-of market))))
+(defun return-slots (obj)
+ (map 'list #'closer-mop:slot-definition-name (closer-mop:class-slots (class-of obj))))

;;; Unique crew member that can provide an abstract buff
;;; or nerf to some internal game system