python实现的简单RPG游戏流程实例


Posted in Python onJune 28, 2015

本文实例讲述了python实现的简单RPG游戏流程。分享给大家供大家参考。具体如下:

#RPG
rpg = True
whp = 100
mahp = 100
hhp = 100
MHP = 10
def dgrnd () :
 wa = raw_input ("What does Warrior do?")
 ma = raw_input ("What does Mage do?")
 ha = raw_input ("What does Healer do?")
 if wa == "flame slash" :
  print ("Warrior uses Flame Slash!")
  MHP-20
 elif wa == "Dragon Slash" and M == "Dragon" :
  print ("Warrior used Dragon Slash!")
  MHP-80
 if wa == "Dragon" and M == "Troll" or M == "Goblin" :
  print ("Warrior's attack did no damage!")
 if ma == "icicle drop" :
  print ("Mage used Icicle Drop")
  MHP-15
  mahp-10
  whp-10
  hhp-10
 if ma == "flames of heck" :
  MHP-75
  mahp-50
  wph-50
  hhp-50
 if ha == "heal warrior" :
  print ("Healer Heals Warrior!")
  whp + 20
 if ha == "heal mage" :
  print ("Healer Heals Mage!")
  mahp + 20
 if ha == "heal healer" :
  print ("Healer Heals Healer!")
  hhp + 20
 if ha == "attack" :
  print ("Healer Attacks!")
  MHP - 5
  print (M+"attacks!")
 if M == "dragon" :
  whp - 40
  mahp - 40
  hhp - 40
 if M == "Troll" :
  whp - 30
  mahp - 30
  hhp - 30
 if M == "Goblin" :
  whp - 20
  mahp - 20
  hhp -20
 print ("Warrior has "+whp+" HP left, Mage has "+mahp+" HP left, and Healer has "+hhp+" HP left!")
 if MHP == 0 :
  print ("You defeated the "+M+" !")
  print ("That is all I have built so far. Eventually, there will be more!")
  print ("Thank You for Playing!!")
  dgrnd ()
if rpg == True :
 print ("This mode is not yet complete. It only contains a dungeon so far. I'm still working on the rest.")
#Dungeon
 whp = 100
 mahp = 100
 hhp = 100
 MHP = 10
 M = "fail"
 print ("You enter the dungeon")
 rm = raw_input ("There are three passages. Do you take the first one, the second one, or the third one?")
 if rm == 'one' :
  M = 'Troll'
  MHP = 80
  print ("A "+M+" appears!")
 if rm == 'two' :
  M = 'Goblin'
  MHP = 35
  print ("A "+M+" appears!")
 if rm == 'three' :
  M = 'Dragon'
  MHP = 120
  print ("A "+M+" appears!")
 while MHP > 0 :
  dgrnd ()

希望本文所述对大家的Python程序设计有所帮助。

Python 相关文章推荐
Python中dictionary items()系列函数的用法实例
Aug 21 Python
Python文件去除注释的方法
May 25 Python
Python中字典创建、遍历、添加等实用操作技巧合集
Jun 02 Python
python使用pil进行图像处理(等比例压缩、裁剪)实例代码
Dec 11 Python
python实现Adapter模式实例代码
Feb 09 Python
pandas将DataFrame的列变成行索引的方法
Apr 10 Python
Python判断是否json是否包含一个key的方法
Dec 31 Python
python 获取微信好友列表的方法(微信web)
Feb 21 Python
新手入门Python编程的8个实用建议
Jul 12 Python
Python绘制股票移动均线的实例
Aug 24 Python
python实现WebSocket服务端过程解析
Oct 18 Python
python中__slots__节约内存的具体做法
Jul 04 Python
python实现自动登录人人网并采集信息的方法
Jun 28 #Python
Python实现将绝对URL替换成相对URL的方法
Jun 28 #Python
python实现将html表格转换成CSV文件的方法
Jun 28 #Python
python实现根据主机名字获得所有ip地址的方法
Jun 28 #Python
python自动zip压缩目录的方法
Jun 28 #Python
python查找指定具有相同内容文件的方法
Jun 28 #Python
python中getaddrinfo()基本用法实例分析
Jun 28 #Python
You might like
php选择排序法实现数组排序实例分析
2015/02/16 PHP
Smarty实现页面静态化(生成HTML)的方法
2016/05/23 PHP
php redis实现文章发布系统(用户投票系统)
2017/03/04 PHP
php使用curl获取header检测开启GZip压缩的方法
2018/08/15 PHP
jquery的index方法实现tab效果
2011/02/16 Javascript
Prototype源码浅析 Enumerable部分之each方法
2012/01/16 Javascript
js报$ is not a function 的问题的解决方法
2014/01/20 Javascript
Jquery和angularjs获取check框选中的值的方法汇总
2016/01/17 Javascript
关于Javascript中defer和async的区别总结
2016/09/20 Javascript
angular+bootstrap的双向数据绑定实例
2017/03/03 Javascript
jQuery实现html table行Tr的复制、删除、计算功能
2017/07/10 jQuery
基于Bootstrap table组件实现多层表头的实例代码
2017/09/07 Javascript
JS实现模糊查询带下拉匹配效果
2018/06/21 Javascript
vue-cli初始化项目中使用less的方法
2018/08/09 Javascript
实现vuex与组件data之间的数据同步更新方式
2019/11/12 Javascript
原生JS与JQ获取元素的区别详解
2020/02/13 Javascript
[00:12]2018DOTA2亚洲邀请赛 Somnus丶M出阵单挑
2018/04/06 DOTA
python通过zlib实现压缩与解压字符串的方法
2014/11/19 Python
Python装饰器实现几类验证功能做法实例
2017/05/18 Python
python3 pillow生成简单验证码图片的示例
2017/09/19 Python
如何利用Python开发一个简单的猜数字游戏
2019/09/22 Python
TensorFlow 读取CSV数据的实例
2020/02/05 Python
美国韩国化妆品和护肤品购物网站:Beautytap
2018/07/29 全球购物
瑞典多品牌连锁店:Johnells
2021/01/13 全球购物
EJB的几种类型
2012/08/15 面试题
群众路线个人剖析材料
2014/10/07 职场文书
学术研讨会欢迎词
2015/01/26 职场文书
在职证明格式样本
2015/06/15 职场文书
村主任当选感言
2015/08/01 职场文书
值班管理制度范本
2015/08/06 职场文书
创业计划书之蛋糕店
2019/08/29 职场文书
Nginx访问日志及错误日志参数说明
2021/03/31 Servers
PHP设计模式(观察者模式)
2021/07/07 PHP
python​格式化字符串
2022/04/20 Python
vue ant design 封装弹窗表单的使用
2022/06/01 Vue.js
Redis批量生成数据的实现
2022/06/05 Redis