python三国杀

news/2024/11/30 12:45:23/

各位大佬好!

这是我第一次写问章,

有不足请多多指教。(毕竟我只是一名小学生)

一段python三国杀代码

import random
import time
import datetime
t=time
r=random
def hm(heart,cheart):print('你的血', heart)print('电脑的血', cheart)
def wx():bb=['无懈可击',' ',' ',' ',' ']bbb=r.choice(bb)if bbb=='无懈可击':return 1else:return 0sha=0
tao=0
shan=0
csha=0
ctao=0
cshan=0
flag=1
xpp='无'
je=r.randint(1000,10000)
#结束 炸弹丸 急救丸 激光 回春术
print('   制作:一只飞快的蛐蛐')
t.sleep(2)
print('loading...')
t.sleep(3)
print('欢迎来到三国杀')
t.sleep(1)
print('指令简介:')
t.sleep(0.5)
print('==================')
print('-指令:开始游戏   -')
print('-指令:查询版本   -')
print('-指令:退出       -')
print('==================')
t.sleep(0.5)
print('开始游戏吗? 开始游戏/不开始')
a=input()
while a!='开始游戏':if a=='退出':quit('欢迎下次再来!')if a=='不开始':print('开始游戏吗?请输入:')a = input()continuet.sleep(1)print('开始游戏吗?请输入:')a = input()
if a == '开始游戏':print('请选人物 赵云 马超 吕布 曹操 张飞')d=['赵云','马超','吕布','曹操','张飞']b=input()for i in range(20):if d[i]==b:d.pop(i)breakc=r.choice(d)corw=crw=bif b=='赵云' or b=='马超':heart=20print('【同等之战】')elif b=='吕布' or b=='曹操':heart=10print('【无限反击】')elif b=='张飞':heart = 1print('【绝地求生】')else:print('你不好好输入')print('人物默认为---(无名氏)')b='---'heart = 1print('【绝地求生】')t.sleep(1)jz=['coc','cocpp']ccard3=['桃','杀']card=[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ']ccard=[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ']cardr=['杀','桃','闪']ppcard=['顺手牵羊','火烧连营','空城计','万箭齐发','李代桃僵','久经沙场','决斗','草船借箭','无懈可击','无中生有']em=['剑','盾','弩','羽扇','火焰杀']cdw=['不朽青铜','不屈白银','荣耀星钻','无敌战神','必胜王牌','勇者巅峰','大师']for i in range(20):card[i]=r.choice(cardr)for i in range(20):ccard[i]=r.choice(cardr)for i in range(20):if card[i]=='杀':sha+=1if card[i]=='桃':tao+=1if card[i]=='闪':shan+=1for i in range(20):if ccard[i]=='杀':csha+=1if ccard[i]=='桃':ctao+=1if ccard[i]=='闪':cshan+=1cheart=20t.sleep(0.5)print('正在匹配中....')t.sleep(3)print('你的人物是',b)print('你的血量是',heart)print('你的卡牌是',card)print('                                    ')cdv=r.choice(cdw)print('电脑的人物是',c)print('电脑的血量是',cheart)t.sleep(2)y = '关闭'yocp = []z = '关闭'lfag = 0while cheart>0 and heart>0 :t.sleep(1)print('-===================== round', flag, '=======================-')if lfag!=flag:if (corw!='张飞' and rw!='张飞') and (rw=='曹操' or corw=='曹操'):print('曹操技能【吸血大王】')if rw=='曹操':heart+=2cheart-=1if corw=='曹操':cheart+=2heart-=1elif (corw=='张飞' or rw!='张飞') and (rw=='曹操' or corw=='曹操'):print('曹操技能【吸血大王】')print('张飞技能【坚不可摧】')if (rw=='马超' and corw=='吕布') or (corw=='马超' and rw=='吕布'):print('马超技能【长枪突刺】')if rw=='马超':cheart-=1else:heart-=1if rw=='赵云':print('赵云技能【举世无双】')if corw=='吕布':print('吕布技能【马中赤兔】')else:cheart-=2if corw=='赵云':print('赵云技能【举世无双】')if rw == '吕布':print('吕布技能【马中赤兔】')else:heart -= 2if cheart==0 and tao>0:bs=input('电脑濒死是/否救他?')if bs=='是':cheart+=1xp+=1tao-=1print('已救活')else:breakelif cheart<0:breakelif cheart<=0 and tao<=0:breakif heart==0 and tao>0:bs=input('你濒死是/否救自己?')if bs=='是':cheart+=1tao-=1print('已救活')else:breakelif heart<0:breakelif heart<=0 and tao<=0:breakprint('你的血', heart, '***----VS----***电脑的血', cheart)print('你的牌',sha,'【杀】',tao,'【桃】',shan,'【闪】')t.sleep(0.5)if y=='启动' and b<3 and lfag!=flag:cheart-=1print('【火烧连营】电脑减1血')hm(heart, cheart)b+=1if z=='启动' and c<3 and lfag!=flag:heart-=1print('【火烧连营】你减1血')hm(heart, cheart)c+=1t.sleep(1)if wx()==1:cms='有'else:cms='无'if len(yocp)<3 and lfag!=flag:yocpp = r.choice(ppcard)yocp.append(yocpp)print('你获得一张【', yocpp, '】')print('你的技能')print(yocp)nu=r.randint(1,20)boem='无'if nu>=5 and nu<=7:yoem = r.choice(em)print('你获得', yoem)print('输入【装备】使用')boem='有'print('你的回合:')lfag = flagyoc = input()if yoc!='杀' and yoc!='桃' and yoc!='闪' and yoc!='没牌了' and yoc!='结束' and yoc!='退出' and yoc not in yocp and yoc!='装备':print('错误重输!')continueif yoc == '杀' and sha==0:print('你没这张牌')continueif yoc == '桃' and tao==0:print('你没这张牌')continueif yoc == '闪':print('你不能直接出【闪】')continueif yoc == '装备':if boem=='有':if yoem=='盾':print('以装备使用')heart+=taoheart+=3tao=3hm(heart, cheart)boem='无'elif yoem=='剑':print('以装备使用')cheart-=shacheart-=3sha=3hm(heart, cheart)boem='无'elif yoem=='弩':print('以装备使用')print('你出几张【杀】?(最多不能超过',sha,')')qbg=int(input())if qbg<=sha:cheart-=qbgelse:cheart-=5hm(heart, cheart)boem = '无'elif yoem=='羽扇':print('以装备使用')if cheart>heart:ppf=heartheart=cheartcheart=ppfelse:heart+=5cheart-=2hm(heart, cheart)boem = '无'else:print('以装备使用')cheart-=3hm(heart, cheart)boem = '无'else:print('你没装备')continueif yoc == '退出':quit('欢迎下次再来!')if yoc == '没牌了':if sha==0 and tao==0:print('好的!')breakelse:print('你还有牌')continueif yoc=='顺手牵羊':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【顺手牵羊】')if cms=='有':print('电脑用【无懈可击】')cms='无'continueif ctao > 0 or csha > 0 or cshan > 0:if ctao <= 0:if csha <= 0:shan+=1cshan-=1print('你牵来了一张【闪】')hm(heart,cheart)else:sha+=1csha-=1print('你牵来了一张【杀】')hm(heart, cheart)elif ctao > 0:if csha > 0:if cshan > 0:adc = r.choice(cardr)if adc == '杀':sha += 1csha -= 1print('你牵来了一张【杀】')hm(heart, cheart)elif adc == '桃':tao += 1ctao -= 1print('你牵来了一张【桃】')hm(heart, cheart)else:shan += 1cshan -= 1print('你牵来了一张【闪】')hm(heart, cheart)else:adc = r.choice(ccard3)if adc == '杀':sha += 1csha -= 1print('你牵来了一张【杀】')hm(heart, cheart)elif adc == '桃':tao += 1ctao -= 1print('你牵来了一张【桃】')hm(heart, cheart)elif csha<=0:tao += 1ctao -= 1print('你牵来了一张【桃】')hm(heart, cheart)continueelif yoc=='火烧连营':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【火烧连营】')if cms=='有':print('电脑用【无懈可击】')cms='无'continuey='启动'b=0print('三回合内对手每回合减一血')t.sleep(0.5)hm(heart,cheart)elif yoc=='空城计':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【空城计】')if cms == '有':print('电脑用【无懈可击】')cms = '无'continueflag += 1t.sleep(0.5)yockcj=input('是否出【杀】?')if yockcj=='是':if rw=='吕布':cheart-=4else:cheart-=2print('你出【杀】电脑减二血')hm(heart,cheart)continueelse:kcj = input('是否出【桃】?')if kcj == '是':heart += 2print('你出【桃】你加二血')hm(heart, cheart)continueelse:print('好的!')continueelif yoc=='万箭齐发':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【万箭齐发】')if cms == '有':print('电脑用【无懈可击】')cms = '无'continuecheart-=cshacheart+=1t.sleep(0.5)hm(heart,cheart)elif yoc=='无懈可击':print('你无法在你的回合使用【无懈可击】')continueelif yoc=='李代桃僵':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【李代桃僵】')heart+=ctaoheart-=1t.sleep(0.5)hm(heart,cheart)elif yoc == '久经沙场':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【久经沙场】')if cms == '有':print('电脑用【无懈可击】')cms = '无'continueheart -= 3cheart -= 5t.sleep(0.5)hm(heart, cheart)elif yoc=='决斗':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【决斗】')if cms == '有':print('电脑用【无懈可击】')cms = '无'continueprint('你出【杀】还是【桃】?(【杀】有',sha,'张,【桃】有',tao,'张)')jd=input()if rw=='吕布':if jd=='杀'and sha>1:if csha>1:print('电脑也出【杀】')csha-=1sha-=1elif csha<=1:cheart-=2print('电脑没有【杀】')elif jd=='桃'and tao>0:if ctao>0 :print('电脑也出【桃】')ctao-=1tao-=1elif ctao <= 0:cheart-=2print('电脑没有【桃】')else:print('输入错误')print('无法使用【决斗】')print('【决斗】自动删除...')t.sleep(0.5)hm(heart,cheart)else:if jd=='杀'and sha>0:if csha>0:print('电脑也出【杀】')csha-=1sha-=1elif csha<=0:cheart-=1print('电脑没有【杀】')elif jd=='桃'and tao>0:if ctao>0 :print('电脑也出【桃】')ctao-=1tao-=1elif ctao <= 0:cheart-=2print('电脑没有【桃】')else:print('输入错误')print('无法使用【决斗】')print('【决斗】自动删除...')t.sleep(0.5)hm(heart,cheart)elif yoc == '草船借箭':for i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【草船借箭】')if cms == '有':print('电脑用【无懈可击】')cms = '无'continueccjj=csha+1print('你借来',ccjj,'张【杀】')sha+=cshasha+=1csha=5t.sleep(0.5)hm(heart, cheart)elif yoc=='无中生有':if len(yocp)>3:print('技能区已满无法使用【无中生有】')continuefor i in range(1000):if yocp[i]==yoc:yocp.pop(i)breakprint('你使用【无中生有】')yocpp = r.choice(ppcard)yocp.append(yocpp)print('你获得一张【', yocpp, '】')print('你的技能')print(yocp)t.sleep(0.5)hm(heart,cheart)continueif sha>0 or tao>0 or csha>0 or ctao>0:if yoc == '闪':print('在说一遍:你不能直接出【闪】')if yoc=='桃' and tao>0:tao -= 1heart+=1print('你出【桃】加一血')print('你的血',heart)print('电脑的血',cheart)print('继续')if yoc=='杀' and sha>0:sha -= 1s='无'for i in ccard:if i=='闪' and cshan>0:print('你出【杀】电脑出【闪】')s='有'cshan-=1breakif s!='有':if rw=='吕布':cheart-=2else:cheart-=1print('你出【杀】电脑减一血')print('你的血',heart)print('电脑的血',cheart)print('继续')t.sleep(1)print('你的血', heart, '***----VS----***电脑的血', cheart)t.sleep(0.5)if cheart<=0 or heart<=0:breakflag += 1print('电脑回合:')t.sleep(1)cboem = '无'if nu>=16 and nu<=18:coem=r.choice(em)print('电脑获得',coem)cboem='有'if cboem == '有':if coem == '盾':print('电脑使用装备【盾】')cheart += ctaocheart += 3ctao = 3hm(heart, cheart)cboem = '无'continueelif coem == '剑':print('电脑使用装备【剑】')heart -= cshaheart -= 3csha = 3hm(heart, cheart)cboem = '无'continueelif coem == '弩':print('电脑使用装备【弩】')heart -= cshahm(heart, cheart)boem = '无'continueelif coem == '羽扇':print('电脑使用装备【羽扇】')if heart > cheart:ppf = heartheart = cheartcheart = ppfelse:cheart += 5heart-=2hm(heart, cheart)boem = '无'continueelse:print('电脑使用装备【火焰杀】')heart -= 3hm(heart, cheart)boem = '无'continueh = r.choice(jz)if h == 'coc':if ctao > 0 or csha > 0:if ctao <= 0:coc = '杀'elif csha <= 0:coc = '桃'else:coc = r.choice(ccard3)else:cocpp = r.choice(ppcard)h = 'cocpp'else:cocpp = r.choice(ppcard)if h=='cocpp':if cocpp == '空城计':print('电脑使用【空城计】')t.sleep(0.5)if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinueif corw=='吕布':heart -= 4else:heart -= 2print('电脑出【杀】你减二血')hm(heart, cheart)elif cocpp == '顺手牵羊':print('电脑使用【顺手牵羊】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinueif tao > 0 or sha > 0 or shan > 0:if tao <= 0:if sha == 0:cshan += 1shan -= 1print('电脑牵了你一张【闪】')hm(heart, cheart)else:csha += 1sha -= 1print('电脑牵了你一张【杀】')hm(heart, cheart)elif tao > 0:if sha > 0:if shan > 0:adc = r.choice(cardr)if adc == '杀':csha += 1sha -= 1print('电脑牵了你一张【杀】')hm(heart, cheart)elif adc == '桃':ctao += 1tao -= 1print('电脑牵了你一张【桃】')hm(heart, cheart)else:cshan += 1shan -= 1print('电脑牵了你一张【闪】')hm(heart, cheart)else:adc = r.choice(ccard3)if adc == '杀':csha += 1sha -= 1print('电脑牵了你一张【杀】')hm(heart, cheart)elif adc == '桃':ctao += 1tao -= 1print('电脑牵了你一张【桃】')hm(heart, cheart)elif csha == 0:ctao += 1tao -= 1print('电脑牵了你一张【桃】')hm(heart, cheart)elif cocpp == '火烧连营':print('电脑使用【火烧连营】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinuez = '启动'c = 0t.sleep(0.5)hm(heart, cheart)elif cocpp == '万箭齐发':print('电脑使用【万箭齐发】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinueheart -= shaheart += 1t.sleep(0.5)hm(heart, cheart)elif cocpp == '李代桃僵':print('电脑使用【李代桃僵】')cheart += taocheart -= 1t.sleep(0.5)hm(heart, cheart)elif cocpp == '久经沙场':print('电脑使用【久经沙场】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinuecheart -= 3heart -= 5t.sleep(0.5)hm(heart, cheart)elif cocpp == '决斗':print('电脑使用【决斗】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinueif csha>0:print('电脑出【杀】')jc='杀'else:print('电脑出【桃】')jc='桃'if corw=='吕布' and sha>1:print('你出 2 张【杀】还是【桃】?(【杀】有',sha,'张,【桃】有',tao,'张)')jd=input()elif corw!='吕布' and sha>0:print('你出【杀】还是【桃】?(【杀】有', sha, '张,【桃】有', tao, '张)')jd = input()elif sha<=0:print('你无法出杀')jd = '无'if jc == '杀':if jd != '杀':print('你没出【杀】')if corw=='吕布':csha -= 1heart-=4else:csha -= 1heart-=2else:if corw=='吕布':csha -= 1sha -= 2else:csha -= 1sha -= 1print('你出【杀】')elif jc == '桃':if jd != '桃':print('你没出【桃】')ctao -= 1heart -= 2else:ctao -= 1tao -= 1print('你出【桃】')else:print('输入错误')heart-=2t.sleep(0.5)hm(heart, cheart)elif cocpp=='草船借箭':print('电脑使用【草船借箭】')if '无懈可击' in yocp:print('你使用【无懈可击】')for i in range(1000):if yocp[i] == '无懈可击':yocp.pop(i)breakcontinueccjj=sha + 1print('电脑借来',ccjj,'张【杀】')csha+=cshacsha+=1sha=5t.sleep(0.5)hm(heart, cheart)if h == 'coc':if coc=='桃' and ctao>0:cheart += 1ctao-=1print('电脑出【桃】加一血')print('你的血',heart)print('电脑的血',cheart)print('继续')if coc=='杀' and csha>0:x='0'csha-=1for i in card:if i=='闪' and shan>0:x=input('电脑出【杀】你是否出【闪】')breakif x=='是':shan-=1print('你出【闪】躲避电脑')print('你的血',heart)print('电脑的血',cheart)print('继续')elif x=='否':if corw=='吕布':heart-=2else:heart-=1print('你没出【闪】减一血')print('你的血',heart)print('电脑的血',cheart)print('继续')elif x=='0':heart-=1print('电脑出【杀】你没有【闪】')print('减一血')print('你的血', heart)print('电脑的血', cheart)else:if corw == '吕布':heart -= 2else:heart -= 1print('电脑出【杀】你没有【闪】')print('减一血')print('你的血', heart)print('电脑的血', cheart)elif sha<=0 and tao<=0 and shan<=0:print('你/电脑没牌了')if heart<cheart:quit('游戏结束,你输了')elif heart>cheart:quit('游戏结束,你赢了')elif heart==cheart:print('游戏结束,平局')quit()if sha<=0 and tao<=0:print('你/电脑没牌了')if heart<cheart:print('游戏结束,你输了')quit()elif heart>cheart:print('游戏结束,你赢了')quit()elif heart==cheart:print('游戏结束,平局')quit()if heart<=0 and cheart!=0:print('游戏结束,你输了')quit()elif heart!=0 and cheart<=0:print('游戏结束,你赢了')quit()elif heart<=0 and cheart<=0:print('游戏结束,平局')quit()quit('好吧,下次再玩!')

 代码水平不高,请多多指教。


http://www.ppmy.cn/news/543147.html

相关文章

三国杀ol服务器维护时间 11月6日,《三国杀OL》停运通知

尊敬的九游《三国杀OL》游戏玩家们&#xff1a; 九游《三国杀OL》游戏从测试开始便一直受到广大玩家的支持和喜爱&#xff0c;一点一滴筑造起来的游戏世界给予我们心里的温馨和欢乐。每一次的更新&#xff0c;都牵动着我们的心扉&#xff1b;每一次的活动&#xff0c;都激扬着我…

三国杀C++源代码

话不多说&#xff0c;也是直接上代码&#xff01; #include<iostream> #include<time.h> #include<stdio.h> #include <stdlib.h> using namespace std; struct pai {int paifu;int huase;int yanse;int dianshu;int leixing;int changdu;void Kanpai…

计算机读光盘出现乱码,解决刻录音乐光盘mp3出现中文乱码的方法

图片&#xff1a; 图片&#xff1a; 图片&#xff1a; 图片&#xff1a; 图片&#xff1a; 1.目前&#xff0c;很多人自己刻录音乐光盘以便在车载播放器里播放&#xff0c;但往往刻录出来的CD光盘会显示乱码&#xff0c;导致播放出来的音乐看不到是什么歌名和哪个歌手唱的。用n…

c语言三国杀,C++版三国杀.doc

C版三国杀 C版三国杀 全文一共2489行&#xff0c;7093个字符&#xff0c;包括main函数在内一共引用33个函数。经过初步检验&#xff0c;程序可以运行&#xff0c;有兴趣的人可以运行一下。此版本为人机对战&#xff0c;2人局&#xff0c;无武将&#xff0c;无性别&#xff0c;标…

c 语言的三国杀代码大全,三国杀语音代码大全

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 子建…子建… {3:44:1}有埋伏…啊&#xff01;&#xff01; {3:45:1}汉室衰弱&#xff0c;非我一人之罪 {3:46:1}大王&#xff0c;我先走一步了 {3:47:1}七纵之恩&#xff0c;来世再报了 {3:48:1}我的时辰&#xff0c;也到了 {3:4…

JAVA小型三国杀的制作_1

import java.util.Scanner; public class MainSGS { /** * param args */ /* * 主函数&#xff0c;程序的入口 */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("欢迎来到炒鸡三国杀"); System.out.println(&qu…

iOS 三国杀 Ver.LOG

MOSAD hw1 代码概况 父类 父类属性/方法类型/返回类型描述countryString国家blood_valueNS整形血量energy_valueNS整形法力值attackNS整形攻击力nameString名字armedNS整形是否装备武器flexNS整形是否在闪避状态poisonNS整形是否中毒sheldNS整形是否施加钝化grandNS整形是否进…

三国杀ol服务器维修中,三国杀OL登录不了

2009-11-13 首次玩三国杀OL遇到些问题&#xff01;1. 1 人物头像左下有一个面具&#xff0c;点击之后就可以看你的身份了。 同样&#xff0c;在与你同时游戏的其他人头像旁边也有一个脸谱面具&#xff0c;除了主公以外(因为人家已经确定了嘛)&#xff0c;其他人的你点击之后都可…