1 (load "~/Repos/clwars/structs.lisp")
2 (load "~/Repos/clwars/economy.lisp")
3 (load "~/Repos/clwars/plumbing.lisp")
4 (load "~/Repos/clwars/sector.lisp")
5 (load "~/Repos/clwars/ship.lisp")
6 (load "~/Repos/clwars/ascii-assets.lisp")
7
8
9 (defvar *sector* NIL)
10
11 (defun init-game-state ()
12 (setq *sector* (make-instance 'sector :market (make-instance 'market)
13 :player-ship-obj
14 (make-instance 'player-ship
15 :weapons (list (make-instance 'weapon
16 :name "Plamsa"
17 :shield-dmg 3
18 :hull-dmg 3
19 :ammo-cost 5)
20 (make-instance 'weapon
21 :name "Mega Bolter"
22 :shield-dmg 1
23 :hull-dmg 2
24 :ammo-cost 1)
25 (make-instance 'weapon
26 :name "Beam"
27 :shield-dmg 1
28 :hull-dmg 3
29 :ammo-cost 3))
30 :crew (make-instance 'crew
31 :sanity-val 100
32 :moral-val 100
33 :crew-members (loop for x in '(1 2 3 4)
34 collect (make-instance 'uniq-crew-mem :name (make-crew-mem-name *name-prefixes* *name-values*))))
35 :inventory (make-instance 'player-inventory
36 :petrofuel 20
37 :gruel 20
38 :spice 0
39 :ammo 20
40 :archeotech 0)))))
41
42
43 (defun new-game ()
44 (init-game-state)
45 (game-intro)
46 (top-level-game-menu))
47
48 (defun game-intro ()
49 (cls)
50 (format t "In the grim darkness of the far future, there is only COMMERCE...~%")
51 (sleep 2)
52 (format t "You embark across a bleak galaxy to ply your wares and discover untold riches!~%")
53 (sleep 2)
54 (format t *intro-ship*)
55 (prompt-read ""))
56
57 ;; Options for top level menu
58 ;; This is the main "gameplay" interface
59 (defvar *top-level-options-display* "
60 Actions:
61 1 | Sector info | sei
62 2 | Ship info | si
63 3 | Trade | t
64 4 | Scout | s
65 5 | Leave sector | l
66 ")
67
68 ;; Use lookup table to handle top level loop arguments
69 ;; See: https://dnaeon.github.io/common-lisp-lookup-tables-alists-and-plists/
70 (defparameter *top-level-opt-lookup* (list (cons 'sector-info 'sector-info)
71 (cons '1 'sector-info)
72 (cons '2 (lambda ()
73 (ship-info (player-ship-obj *sector*))))
74 (cons '3 (lambda ()
75 (trade-menu *sector*)))
76 (cons '4 'scout)
77 (cons '5 'leave)))
78
79
80 (defun top-level-game-menu ()
81 (format t *top-level-options-display*)
82 (let ((option (prompt-read "Enter an option: ")))
83 (format t "~%")
84 (handle-opt (read-from-string option) *top-level-opt-lookup*))
85 (top-level-game-menu))
86