summaryrefslogtreecommitdiffstats
path: root/src/main.lisp
blob: 1fd05a98d96f36d2d2864b1d6f6b5aef36867a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(in-package :cl-user)
(defpackage transacc
  (:use :cl)
  (:export :main))

(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* ((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))))