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 logging 日志轮转文件不删除问题的解决方法
Aug 02 Python
如何在Python函数执行前后增加额外的行为
Oct 20 Python
python运行其他程序的实现方法
Jul 14 Python
python实现淘宝秒杀脚本
Jun 23 Python
python threading和multiprocessing模块基本用法实例分析
Jul 25 Python
Python爬虫图片懒加载技术 selenium和PhantomJS解析
Sep 18 Python
Python dict和defaultdict使用实例解析
Mar 12 Python
tensorflow常用函数API介绍
Apr 19 Python
python实例化对象的具体方法
Jun 17 Python
python编写实现抽奖器
Sep 10 Python
python 实现客户端与服务端的通信
Dec 23 Python
Python使用Web框架Flask开发项目
Jun 01 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
把1316这个数表示成两个数的和,其中一个为13的倍数,另一个是11的倍数,求这两个数。
2011/06/24 PHP
php采集自中央气象台范围覆盖全国的天气预报代码实例
2015/01/04 PHP
JavaScript的eval JSON object问题
2009/11/15 Javascript
JS清除IE浏览器缓存的方法
2013/07/26 Javascript
js实现兼容IE和FF的上下层的移动
2015/05/04 Javascript
整理AngularJS中的一些常用指令
2015/06/16 Javascript
点评js异步加载的4种方式
2015/12/22 Javascript
如何给ss bash 写一个 WEB 端查看流量的页面
2017/03/23 Javascript
vue引入jq插件的实例讲解
2017/09/12 Javascript
使用vuex的state状态对象的5种方式
2018/04/19 Javascript
基于Bootstrap下拉框插件bootstrap-select使用方法详解
2018/08/07 Javascript
element-ui上传一张图片后隐藏上传按钮功能
2019/05/22 Javascript
Vue函数式组件的应用实例详解
2019/08/30 Javascript
基于JS实现父组件的请求服务过程解析
2019/10/14 Javascript
高性能js数组去重(12种方法,史上最全)
2019/12/21 Javascript
[03:09]2014DOTA2国际邀请赛 Mushi前队友送上祝福
2014/07/12 DOTA
python双向链表实现实例代码
2013/11/21 Python
Python SQLAlchemy基本操作和常用技巧(包含大量实例,非常好)
2014/05/06 Python
Python实现读取邮箱中的邮件功能示例【含文本及附件】
2017/08/05 Python
Django视图和URL配置详解
2018/01/31 Python
Centos部署django服务nginx+uwsgi的方法
2019/01/02 Python
python3.x实现base64加密和解密
2019/03/28 Python
详解PyCharm安装MicroPython插件的教程
2019/06/24 Python
Python3 中sorted() 函数的用法
2020/03/24 Python
python opencv把一张图片嵌入(叠加)到另一张图片上的实现代码
2020/06/11 Python
python 发送get请求接口详解
2020/11/17 Python
单位门卫岗位职责
2013/12/20 职场文书
护士的自我鉴定
2014/02/07 职场文书
求职信模板标准格式范文
2014/02/23 职场文书
竞选学生会主席演讲稿
2014/04/24 职场文书
企业安全生产责任书范本
2014/07/28 职场文书
写作技巧:如何撰写一份优秀的营销策划书
2019/08/13 职场文书
浅谈Python3中datetime不同时区转换介绍与踩坑
2021/08/02 Python
面试分析分布式架构Redis热点key大Value解决方案
2022/03/13 Redis
Python中time标准库的使用教程
2022/04/13 Python
MySQL8.0 Undo Tablespace管理详解
2022/06/16 MySQL