1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- (load "~/Repos/clwars/structs.lisp")
- (load "~/Repos/clwars/economy.lisp")
- (load "~/Repos/clwars/plumbing.lisp")
- (load "~/Repos/clwars/sector.lisp")
- (load "~/Repos/clwars/ship.lisp")
- (load "~/Repos/clwars/ascii-assets.lisp")
- (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-crew-mem-name *name-prefixes* *name-values*))))
- :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))
-
|