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使用ntplib库同步校准当地时间的方法
Jul 02 Python
一个基于flask的web应用诞生 组织结构调整(7)
Apr 11 Python
Python实现自动上京东抢手机
Feb 06 Python
python 字符串和整数的转换方法
Jun 25 Python
Python基于plotly模块实现的画图操作示例
Jan 23 Python
Python后台管理员管理前台会员信息的讲解
Jan 28 Python
pycharm 安装JPype的教程
Aug 08 Python
tensorflow 查看梯度方式
Feb 04 Python
Python基础之列表常见操作经典实例详解
Feb 26 Python
TensorFlow实现模型断点训练,checkpoint模型载入方式
May 26 Python
pytorch中Schedule与warmup_steps的用法说明
May 24 Python
Python极值整数的边界探讨分析
Sep 15 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
?繁体转换的class
2006/10/09 PHP
mysql 的 like 问题,超强毕杀记!!!
2007/01/18 PHP
Ajax+PHP实现的分类列表框功能示例
2019/02/11 PHP
js表格分页实现代码
2009/09/18 Javascript
基于jquery的textarea发布框限制文字字数输入(添加中文识别)
2012/02/16 Javascript
在每个匹配元素的外部插入新元素的方法
2013/12/20 Javascript
JavaScript拆分字符串时产生空字符的解决方案
2014/09/26 Javascript
jQuery源码解读之hasClass()方法分析
2015/02/20 Javascript
JavaScript原生对象之Number对象的属性和方法详解
2015/03/13 Javascript
JavaScript数组方法总结分析
2016/05/06 Javascript
JS本地刷新返回上一页代码
2016/07/25 Javascript
Node.js Sequelize如何实现数据库的读写分离
2016/10/23 Javascript
bootstrap基础知识学习笔记
2016/11/02 Javascript
JS实现上传图片实时预览功能
2017/05/22 Javascript
清空元素html("") innerHTML="" 与 empty()的区别和应用(推荐)
2017/08/14 Javascript
Three.js利用Detector.js插件如何实现兼容性检测详解
2017/09/26 Javascript
浅谈Vue.js中ref ($refs)用法举例总结
2017/12/19 Javascript
原生JavaScript实现todolist功能
2018/03/02 Javascript
微信web端后退强制刷新功能的实现代码
2018/03/04 Javascript
详解vue在项目中使用百度地图
2019/03/26 Javascript
p5.js临摹动态图形的方法
2019/10/23 Javascript
vue(2.x,3.0)配置跨域代理
2019/11/27 Javascript
[44:21]Ti4 循环赛第四日 附加赛NEWBEE vs LGD
2014/07/13 DOTA
python常见的格式化输出小结
2016/12/15 Python
pygame实现简易飞机大战
2018/09/11 Python
解决Mac下首次安装pycharm无project interpreter的问题
2018/10/29 Python
Python 实现两个列表里元素对应相乘的方法
2018/11/14 Python
python字典嵌套字典的情况下找到某个key的value详解
2019/07/10 Python
对python中assert、isinstance的用法详解
2019/11/27 Python
Python实现桌面翻译工具【新手必学】
2020/02/12 Python
python3 简单实现组合设计模式
2020/07/02 Python
小学三八妇女节活动方案
2014/03/16 职场文书
爱心捐助倡议书
2014/05/19 职场文书
2014年高中班主任工作总结
2014/11/08 职场文书
中学社团活动总结
2015/05/07 职场文书
高中班主任工作总结(范文)
2019/08/20 职场文书