diff options
| author | El-BG-1970 <elouangros@hotmail.com> | 2022-08-04 18:47:24 +0200 |
|---|---|---|
| committer | El-BG-1970 <elouangros@hotmail.com> | 2022-08-04 18:47:24 +0200 |
| commit | 62d2646d4dbe4a3a35bd9b4449e5c5b67d36f233 (patch) | |
| tree | e8e60cf9cd00c27e216fbd4b100d64abf30001da /src/game.lisp | |
| parent | 5731684cca287633b7589c12ca1372eec5dc0f0a (diff) | |
| download | transacc-62d2646d4dbe4a3a35bd9b4449e5c5b67d36f233.tar.gz | |
implemented game:get profit
Diffstat (limited to 'src/game.lisp')
| -rw-r--r-- | src/game.lisp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/game.lisp b/src/game.lisp index 51c3a4d..979e4e2 100644 --- a/src/game.lisp +++ b/src/game.lisp @@ -3,7 +3,9 @@ (:export :new-game :buy-item :sell-item - :change-zone)) + :change-zone + :get-profit + :get-profit-in-zone)) (in-package :game) @@ -40,3 +42,16 @@ zones))) (when z (setq cur-zone z))))) + +(defmethod get-profit-in-zone ((g game) name zone) + (with-slots (player) g + (let ((player-item (car (player:find-item player name))) + (zone-item (zone:get-commodity zone name))) + (if (and player-item zone-item) + (- (commodities:price zone-item) + (commodities:price player-item)) + 0)))) + +(defmethod get-profit ((g game) name) + (with-slots (cur-zone) g + (get-profit-in-zone g name cur-zone))) |
