Forráskód Böngészése

Reworked some crew stuff, added crew buffs

More work to do, still fleshing out subsystems that are relevant
to the combat system, so that I can fully implement the combat
system.
spesk 1 éve
szülő
commit
38206409cb
6 módosított fájl, 138 hozzáadás és 78 törlés
  1. 126 0
      crew.lisp
  2. 1 0
      economy.lisp
  3. 7 3
      game.lisp
  4. 4 0
      plumbing.lisp
  5. 0 18
      ship.lisp
  6. 0 57
      structs.lisp

+ 126 - 0
crew.lisp

@@ -0,0 +1,126 @@
+(defun display-crew (player-ship-obj)
+  (let ((crew-names 
+	   (loop for member in (crew-members (crew player-ship-obj))
+		 collect (progn
+			   (if (buff member)
+			       (list (name member) (slot-value (buff member) 'buff-type) (slot-value (buff member) 'buff-value))
+			       (list (name member) NIL NIL))))))
+				    
+    (format T "~%CREW DETAILS~%~%")
+    (format-table T
+		  (list
+		   (list
+		    (sanity-val (crew player-ship-obj))
+		    (moral-val (crew player-ship-obj)))) :column-label '("Sanity" "Moral"))
+    (format T "~%")
+    (format-table T crew-names :column-label '("Name" "Buff" "Buff Amount"))))
+
+(defun display-inventory (player-ship-obj)
+  (let* ((inventory (inventory player-ship-obj))
+	(inventory-list (loop for slot in (return-slots inventory)
+			     collect (list
+				      slot (slot-value inventory slot))))) 
+    (format T "~%INVENTORY~%")
+    (format-table T inventory-list :column-label '("Resource" "Amount"))))
+
+(defparameter *buff-types*
+  (list 'weapons-expert
+	'shields-expert
+	'chef
+	'machine-enchanter
+	'warp-shaman
+	'holy-see))
+
+(defun make-buff (buff-type)
+  "Given a buff-type symbol, return an instance of 'crew-buff
+   that corresponds with the buff-type"
+  (case buff-type
+    (holy-see
+     (make-instance 'crew-buff
+		    :name "Holy See" ; Moral cannot go below val while the
+		                     ; Holy See lives
+		    :buff-type buff-type
+		    :buff-value (+ 1 (random 50))))
+    (warp-shaman
+     (make-instance 'crew-buff
+		    :name "Warp Shaman" ; % change to ignore low power warp shield
+		    :buff-type buff-type
+		    :buff-value (+ 0.1 (random 0.6))))
+    (machine-enchanter
+     (make-instance 'crew-buff
+		    :name "Machine Enchanter" ; Val is % chance to not consume
+		                              ; ammo when firing weapon
+		    :buff-type buff-type
+		    :buff-value (+ 0.1 (random 0.6))))
+    (chef
+     (make-instance 'crew-buff
+		    :name "Chef" ; Reduce gruel consumption / action by val
+		    :buff-type buff-type
+		    :buff-value (+ 1 (random 20))))
+    (shields-expert
+     (make-instance 'crew-buff
+		    :name "Shields Expert" ; Increases shield str by val
+		    :buff-type buff-type
+		    :buff-value (+ 1 (random 3))))
+     (weapons-expert
+      (make-instance 'crew-buff
+		     :name "Weapons Expert" ; Increases all weapon damage by val
+		     :buff-type buff-type
+		     :buff-value (+ 1 (random 3))))))
+
+(defun get-random-buff ()
+  "Return a random 'crew-buff object"
+  (make-buff (nth (+ 1 (random (length *buff-types*))) *buff-types*)))
+
+;; Crew name generators
+(defvar *name-prefixes*
+  (list "Precepitor"
+	"Auriga"
+	"Basileus"
+	"Pontiff"
+	"Palatine"
+	"Centurion"
+	"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 make-crew-mem-name (name-prefixes name-values)
+  "Expects a list of strings to use as prefixes for a name, and a list
+   of possible names"
+  (let ((name (nth (random (length name-values)) name-values))
+	(prefix (nth (random (length name-prefixes)) name-prefixes)))
+    (concatenate 'string prefix " " name)))

+ 1 - 0
economy.lisp

@@ -101,6 +101,7 @@ Actions:
 	(cons 'price-of-spice '(5 101))
 	(cons 'price-of-gruel '(1 16))))
 
+;; This could be simplfied with (map #')
 (defun randomize-market-prices (market)
   (let ((get-random-val (lambda (resource-arg)
 			  (+ (cadr resource-arg)

+ 7 - 3
game.lisp

@@ -1,6 +1,7 @@
 (load "~/Repos/clwars/structs.lisp")
-(load "~/Repos/clwars/economy.lisp")
 (load "~/Repos/clwars/plumbing.lisp")
+(load "~/Repos/clwars/crew.lisp")
+(load "~/Repos/clwars/economy.lisp")
 (load "~/Repos/clwars/sector.lisp")
 (load "~/Repos/clwars/ship.lisp")
 (load "~/Repos/clwars/ascii-assets.lisp")
@@ -35,9 +36,12 @@
 							   :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*)
-												       :buff (lambda ()
+												       :buff (funcall
+													      (lambda ()
+														(if (= 1 (+ 1(random 5)))
+														    (get-random-buff)
+														    NIL))))))
 															     
-															     )))
 							   :inventory (make-instance 'player-inventory
 										     :petrofuel 20
 										     :gruel 20

+ 4 - 0
plumbing.lisp

@@ -63,3 +63,7 @@
    function associated with the opt used"
   (let ((handler (cdr (assoc opt lookup-table))))
     (if handler (funcall handler) (format t "Invalid opt~%~%"))))
+
+;; "Given an object, return the names of it's slots"
+(defun return-slots (obj)
+  (map 'list #'closer-mop:slot-definition-name (closer-mop:class-slots (class-of obj))))

+ 0 - 18
ship.lisp

@@ -1,22 +1,4 @@
 ;;; SHIP INFO ;;;
-(defun display-crew (player-ship-obj)
-  (let ((crew-names 
-	   (loop for member in (crew-members (crew player-ship-obj))
-		 collect (list (name member)))))
-    (format T "~%CREW DETAILS~%~%")
-    (format-table T (list (list (sanity-val (crew player-ship-obj)))) :column-label '("Sanity"))
-    (format T "~%")
-    (format-table T crew-names :column-label '("Name" "Buff" "Buff Amount"))))
-
-(defun display-inventory (player-ship-obj)
-  (let* ((inventory (inventory player-ship-obj))
-	(inventory-list (loop for slot in (return-slots inventory)
-			     collect (list
-				      slot (slot-value inventory slot))))) 
-    (format T "~%INVENTORY~%")
-    (format-table T inventory-list :column-label '("Resource" "Amount"))))
-
-
 (defun ship-info (player-ship-obj)
   (display-crew player-ship-obj)
   (display-inventory player-ship-obj))

+ 0 - 57
structs.lisp

@@ -91,10 +91,6 @@
     :initarg :crew-members  ; List of *uniq-crew-mem*
     :accessor crew-members)))
 
-;; "Given an object, return the names of it's slots"
-(defun return-slots (obj)
-  (map 'list #'closer-mop:slot-definition-name (closer-mop:class-slots (class-of obj))))
-
 ;;; Unique crew member that can provide an abstract buff
 ;;; or nerf to some internal game system
 (defclass uniq-crew-mem ()
@@ -119,59 +115,6 @@
     :accessor buff-value
     :initform NIL)))
 
-;; Crew name generators
-(defvar *name-prefixes*
-  (list "Precepitor"
-	"Auriga"
-	"Basileus"
-	"Pontiff"
-	"Palatine"
-	"Centurion"
-	"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 make-crew-mem-name (name-prefixes name-values)
-  "Expects a list of strings to use as prefixes for a name, and a list
-   of possible names"
-  (let ((name (nth (random (length name-values)) name-values))
-	(prefix (nth (random (length name-prefixes)) name-prefixes)))
-    (concatenate 'string prefix " " name)))
-
 (defclass weapon ()
   ((name
     :initarg :name