Bläddra i källkod

Nothing of note, just messing around with displays

Simon Watson 1 år sedan
förälder
incheckning
829e5e0560
5 ändrade filer med 106 tillägg och 18 borttagningar
  1. 17 7
      README.md
  2. 1 0
      clwars.lisp
  3. 28 4
      game.lisp
  4. 51 0
      plumbing.lisp
  5. 9 7
      structs.lisp

+ 17 - 7
README.md

@@ -6,11 +6,12 @@ Text based trading/adventure sim.
 
 ** Description
 CL-Wars is a text based game made for fun, highly inspired by
-Space Trader, Drug Wars, and WH40k.
+Space Trader, Drug Wars, FTL, Roguelikes, STALKER, WH40k, and
+many more.
 
-In CL-Wars you are a rogue trader on the run from galatic
-security forces, and you must use the tools available to
-you to reach a safe haven on the edge of the galaxy.
+In CL-Wars you are a rogue trader on the edge of an poorly charted
+and unfriendly galaxy. Ply your wares, capture archeotech, and
+purge xenomorphs in the fires of your guns.
 
 ** Systems
 *** Systems
@@ -37,12 +38,21 @@ you to reach a safe haven on the edge of the galaxy.
     - High hull damage, low shield damage
   - Explosive Weapon
     - Average hull damage, average shield damage
-- Money
+- Money/Economy
   - Used to upgrade ship components/crew
+  - Can trade spice (variable cost in systems), but your crew will
+    consume it based on their happiness
+  - Can trade archeotech (AT has characteristics that may be desireable to
+    different planetary systems)
 - Crew Systems
   - Crew needs gruel for food
   - Crew will be happier if spice is present on the ship
   - Crew members can give buffs
     to other parts of the ship
-  - Sanity
-  - Moral
+  - Sanity/Moral (impacted by availability of spice and/or horrors of the warp)
+- Hazard/Boon System
+  - Each sector contains a hazard and a boon
+    - A hazard is a combat encounter or some kind of negative event
+    - The boon is some kind of positive event
+    - The likelihood of either depends on sanity calculation
+      - Perhaps flesh out equipment system for 'boon' hunting

+ 1 - 0
clwars.lisp

@@ -1,6 +1,7 @@
 (load "~/Repos/clwars/ascii-assets.lisp")
 (load "~/Repos/clwars/structs.lisp")
 (load "~/Repos/clwars/game.lisp")
+(load "~/Repos/clwars/plumbing.lisp")
 
 (defun reload()
   (load "~/Repos/clwars/clwars.lisp"))

+ 28 - 4
game.lisp

@@ -7,8 +7,8 @@
 						   :price-of-archeotech 1000
 						   :price-of-spice 50
 						   :price-of-gruel 5)
-			      :hazard-count 1
-			      :boon-count 1))
+			      :hazards NIL
+			      :boons NIL))
   (setq *player-ship* (make-player-ship :armor-val 10
 					:rep-shield-val 10
 					:warp-drive (list 1 5)
@@ -29,9 +29,8 @@
 								    :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))))
+									     collect (make-uniq-crew-mem :name (make-crew-mem-name))))
 					:inventory (make-player-inventory :petrofuel 20
 									  :gruel 20
 									  :spice 0
@@ -66,8 +65,33 @@ Actions:
 
 (defun sector-info ()
   (format t "Called sector-info"))
+
+;;; SHIP INFO ;;;
+(defun display-crew ()
+  (let* ((crew-struct (crew-crew-members (player-ship-crew *player-ship*)))
+	 (crew-names 
+	   (loop for member in crew-struct
+		 collect (list (uniq-crew-mem-name member) NIL NIL))))
+    (format T "CREW DETAILS~%~%")
+    (format-table T (list (list (crew-sanity-val (player-ship-crew *player-ship*)))) :column-label '("Sanity"))
+    (format T "~%")
+    (format-table T crew-names :column-label '("Name" "Buff" "Buff Amount"))))
+
+(defun display-inventory ()
+  (let ((inventory-list (list 
+			 (list "Petrofuel" (player-inventory-petrofuel (player-ship-inventory *player-ship*)))
+			 (list "Gruel" (player-inventory-gruel (player-ship-inventory *player-ship*)))
+			 (list "Spice" (player-inventory-spice (player-ship-inventory *player-ship*)))
+			 (list "Ammo" (player-inventory-ammo (player-ship-inventory *player-ship*)))
+			 (list "Archeotech" (player-inventory-archeotech (player-ship-inventory *player-ship*))))))
+    (format T "INVENTORY~%")
+    (format-table T inventory-list :column-label '("Resource" "Amount"))))
+
+
 (defun ship-info ()
   (format t "Called ship-info"))
+;;; SHIP INFO END ;;;
+
 (defun trade ()
   (format t "Called trade"))
 (defun scout ()

+ 51 - 0
plumbing.lisp

@@ -0,0 +1,51 @@
+;;; TABLE PRINTING
+;;; Taken from: https://gist.github.com/WetHat/a49e6f2140b401a190d45d31e052af8f
+;;; Used for pretty printing output
+(defvar +CELL-FORMATS+ '(:left   "~vA"
+                         :center "~v:@<~A~>"
+                         :right  "~v@A"))
+
+(defun format-table (stream data &key (column-label (loop for i from 1 to (length (car data))
+                                                          collect (format nil "COL~D" i)))
+                                      (column-align (loop for i from 1 to (length (car data))
+                                                          collect :left)))
+    (let* ((col-count (length column-label))
+           (strtable  (cons column-label ; table header
+                          (loop for row in data ; table body with all cells as strings
+                              collect (loop for cell in row
+                                           collect (if (stringp cell)
+                                                        cell
+                                                    ;else
+                                                        (format nil "~A" cell))))))
+           (col-widths (loop with widths = (make-array col-count :initial-element 0)
+                           for row in strtable
+                           do (loop for cell in row
+                                    for i from 0
+                                  do (setf (aref widths i)
+                                         (max (aref widths i) (length cell))))
+                           finally (return widths))))
+        ;------------------------------------------------------------------------------------
+        ; splice in the header separator
+        (setq strtable
+              (nconc (list (car strtable) ; table header
+                           (loop for align in column-align ; generate separator
+                                 for width across col-widths
+                               collect (case align
+                                           (:left   (format nil ":~v@{~A~:*~}"
+                                                        (1- width)  "-"))
+                                           (:right  (format nil "~v@{~A~:*~}:"
+                                                        (1- width)  "-"))
+                                           (:center (format nil ":~v@{~A~:*~}:"
+                                                        (- width 2) "-")))))
+                           (cdr strtable))) ; table body
+        ;------------------------------------------------------------------------------------
+        ; Generate the formatted table
+        (let ((row-fmt (format nil "| ~{~A~^ | ~} |~~%" ; compile the row format
+                           (loop for align in column-align
+                               collect (getf +CELL-FORMATS+ align))))
+              (widths  (loop for w across col-widths collect w)))
+            ; write each line to the given stream
+            (dolist (row strtable)
+              (apply #'format stream row-fmt (mapcan #'list widths row))))))
+
+

+ 9 - 7
structs.lisp

@@ -19,9 +19,7 @@
 
 (defstruct crew
   sanity-val ; Max 100
-  moral-val ; Max 100
-  crew-members ; List of *uniq-crew-mem*
-  )
+  crew-members) ; List of *uniq-crew-mem*
 
 ;;; Unique crew member that can provide an abstract buff
 ;;; or nerf to some internal game system
@@ -30,7 +28,6 @@
   armor-buff
   rep-shield-buff
   sanity-buff
-  moral-buff
   warp-drive-buff
   reactor-str-buff
   warp-field-buff
@@ -42,6 +39,11 @@
 ;; Crew name generators
 (defvar *name-prefixes*
   (list "Precepitor"
+	"Auriga"
+	"Basileus"
+	"Pontiff"
+	"Palatine"
+	"Centurion"
 	"Conjugator"
 	"Principus"
 	"Executor"
@@ -80,7 +82,7 @@
 	"Quintus"
 	"Decimus"))
   
-(defun get-crew-mem-name ()
+(defun make-crew-mem-name ()
   (let ((name (nth (random (length *name-values*)) *name-values*))
 	(prefix (nth (random (length *name-prefixes*)) *name-prefixes*)))
     (concatenate 'string prefix " " name)))
@@ -102,5 +104,5 @@
 ;; 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
+  hazards ; Contains hazard for sector
+  boons) ; Contains boon for sector