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用QQ邮箱发送邮件时授权码的问题
Jan 29 Python
python使用ddt过程中遇到的问题及解决方案【推荐】
Oct 29 Python
Python字符串内置函数功能与用法总结
Apr 16 Python
Django ORM 查询管理器源码解析
Aug 05 Python
python读取大文件越来越慢的原因与解决
Aug 08 Python
python实现批量修改服务器密码的方法
Aug 13 Python
在Python中通过threshold创建mask方式
Feb 19 Python
使用python创建生成动态链接库dll的方法
May 09 Python
python使用Word2Vec进行情感分析解析
Jul 31 Python
python实现视频压缩功能
Dec 18 Python
python Zmail模块简介与使用示例
Dec 19 Python
matplotlib 范围选区(SpanSelector)的使用
Feb 24 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
phpMyAdmin 安装教程全攻略
2007/03/19 PHP
php单例模式实现(对象只被创建一次)
2012/12/05 PHP
php旋转图片90度的方法
2013/11/07 PHP
php使用redis的有序集合zset实现延迟队列应用示例
2020/02/20 PHP
浅析Prototype的模板类 Template
2011/12/07 Javascript
jquery阻止冒泡事件使用模拟事件
2013/09/06 Javascript
js+csss实现的一个带复选框的下拉框
2014/09/29 Javascript
JS实现仿雅虎首页快捷登录入口及导航模块效果
2015/09/19 Javascript
JS实现网页标题栏显示当前时间和日期的完整代码
2015/11/02 Javascript
JavaScript+canvas实现七色板效果实例
2016/02/18 Javascript
js原生实现移动端手指滑动轮播图效果的示例
2018/01/02 Javascript
LayUi中接口传数据成功,表格不显示数据的解决方法
2018/08/19 Javascript
JavaScript设计模式之责任链模式实例分析
2019/01/16 Javascript
Python操作列表的常用方法分享
2014/02/13 Python
Python常用正则表达式符号浅析
2014/08/13 Python
python自动化测试实例解析
2014/09/28 Python
python通过字典dict判断指定键值是否存在的方法
2015/03/21 Python
python使用wmi模块获取windows下的系统信息 监控系统
2015/10/27 Python
解决python3捕获cx_oracle抛出的异常错误问题
2018/10/18 Python
python实现LRU热点缓存及原理
2019/10/29 Python
python 使用opencv 把视频分割成图片示例
2019/12/12 Python
Pytorch 搭建分类回归神经网络并用GPU进行加速的例子
2020/01/09 Python
python 数据分析实现长宽格式的转换
2020/05/18 Python
Python unittest如何生成HTMLTestRunner模块
2020/09/08 Python
基于python实现监听Rabbitmq系统日志代码示例
2020/11/28 Python
使用tkinter实现三子棋游戏
2021/02/25 Python
CSS3中的content属性使用示例
2015/07/20 HTML / CSS
介绍一下如何优化MySql
2016/12/20 面试题
2014年高考决心书
2014/03/11 职场文书
诚信贷款承诺书
2014/05/30 职场文书
五一口号
2014/06/19 职场文书
mysql多表查询-笔记七
2021/04/05 MySQL
Python中常见的导入方式总结
2021/05/06 Python
Pandas自定义选项option设置
2021/07/25 Python
python人工智能human learn绘图可创建机器学习模型
2021/11/23 Python
Java中生成微信小程序太阳码的实现方案
2022/06/01 Java/Android