전투 모듈에서는 몹에 대한 공격과 방어가 확률에 의해 진행된다.
방어구를 입은 경우 넘겨야할 난이도를 75%정도로 낮추어서 게임 진행을 쉽게 한다.
전투종료시 난이도 값을 얼마나 남겼는지를 확인해서 승패를 결정한다.
;; 배틀모드
(defun taking-arms ()
(let ((prob1 (random 10))
(prob2 (random 10))
(prob3 (random 10))
(prob4 (random 100))
(prob5 (random 10)))
(cond ((> prob1 5)
(format t "~a attacks~%" *monster*))
(t
(format t "you attack~%")))
(cond ((> prob2 5)
(progn
(format t "You manage to wound it~%")
(setf *ff* (floor (* 5 (/ *ff* 6)))))))
(cond ((> prob3 5)
(progn
(format t "The monster wounds you!~%")
(decf *strength* 5))))
(cond ((> prob4 35)
(taking-arms))
(t
(cond ((> (* prob5 1.6) *ff*)
(progn
(format t "~%and you managed to kill the ~a" *monster*)
(incf *mk*)
(setf (nth 6 (nth (- *room* 1) *castle*)) 0)))
(t
(progn
(format t "The ~a defeated you." *monster*)
(setf *strength* (floor (*strength* 2))))))))))

방어구를 입은 경우 넘겨야할 난이도를 75%정도로 낮추어서 게임 진행을 쉽게 한다.
;;; 전투모듈실제 전투모드에서는 확률에 의거해 공방을 결정하고, 전투가 끝나는 것도 확률로 결정한다.
(defun fight ()
(prompt-read "press return to fight")
(cond ((= *suit* 1)
(progn
(format t "Your armor increases your chance of success~%")
(setf *ff* (* 3 (floor (/ *ff* 4)))))))
(cond ((and (= *axe* 0) (= *sword* 0))
(progn
(format t "You have no weapons~%You mush fight with Base hands~%")
(setf *ff* (+ *ff* (floor (/ *ff* 5))))))
((and (= *axe* 1) (= *sword* 0))
(progn
(format t "You have only an axe to fight with~%")
(setf *ff* (* 4 (floor (/ *ff* 5))))))
((and (= *sword* 1) (= *axe* 0))
(progn
(format t "You mush fight with your sowrd~%")
(setf *ff* (* 3 (floor (/ *ff* 4))))))
(t
(let ((z (parse-integer (prompt-read "Which weapon? 1- Axe, 2- Sword"))))
(cond ((= z 1) (setf *ff* (* 4 (floor (/ *ff* 5)))))
((= z 2) (setf *ff* (* 3 (floor (/ *ff* 4)))))))))
(taking-arms))
전투종료시 난이도 값을 얼마나 남겼는지를 확인해서 승패를 결정한다.
;; 배틀모드
(defun taking-arms ()
(let ((prob1 (random 10))
(prob2 (random 10))
(prob3 (random 10))
(prob4 (random 100))
(prob5 (random 10)))
(cond ((> prob1 5)
(format t "~a attacks~%" *monster*))
(t
(format t "you attack~%")))
(cond ((> prob2 5)
(progn
(format t "You manage to wound it~%")
(setf *ff* (floor (* 5 (/ *ff* 6)))))))
(cond ((> prob3 5)
(progn
(format t "The monster wounds you!~%")
(decf *strength* 5))))
(cond ((> prob4 35)
(taking-arms))
(t
(cond ((> (* prob5 1.6) *ff*)
(progn
(format t "~%and you managed to kill the ~a" *monster*)
(incf *mk*)
(setf (nth 6 (nth (- *room* 1) *castle*)) 0)))
(t
(progn
(format t "The ~a defeated you." *monster*)
(setf *strength* (floor (*strength* 2))))))))))
