Ver Fonte

Small changes

Simon Watson há 2 anos atrás
pai
commit
02e7859d49
3 ficheiros alterados com 163 adições e 68 exclusões
  1. 21 14
      ascii-assets.lisp
  2. 88 54
      game.lisp
  3. 54 0
      structs.lisp

+ 21 - 14
ascii-assets.lisp

@@ -11,18 +11,25 @@
 ")
 
 (defvar *intro-ship* "
-.        ,     . * -    .  .   , , . . -   *   . .
-    .       /        .       .           .  *     ,
-  *   , -     *    .    *      . _ .  ,   .   ,  .  .
--  ,     .     ;  .   ,    ,,   .   .   *   .  .   .
- .   *  ;   .   __________________   *   ,   .   +  
-*  ^   .  ,  * |              |   \ ., * .. . , . . -
-     . , * * * |              |____\
-     , . * * * |                   /
-             * |__________________/
-  ___             |   /
-/    \            |  /
-      \           | /---++
-      /           |/----++
-\ __ /
+                                                               ┈   ┅
+                                                              ▂▂╶╴▁▂
+                                                              ▐▊╌▏▅▐╻
+                                                           ▕▄▄▟▊▁▅█▝▍▂▍╲
+                                                          ▗▅██▐▃▂█▋─▇█▇▊
+                                                          ▐█▀▔▜████╎███▉
+                                                    ▁ ╷  ▕█▃▃█▟█▆██╸████▆▆▖
+                                           ▁     ┒▄▅▅▂▁▄▟▆▆▇━▀▝▀▔▂▔▔▔▔  ━██▏  ▁▃┒
+                                    ▖   ▗  ╴ ▂▃▟▅┰▐▜▜▀▀▘▔▔▁▂▄▅▄▅▉▐▙▆▁       ▃▔▐▆█▎
+                                  ▁ ╾─╴▆▟▜▜▇▅▉▟╹▀▔ ▁▂▁▄━▇█▇▀▘▜▃▃▅▆██▛█▖▃ ▃▃▃▊▕███▍
+                        ╴▁  ─╍▁▂▇▃╶▁ ▝▜▀▀▀▂▟▁▂▃▄▅▛▜▇▛▀▀▃▜▄▇▟██████████▇▆██▛▀▜▐███▘
+                        ╺▆▇▛▀▀▔▔  ▂▃▄▅▆▇▛▜███▇▛▜▀▃▜▇▟▆███████████████████▔   ▜▀▔▔
+                     ─╼┙▀▅▅▆▆▆▇▇▇██████▆█████▃█▟▇██████████████████████▀▔
+                  ▁▂▃╼┶┻▛▊┷██▃▅████████████████████████▀▀███████▛▀▜▀▀▔
+               ╼╵▘▔ ▁▃▇███████████████████████████▜▔▔ ▕▏   ▔▔
+                ╶━▝└╼┙▘▔▕██████┬┳███████████▜▌▀▀ ▌     ▏
+                     ▁▁▅▛▔▔  ▂    ▟▟███████▎▝    ╹
+                ▁▃─┶▂▟██▘▃▅▆▀▘ ▁  ▔▀█████▀▀▏
+              ▁▂╶╼▀▀▀▇▀  ▔▁▃▄▆▛▃▃▖━▀▀▔
+              ▔     ▕▅▅▅▆████▛▔▔▔
+                       ╺▛▀▔▔
 ")

+ 88 - 54
game.lisp

@@ -1,72 +1,106 @@
 (defvar *player-ship*)
-(defvar *market*)
-
-
-(defun random-uniq-crew ()
-  (let ((num-attr (random 10))
-	(crew-mem (make-uniq-crew-mem)))))
-    
-
+(defvar *sector*)
+	
 (defun init-game-state ()
-  (progn
-    (setq *market* (make-market :price-of-petrofuel 20
-				:price-of-ammo 10
-				:price-of-archeotech 1000
-				:price-of-spice 50
-				:price-of-gruel 5))
-    (setq *player-ship* (make-player-ship :armor-val 10
-		      :rep-shield-val 10
-		      :warp-drive (list 1 5)
-		      :reactor-str 1
-		      :ammo 20
-		      :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 (list (make-uniq-crew-mem)))
-		      :inventory (make-player-inventory :petrofuel 20
-							:gruel 20
-							:spice 0
-							:ammo 20
-							:archeotech 0)))))
+  (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)
+			      :hazard-count 1
+			      :boon-count 1))
+  (setq *player-ship* (make-player-ship :armor-val 10
+					:rep-shield-val 10
+					:warp-drive (list 1 5)
+					:reactor-str 1
+					:ammo 20
+					: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 (get-crew-mem-name))))
+					:inventory (make-player-inventory :petrofuel 20
+									  :gruel 20
+									  :spice 0
+									  :ammo 20
+									  :archeotech 0))))
 
 
 (defun new-game ()
-  (progn
-    (init-game-state))) 
+  (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...~C" #\linefeed)
+  (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!~C" #\linefeed)
+  (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
-(defvar *top-level-options* "
+;; This is the main "gameplay" interface
+(defvar *top-level-options-display* "
 Actions:
-1. Sector info
-2. Ship info
-3. Trade
-4. Scout
-5. Leave
+1 | Sector info | sei
+2 | Ship info | si
+3 | Trade | t
+4 | Scout | s
+5 | Leave | l
 ")
 
+(defun sector-info ()
+  (format t "Called sector-info"))
+(defun ship-info ()
+  (format t "Called ship-info"))
+(defun trade ()
+  (format t "Called trade"))
+(defun scout ()
+  (format t "Called scout"))
+(defun leave ()
+  (format t "Called leave"))
+
+;; Use lookup table to handle top level loop arguments
+;; See: https://dnaeon.github.io/common-lisp-lookup-tables-alists-and-plists/
+(defparameter *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)
+				 (cons 't 'trade)
+				 (cons '3 'trade)
+				 (cons 'scout 'scout)
+				 (cons 's 'scout)
+				 (cons '4 'scout)
+				 (cons 'leave 'leave)
+				 (cons 'l 'leave)
+				 (cons '5 'leave)))
+
+(defun handle-opt (opt)
+  (let ((handler (cdr (assoc opt *opt-lookup*))))
+    (if handler (funcall handler) (format t "Invalid opt~%~%"))))
+
 (defun top-level-game-menu ()
-  (format t *top-level-options*)
-  (let ((option (prompt-read "Enter an option: "))
-	(cond ((eql option '"1") (print "1"))))))
+  (format t *top-level-options-display*)
+  (let ((option (prompt-read "Enter an option: ")))
+    (format t "~%")
+    (handle-opt (read-from-string option)))
+  (top-level-game-menu))
+	  

+ 54 - 0
structs.lisp

@@ -26,6 +26,7 @@
 ;;; Unique crew member that can provide an abstract buff
 ;;; or nerf to some internal game system
 (defstruct uniq-crew-mem
+  name
   armor-buff
   rep-shield-buff
   sanity-buff
@@ -38,6 +39,52 @@
   beam-buff
   credit-buff)
 
+;; Crew name generators
+(defvar *name-prefixes*
+  (list "Precepitor"
+	"Conjugator"
+	"Principus"
+	"Executor"
+	"Commonus"
+	"Gothicus"
+	"Augusta"
+	"Calligraphus"
+	"Imperator"
+	"Consul"
+	"Signifier"
+	"Tribune"
+	"Praetorian"
+	"Prefect"))
+
+(defvar *name-values*
+  (list "Atticus"
+	"Aurelia"
+	"Cassius"
+	"Maximus"
+	"Aurelius"
+	"Magnus"
+	"Lucius"
+	"Augustus"
+	"Caeser"
+	"Remus"
+	"Julius"
+	"Octavius"
+	"Cato"
+	"Tiberius"
+	"Nero"
+	"Romulus"
+	"Septimus"
+	"Cicero"
+	"Cyprian"
+	"Justus"
+	"Quintus"
+	"Decimus"))
+  
+(defun get-crew-mem-name ()
+  (let ((name (nth (random (length *name-values*)) *name-values*))
+	(prefix (nth (random (length *name-prefixes*)) *name-prefixes*)))
+    (concatenate 'string prefix " " name)))
+
 (defstruct weapon
   name
   shield-dmg
@@ -50,3 +97,10 @@
   price-of-archeotech
   price-of-spice
   price-of-gruel)
+
+;; This gets created when travelling to a
+;; new sector
+(defstruct sector
+  market ; contains market struct
+  hazard-count ; number of hazard events in this sector
+  boon-count) ; number of boon events in this sector