(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") (load "~/Repos/clwars/structs.lisp") (defvar *player-ship*) (defvar *sector*) (defun init-game-state () (setq *sector* (make-instance 'sector :market (make-instance 'market))) (setq *player-ship* (make-instance 'player-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 'sei 'sector-info) (cons 'ship-info 'ship-info) (cons 'si 'ship-info) (cons '2 'ship-info) (cons 'trade 'trade-menu) (cons 't 'trade-menu) (cons '3 'trade-menu) (cons 'scout 'scout) (cons 's 'scout) (cons '4 'scout) (cons 'leave 'leave) (cons 'l 'leave) (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))