竟然还很好玩,不过我敏捷都为负了还可以来一击紧张刺激的stabe

;;;;global variables for the players and monsters(defparameter *player-health* nil)
(defparameter *player-agility* nil)
(defparameter *player-strength* nil)(defparameter *monsters* nil)
(defparameter *monster-builders* nil)
(defparameter *monster-num* 12);;;;main game function(defun orc-battle ()(init-monsters)(init-player)(game-loop)(when (player-dead)(princ "You have been killed. Game Over."))(when (monsters-dead)(princ "Congratulations! You have vanquished all of your foes.")))(defun game-loop ()(unless (or (player-dead) (monsters-dead))(show-player)(dotimes (k (1+ (truncate (/ (max 0 *player-agility*) 15))))(unless (monsters-dead)(show-monsters)(player-attack)))(fresh-line)(map 'list (lambda (m)(or (monster-dead m) (monster-attack m)))*monsters*)(game-loop)));;;;player management functions(defun init-player ()(setf *player-health* 30)(setf *player-agility* 30)(setf *player-strength* 30))(defun player-dead ()(<= *player-health* 0))(defun show-player ()(fresh-line)(princ "You are a valiant knight with a health of ")(princ *player-health*)(princ ", an agility of ")(princ *player-agility*)(princ ", and a strength of ")(princ *player-strength*))(defun player-attack ()(fresh-line)(princ "Attack style: [s]tabe [d]ouble swing [r]oundhouse:")(case (read)(s (monster-hit (pick-monster)(+ 2 (randval (ash *player-strength* -1)))))(d (let ((x (randval (truncate (/ *player-strength* 6)))))(princ "Your double swing has a strength of ")(princ x)(fresh-line )(monster-hit (pick-monster) x)(unless (monsters-dead)(monster-hit (pick-monster) x))))(otherwise (dotimes (x (1+ (randval (truncate (/ *player-strength* 3)))))(unless (monsters-dead)(monster-hit (random-monster) 1))))))(defun randval (n)(1+ (random (max 1 n))));;;;helper functions for player attcks(defun random-monster ()(let ((m (aref *monsters* (random (length *monsters*)))))(if (monster-dead m)(random-monster)m)))(defun pick-monster ()(fresh-line)(princ "Monster #:")(let ((x (read)))(if (not (and (integerp x) (>= x 1) (<= x *monster-num*)))(progn (princ "That is not a valid monster number.")(pick-monster))(let ((m (aref *monsters* (1- x))))(if (monster-dead m)(progn (princ "That monster is alread dead.")(pick-monster))m)))));;;;monster management functions(defun init-monsters ()(setf *monsters*(map 'vector (lambda (x)(funcall (nth (random (length *monster-builders*))*monster-builders*)))(make-array *monster-num*))))(defun monster-dead (m)(<= (monster-health m) 0))(defun monsters-dead ()(every #'monster-dead *monsters*))(defun show-monsters ()(fresh-line)(princ "Your foes:")(let ((x 0))(map 'list (lambda (m)(fresh-line)(princ " ")(princ (incf x))(princ ". ")(if (monster-dead m)(princ "**dead**")(progn (princ "(Health=")(princ (monster-health m))(princ ") ")(monster-show m))))*monsters*)));;;;the monsters(defstruct monster (health (randval 10)))(defmethod monster-hit (m x)(decf (monster-health m) x)(if (monster-dead m)(progn (princ "You killed the ")(princ (type-of m))(princ "! "))(progn (princ "You hit the ")(princ (type-of m))(princ ", knocking off ")(princ x)(princ " health points! "))))(defmethod monster-show (m)(princ "A firce ")(princ (type-of m)))(defmethod monster-attack (m));;;;the wicked orc(defstruct (orc (:include monster)) (club-level (randval 8)))
(push #'make-orc *monster-builders*)(defmethod monster-show ((m orc))(princ "A wicked orc with a level")(princ (orc-club-level m))(princ " club"))(defmethod monster-attack ((m orc))(let ((x (randval (orc-club-level m))))(princ "An orc swings his club at you and knocks off ")(princ x)(princ " of your health points. ")(decf *player-health* x)));;;;the malicious hydra (defstruct (hydra (:include monster)))
(push #'make-hydra *monster-builders*)(defmethod monster-show ((m hydra))(princ "A malicious hydra with ")(princ (monster-health m))(princ " heads."))(defmethod monster-hit ((m hydra) x)(decf (monster-health m) x)(if (monster-dead m)(princ "The corpse of the fully decapitated and decapacitated hydra falls to the floor!")(progn (princ "You lop off ")(princ x)(princ " of the hydra's heads! "))))(defmethod monster-attack ((m hydra))(let ((x (randval (ash (monster-health m) -1))))(princ "A hydra attacks you with ")(princ x)(princ " of its heads! It also grows back one more head! ")(incf (monster-health m))(decf *player-health* x)));;;;slime(defstruct (slime-mold (:include monster)) (sliminess (randval 5)))
(push #'make-slime-mold *monster-builders*)
(defmethod monster-show ((m slime-mold))(princ "A slime mold with a sliminess of ")(princ (slime-mold-sliminess m)))(defmethod monster-attack ((m slime-mold))(let ((x (randval (slime-mold-sliminess m))))(princ "A slime mold wraps around your legs and decreases your agility by ")(princ x)(princ "! ")(decf *player-agility* x)(when (zerop (random 2))(princ "It also squirts in your face, taking away a health point! ")(decf *player-health*))));;;;the cunning brigand(defstruct (brigand (:include monster)))
(push #'make-brigand *monster-builders*)(defmethod monster-attack ((m brigand))(let ((x (max *player-health* *player-agility* *player-strength*)))(cond ((= x *player-health*)(princ "A brigand hits you with his slingshot, taking off 2 health points! ")(decf *player-health* 2))((= x *player-agility*)(princ "A brigand catches your leg with his whip, taking off 2 agility points! ")(decf *player-agility* 2))((= x *player-strength*)(princ "A brigand cuts your arm with his whip, taking off 2 strength points! ")(decf *player-strength* 2)))))

转载于:https://www.cnblogs.com/tclan126/p/7464542.html

Orc-Battle相关推荐

  1. 国际战略中aaa模式_AAA游戏中的微交易将继续存在(但仍然很糟糕)

    国际战略中aaa模式 This weekend, while most of the technology and gaming press wasn't working on anything pa ...

  2. date类型_06076.1.0如何将ORC格式且使用了DATE类型的Hive表转为Parquet表

    温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图. Fayson的github: https://github.com/fayson/cdhproject 提示 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 1013 Battle Over Cities(并查集解法)

    关于背景的介绍见1013 Battle Over Cities(图的DFS解法) DFS就是不算特定结点后数连通子图的总数,再减一.我想着那么并查集就是数不算特定节点后,集合元素(根)的个数.但是我弄 ...

  5. 神经网络变成小怪兽,还能互相 battle!这款游戏用最简单的方式训练神经网络...

    机器之心报道 编辑:魔王 在游戏里训练「神经网络小怪兽」,学习强化学习! 想了解神经网络,但不知道如何入手?教程太枯燥,论文不好懂? 别怕,这里有款多人在线战术竞技游戏(MOBA),让你在西部牛仔的世 ...

  6. text、RC、Parquet、ORC

    数据格式:text.RC.Parquet.ORC 相同大小的原始数据集,转换成相应的格式之后的文件大小:Text > RC > Parquet > ORC Text/CSV csv文 ...

  7. 【发现】Warcraft III v1.22 不用正版CDKey上Battle.net 续篇

    之前介绍过一个方法,有朋友说没有几个人,今天推荐一个人比上一个推荐的服务器多的,但是如果跟浩方比那没法比!仅仅享受一下上battle.net的感觉吧!何必那么较真嘛: 下载这个安装之后就可以了: ht ...

  8. 20+顶尖高校同时开打《王者荣耀》!实际上是一场科研battle,你能信?

    金磊 假装发自 王者峡谷 量子位 报道 | 公众号 QbitAI 不是吧,不是吧. 一群学霸聚集在一起,竟然是为了打<王者荣耀>?! 而且还是来自清北.中科院.浙大等20余所顶级学府的那种 ...

  9. Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set区间分解

    D. One-Dimensional Battle Ships Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...

  10. MapReduce基础开发之十读写ORC File

    1.ORC File Orc是Hive特有的一种列式存储的文件格式,它有着非常高的压缩比和读取效率,因此很快取代了之前的RCFile,成为Hive中非常常用的一种文件格式. 2.编译ORC Jar包 ...

最新文章

  1. 用Python从头实现一个神经网络
  2. servlet中为什么doGet方法没有被调用的一种可能(笔记)
  3. 基于重力补偿的 PD 控制
  4. 2021年结婚登记创36年新低,六大原因值得注意
  5. 15.Node.js REPL(交互式解释器)
  6. Pytorch DataLoader一次性封装多种数据集(pytorch Data学习六)
  7. SAP License:家装ERP
  8. 17.1.1.3 Creating a User for Replication 创建一个用于用于复制:
  9. None.js 第五步 Buffer(缓冲区)
  10. java ajaxsubmit_jQuery 使用 ajaxSubmit() 提交表单实现方法
  11. 继电保护原理7-母线保护
  12. 蓝桥杯 等差素数列(python实现)
  13. mysql创建唯一非聚集索引_创建聚集索引、非聚集索引、唯一索引、唯一键约束...
  14. 方维直播源码:修复BUG完整版(附代码)
  15. 使用idea解决包依赖冲突的问题SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory
  16. 计算机组成原理—储存器的层次结构
  17. 计算机bq,用BQ24700构成的笔记本电脑电池充电电路
  18. 阿里云天池大赛赛题解析——机器学习篇
  19. linux—常用gdb调试命令汇总
  20. VMware vGPU服务器配置

热门文章

  1. css3绘制八卦图及动画效果
  2. coda 创建和删除虚拟环境
  3. 密码打马赛克已经不安全了!这款开源的去“马赛克“工具一秒还原
  4. 使用超级用户登录系统linux,登录和退出Linux系统
  5. 2020华数杯数学建模C题脱贫帮扶绩效评价求解全过程文档及程序
  6. 公告:请访问我Blog新站——酷壳 CoolShell.me
  7. 抖音直播聊天窗口如何关闭,抖音直播间看不到弹幕
  8. 如何建立高质量团队-《克服团队协作的五种障碍》笔记与心得
  9. 关于宿舍熄灯问题的调研
  10. java怎么打印星期,在任何日期打印出星期几