123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- (defvar *sector* NIL)
-
- (defun init-game-state ()
- (setq *sector*
- (make-instance 'sector
- :market (make-instance 'market)
- :player-ship-obj
- (make-instance 'ship
- :weapons (list (make-instance 'weapon
- :name "Plamsa"
- :shield-dmg 3
- :hull-dmg 3
- :ammo-cost 5)
- (make-instance 'weapon
- :name "Mega Bolter"
- :shield-dmg 1
- :hull-dmg 2
- :ammo-cost 1)
- (make-instance 'weapon
- :name "Beam"
- :shield-dmg 1
- :hull-dmg 3
- :ammo-cost 3))
- :crew (make-instance 'crew
- :sanity-val 100
- :moral-val 100
- :crew-members
- (loop for x in '(1 2 3 4)
- collect (make-instance 'uniq-crew-mem :name (make-name *name-prefixes* *name-values*)
- :buff (funcall
- (lambda ()
- (if (= 1 (+ 1(random 5)))
- (get-random-buff *buff-types*)
- NIL))))))
-
- :inventory (make-instance 'player-inventory
- :petrofuel 20
- :gruel 20
- :spice 0
- :ammo 20
- :archeotech 0)))))
- (defun new-game ()
- (init-game-state)
- (game-intro)
- (top-level-game-menu))
- (defun game-intro ()
- (cls)
- (format t "In the grim darkness of the far future, there is only COMMERCE...~%")
- (sleep 2)
- (format t "You embark across a bleak galaxy to ply your wares and discover untold riches!~%")
- (sleep 2)
- (format t *intro-ship*)
- (prompt-read ""))
- ;; Options for top level menu
- ;; This is the main "gameplay" interface
- (defvar *top-level-options-display* "
- Actions:
- 1 | Sector info | sei
- 2 | Ship info | si
- 3 | Trade | t
- 4 | Scout | s
- 5 | Leave sector | l
- ")
- ;; Use lookup table to handle top level loop arguments
- ;; See: https://dnaeon.github.io/common-lisp-lookup-tables-alists-and-plists/
- (defparameter *top-level-opt-lookup* (list (cons 'sector-info 'sector-info)
- (cons '1 'sector-info)
- (cons '2 (lambda ()
- (ship-info (player-ship-obj *sector*))))
- (cons '3 (lambda ()
- (trade-menu *sector*)))
- (cons '4 'scout)
- (cons '5 'leave)))
- (defun top-level-game-menu ()
- (format t *top-level-options-display*)
- (let ((option (prompt-read "Enter an option: ")))
- (format t "~%")
- (handle-opt (read-from-string option) *top-level-opt-lookup*))
- (top-level-game-menu))
-
|