123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- (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-sector :market (make-market :price-of-petrofuel 20
- :price-of-ammo 10
- :price-of-archeotech 1000
- :price-of-spice 50
- :price-of-gruel 5)
- :hazards NIL
- :boons NIL))
- (setq *player-ship* (make-player-ship :armor-val 10
- :rep-shield-val 10
- :warp-drive (list 1 5)
- :reactor-str 1
- :warp-field 1
- :weapons (list (make-weapon :name "Plamsa"
- :shield-dmg 3
- :hull-dmg 3
- :ammo-cost 5)
- (make-weapon :name "Mega Bolter"
- :shield-dmg 1
- :hull-dmg 2
- :ammo-cost 1)
- (make-weapon :name "Beam"
- :shield-dmg 1
- :hull-dmg 3
- :ammo-cost 3))
- :credits 1000
- :crew (make-crew :sanity-val 100
- :moral-val 100
- :crew-members (loop for x in '(1 2 3 4)
- collect (make-uniq-crew-mem :name (make-crew-mem-name))))
- :inventory (make-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))
-
|