commit b51d80eee12194854d3770bf69d1375866338cef
Author: Simon Watson <spw01@protonmail.com>
Date: Fri Feb 10 20:28:43 2023 -0500
Adding a small macro
Can in theory help simplify the messy buy/sell functions
diff --git a/game.lisp b/game.lisp
index 06b5f89..2b72ae3 100644
--- a/game.lisp
+++ b/game.lisp
@@ -211,6 +211,10 @@ Actions:
(sell-transaction item-to-sell quantity)
(trade-menu)))))
+(defmacro dynamic-slot-access (predicate slotname accessor)
+ "Given a predicate where the predicate is a struct slot accessor like 'market-price-of-',
+ an 'accessor' like 'petrofuel', and a struct location, return the slot accessor function"
+ `(funcall ,(symbol-function (find-symbol (string-upcase (concatenate 'string predicate slotname)))) ,accessor))
(defun display-prices ()
;;; (funcall (symbol-function (find-symbol (string-upcase (concatenate 'string "market-price-of-" item)))) (sector-market *sector*)) ;;; A call by string reference method for function calls