diff options
| author | El-BG-1970 <elouan.gros.fr@gmail.com> | 2022-08-26 09:21:14 +0200 |
|---|---|---|
| committer | El-BG-1970 <elouan.gros.fr@gmail.com> | 2022-08-26 09:21:14 +0200 |
| commit | 4198d1ae1d53b87ad0dfcc489b0e90b7f69c6b23 (patch) | |
| tree | 195aab75d3e10a65b07444de2dd63210e9eeeff4 /src/player.lisp | |
| parent | 2a8076782ac7786c26e18493fe407c7916b49254 (diff) | |
| download | transacc-4198d1ae1d53b87ad0dfcc489b0e90b7f69c6b23.tar.gz | |
added multipurpose panel (currently only displays player stats)
Diffstat (limited to 'src/player.lisp')
| -rw-r--r-- | src/player.lisp | 15 |
1 files changed, 9 insertions, 6 deletions
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))) |
