|  | @@ -1,20 +1,46 @@
 | 
	
		
			
				|  |  |  ;;; Combat systems implemented here
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -(defvar *combat-menu-options-display* NIL)
 | 
	
		
			
				|  |  | -(defvar *combat-opt-lookup NIL)
 | 
	
		
			
				|  |  | +(defvar *combat-menu-options-display* "
 | 
	
		
			
				|  |  | +Actions:
 | 
	
		
			
				|  |  | +1 | Attack | a
 | 
	
		
			
				|  |  | +2 | Regen. Shields | r
 | 
	
		
			
				|  |  | +3 | Overcharge Gun | o
 | 
	
		
			
				|  |  | +4 | Attempt to flee | f
 | 
	
		
			
				|  |  | +")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  ;; Combat options:
 | 
	
		
			
				|  |  |  ;; Attack (with specific weapon)
 | 
	
		
			
				|  |  |  ;; Regen shields
 | 
	
		
			
				|  |  |  ;; - (add value to rep-shield-val at cost of overcharing
 | 
	
		
			
				|  |  |  ;; - (overcharing can cause warp field to go into low-power)
 | 
	
		
			
				|  |  | +;; - (overcharging can cause hull damage)
 | 
	
		
			
				|  |  |  ;; Overcharge gun at cost of overcharing reactor
 | 
	
		
			
				|  |  |  ;; Attempt to flee into the warp
 | 
	
		
			
				|  |  | -;; - (requires full power / overcharged
 | 
	
		
			
				|  |  | +;; - (requires full power / overcharged reactor)
 | 
	
		
			
				|  |  |  ;; - (can also cause reactor to go low power, which removes ability to regen/overcharge)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  (defun combat-loop (sector)
 | 
	
		
			
				|  |  | -  "The main loop responsbile for resolving combat situations")
 | 
	
		
			
				|  |  | +  "The main loop responsbile for resolving combat situations"
 | 
	
		
			
				|  |  | +  (let ((combat-state T))
 | 
	
		
			
				|  |  | +    (loop
 | 
	
		
			
				|  |  | +      while combat-state
 | 
	
		
			
				|  |  | +      do (progn
 | 
	
		
			
				|  |  | +	   (format T *combat-menu-options-display*)
 | 
	
		
			
				|  |  | +	   (let ((top-level-selection (prompt-read "Enter a selection: ")))
 | 
	
		
			
				|  |  | +	     (case (read-from-string top-level-selection)
 | 
	
		
			
				|  |  | +	       (1 (progn ;; There is a way to collapse this progn into a single
 | 
	
		
			
				|  |  | +		         ;; function call, but it's arguably a lot less readable
 | 
	
		
			
				|  |  | +		    (let* ((weapon (weapon-select-menu (player-ship-obj sector)))
 | 
	
		
			
				|  |  | +			   (attack-result (player-ship-attack
 | 
	
		
			
				|  |  | +					   (player-ship-obj sector)
 | 
	
		
			
				|  |  | +					   (first (enemy-ships sector))
 | 
	
		
			
				|  |  | +					   weapon)))
 | 
	
		
			
				|  |  | +		      (if attack-result
 | 
	
		
			
				|  |  | +			  (progn
 | 
	
		
			
				|  |  | +			    (setf (enemy-ships sector) (delete attack-result (enemy-ships sector)))
 | 
	
		
			
				|  |  | +			    (format T "Your opponent has been vanquished!~%")
 | 
	
		
			
				|  |  | +			    (top-level-game-menu))))))))))))
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  ;; Select weapon
 | 
	
		
			
				|  |  |  ;; Determine if hit (% chance?)
 | 
	
	
		
			
				|  | @@ -24,6 +50,24 @@
 | 
	
		
			
				|  |  |  ;; ELSE
 | 
	
		
			
				|  |  |  ;; -- Decrement shield value per value of shield dmg
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +(defun weapon-select-menu (player-ship-obj)
 | 
	
		
			
				|  |  | +  (let ((weapon-list (loop for weapon in (weapons player-ship-obj)
 | 
	
		
			
				|  |  | +			   for i from 0
 | 
	
		
			
				|  |  | +			   collect (list i
 | 
	
		
			
				|  |  | +					 (name weapon)
 | 
	
		
			
				|  |  | +					 (shield-dmg weapon)
 | 
	
		
			
				|  |  | +					 (hull-dmg weapon)
 | 
	
		
			
				|  |  | +					 (ammo-cost weapon)))))
 | 
	
		
			
				|  |  | +    (format T "~%Available Ammo: ~A~%~%" (ammo (inventory player-ship-obj)))
 | 
	
		
			
				|  |  | +    (format T "Available Weapons: ~%")
 | 
	
		
			
				|  |  | +    (format-table T weapon-list :column-label '("Number" "Name" "Shield Damage" "Hull Damage" "Ammo Cost"))
 | 
	
		
			
				|  |  | +    (let ((selection (prompt-read "Select a weapon to via the number column: ")))
 | 
	
		
			
				|  |  | +      (format t "Selection was number: ~A and weapon name: ~A~%~%"
 | 
	
		
			
				|  |  | +	      selection
 | 
	
		
			
				|  |  | +	      (second (nth (parse-integer selection) weapon-list)))
 | 
	
		
			
				|  |  | +      (return-from weapon-select-menu (nth (parse-integer selection) (weapons player-ship-obj))))))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  (defun calculate-shield-damage (attacker-obj target-obj attacker-weapon)
 | 
	
		
			
				|  |  |    "Given a target and a weapon, return a value that the
 | 
	
		
			
				|  |  |     targets shield value should now be set as"
 | 
	
	
		
			
				|  | @@ -63,3 +107,14 @@
 | 
	
		
			
				|  |  |  	  (format T "Their hulls been breached! You've won the exchange!~%")
 | 
	
		
			
				|  |  |  	  (return-from player-ship-attack target-obj))
 | 
	
		
			
				|  |  |  	NIL)))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +(defun display-weapons (player-ship-obj)
 | 
	
		
			
				|  |  | +  "Given player ship, display weapons and associated attributes"
 | 
	
		
			
				|  |  | +  (let* ((weapons (weapons player-ship-obj))
 | 
	
		
			
				|  |  | +	 (weapon-list (loop for weapon in weapons
 | 
	
		
			
				|  |  | +			    collect (list (name weapon)
 | 
	
		
			
				|  |  | +					  (shield-dmg weapon)
 | 
	
		
			
				|  |  | +					  (hull-dmg weapon)
 | 
	
		
			
				|  |  | +					  (ammo-cost weapon)))))
 | 
	
		
			
				|  |  | +    (format T "~%WEAPON DETAILS~%")
 | 
	
		
			
				|  |  | +    (format-table T weapon-list :column-label '("Name" "Shield Damage" "Hull Damage" "Ammo Cost"))))
 |