diff options
| author | El-BG-1970 <elouangros@hotmail.com> | 2022-08-25 15:05:08 +0200 |
|---|---|---|
| committer | El-BG-1970 <elouangros@hotmail.com> | 2022-08-25 15:05:08 +0200 |
| commit | d6ff28e518c4dec62d8520f74a8f4d1a527a47bc (patch) | |
| tree | 814336833572be49868184432f533610707930d9 | |
| parent | 3a9bb4886317e82aee1a45e4b643b5973c5215f9 (diff) | |
| download | transacc-d6ff28e518c4dec62d8520f74a8f4d1a527a47bc.tar.gz | |
begginings of a gui
| -rw-r--r-- | src/game.lisp | 15 | ||||
| -rw-r--r-- | src/main.lisp | 55 | ||||
| -rw-r--r-- | transacc.asd | 2 |
3 files changed, 55 insertions, 17 deletions
diff --git a/src/game.lisp b/src/game.lisp index b55224a..08184fc 100644 --- a/src/game.lisp +++ b/src/game.lisp @@ -5,7 +5,8 @@ :sell-item :change-zone :get-profit - :get-profit-in-zone)) + :get-profit-in-zone + :commodities-panel)) (in-package :game) @@ -65,10 +66,10 @@ (player-item (player:find-item player name)) (quantity (if player-item (cdr player-item) 0)) (profit (if player-item - (- price - (commodities:price (car player-item)))))) - (list name - price - quantity - profit))) + (- price (commodities:price (car player-item))) + 0))) + (list :name name + :price price + :qty quantity + :profit profit))) (zone:get-commodities cur-zone)))) diff --git a/src/main.lisp b/src/main.lisp index 9c0ba32..1fd05a9 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -5,13 +5,50 @@ (in-package :transacc) +(clim:define-application-frame superapp () + () + ;; :panes section describes different parts of the + ;; application-frame. This application has only one pane. + (:panes + (int :interactor :height 400 :width 600)) + + ;; :layouts section describes how the panes are layed out. + ;; This application has one layout named "default" which has a single pane. + (:layouts + (default int))) + +(defun format-panel (panel) + (loop for it in panel do + (format t "~a :~T ~$$ [~@$$] owned: ~a~%" + (getf it :name) + (getf it :price) + (getf it :profit) + (getf it :qty)))) + (defun main () - (let ((player (player:init-player "Joze" 2000)) - (zones - (list - (zone:new-zone "Bronx" - (list (commodities:new-commodity "speed" 500) - (commodities:new-commodity "grass" 40)))))) - (assert (equal (zone:name (car zones)) "Bronx")) - (assert (equal (player:name player) "Joze")) - (format t "~a in the game" (player:name player)))) + (let* ((p (player:init-player "Joze")) + (c (list (commodities:new-commodity "apple" 5) + (commodities:new-commodity "pear" 7))) + (c2 (list (commodities:new-commodity "apple" 6) + (commodities:new-commodity "pear" 2))) + (z (zone:new-zone "Bronx" c)) + (z2 (zone:new-zone "Manhattan" c2)) + (g (game:new-game p z2 (list z z2)))) + + ;; Panel command + (define-superapp-command (com-panel :name t) () + (format-panel (game:commodities-panel g))) + ;; Buy command + (define-superapp-command (com-buy :name t) + ((item 'string) (quantity 'integer)) + (game:buy-item g item quantity)) + ;; Sell command + (define-superapp-command (com-sell :name t) + ((item 'string) (quantity 'integer)) + (game:sell-item g item quantity)) + ;; Goto command + (define-superapp-command (com-goto :name t) + ((dest 'string)) + (game:change-zone g dest)) + + (clim:run-frame-top-level (clim:make-application-frame 'superapp)))) diff --git a/transacc.asd b/transacc.asd index 111a39a..e9cbf45 100644 --- a/transacc.asd +++ b/transacc.asd @@ -3,7 +3,7 @@ :version "0.0.1" :author "Elouan Gros, Isciane Gros" :licence "" - :depends-on () + :depends-on ("mcclim") :components ((:module "src" :components ((:file "main" :depends-on ("game")) |
