From 4198d1ae1d53b87ad0dfcc489b0e90b7f69c6b23 Mon Sep 17 00:00:00 2001 From: El-BG-1970 Date: Fri, 26 Aug 2022 09:21:14 +0200 Subject: added multipurpose panel (currently only displays player stats) --- src/player.lisp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/player.lisp') diff --git a/src/player.lisp b/src/player.lisp index b5c8651..c9033ac 100644 --- a/src/player.lisp +++ b/src/player.lisp @@ -7,7 +7,8 @@ :repay-debt :buy-item :sell-item - :find-item)) + :find-item + :inventory-stats)) (in-package :player) @@ -40,11 +41,10 @@ (with-slots (stock cash) p (let ((cost (* quantity (commodities:price item)))) - (when (>= cash cost) - (progn - (inventory:add-item stock item quantity) - (setq cash (- cash cost)) - t))))) + (when (and (>= cash cost) + (inventory:add-item stock item quantity)) + (setq cash (- cash cost)) + t)))) (defmethod sell-item ((p player) item amount) (with-slots (stock cash) p @@ -67,3 +67,6 @@ (setq cash (- cash amount) debt (- debt amount)) t))) + +(defmethod inventory-stats ((p player)) + (inventory:how-filled (stock p))) -- cgit v1.2.3