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 相关文章推荐
win7上python2.7连接mysql数据库的方法
Jan 14 Python
Python cookbook(数据结构与算法)实现查找两个字典相同点的方法
Feb 18 Python
浅谈Django中的数据库模型类-models.py(一对一的关系)
May 30 Python
详解Python安装scrapy的正确姿势
Jun 26 Python
Flask框架工厂函数用法实例分析
May 25 Python
Flask-WTF表单的使用方法
Jul 12 Python
python自动化UI工具发送QQ消息的实例
Aug 27 Python
python下载库的步骤方法
Oct 12 Python
Python with关键字,上下文管理器,@contextmanager文件操作示例
Oct 17 Python
利用python进行文件操作
Dec 04 Python
Keras保存模型并载入模型继续训练的实现
Feb 20 Python
python自动化测试之Selenium详解
Mar 13 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 is_dir() 判断给定文件名是否是一个目录
2010/05/10 PHP
PHP简洁函数小结
2011/08/12 PHP
windows的文件系统机制引发的PHP路径爆破问题分析
2014/07/28 PHP
PHP构造函数与析构函数用法示例
2016/09/28 PHP
详解PHP原生DOM对象操作XML的方法
2016/10/17 PHP
php读取qqwry.dat ip地址定位文件的类实例代码
2016/11/15 PHP
解决form中action属性后面?传递参数 获取不到的问题
2017/07/21 PHP
在JavaScript中,为什么要尽可能使用局部变量?
2009/04/06 Javascript
javascript下判断一个对象是否具有指定名称的属性的的代码
2010/01/11 Javascript
javascript之Partial Application学习
2013/01/10 Javascript
Javascript 多浏览器兼容总结(实战经验)
2013/10/30 Javascript
jQuery之Deferred对象详解
2014/09/04 Javascript
z-blog SyntaxHighlighter 长代码无法换行解决办法(jquery)
2014/11/16 Javascript
基于Bootstrap里面的Button dropdown打造自定义select
2016/05/30 Javascript
JavaScript实战之菜单特效
2016/08/16 Javascript
详解vue axios二次封装
2018/07/22 Javascript
详解新手使用vue-router传参时注意事项
2019/06/06 Javascript
javascript获取select值的方法完整实例
2019/06/20 Javascript
javascript自定义加载loading效果
2020/09/15 Javascript
python中查找excel某一列的重复数据 剔除之后打印
2013/02/10 Python
Python中import导入上一级目录模块及循环import问题的解决
2016/06/04 Python
Python+Selenium自动化实现分页(pagination)处理
2017/03/31 Python
Diango + uwsgi + nginx项目部署的全过程(可外网访问)
2018/04/22 Python
django+echart绘制曲线图的方法示例
2018/11/26 Python
pip安装tensorflow的坑的解决
2020/04/19 Python
python3访问字典里的值实例方法
2020/11/18 Python
pycharm 2020.2.4 pip install Flask 报错 Error:Non-zero exit code的问题
2020/12/04 Python
一个不错的HTML5 Canvas多层点击事件监听实例
2014/04/29 HTML / CSS
美国儿童珠宝在线零售商:Loveivy
2019/05/22 全球购物
英语专业毕业生自荐信范文
2013/12/31 职场文书
电子工程专业毕业生求职信
2014/03/14 职场文书
建筑安全标语
2014/06/07 职场文书
华清池导游词
2015/02/02 职场文书
2015年科研工作总结范文
2015/05/13 职场文书
MySQL 存储过程的优缺点分析
2021/05/20 MySQL
PHP面试题 wakeup魔法 Ezpop pop序列化与反序列化
2022/04/11 PHP