三国志战略版抽卡模拟器,python tkinter库,计算你的欧非程度
#!/usr/bin/python3 # -*- coding: utf-8 -*- import random from tkinter import * from tkinter import messagebox from PIL import Image cheng=["刘备","关羽","张飞","曹操","孙权","孙策","曹植","王平","庞德","祝融夫人","邓艾", "典韦","贾诩","司马懿","张辽","庞统","马超","诸葛亮","孙尚香","张肱","张昭","陆逊", "袁绍","袁术","孟获","于吉","董卓","吕布","陈群","许褚","张郃","郝昭","曹仁", "甄姬","程昱","荀彧","荀攸","徐晃","夏侯惇","钟会","严颜","关银屏","马云禄","陈到", "姜维","黄忠","赵云","凌统","鲁肃","甘宁","周泰","吕蒙","太史慈","孙坚","陆抗", "周瑜","田丰","吕玲绮","兀突骨","公孙瓒","张角","曹纯","于禁","乐进","邓艾","夏侯渊", "郭嘉","蒋琬","徐庶","黄盖","程普","孙策","高岚","木鹿大王","李儒","高顺","马腾", "文丑","华雄","颜良","华佗","左慈","曹丕","张姬","黄月英","法正","大乔","貂蝉", "陈宫","司马徽","张春华","小乔","蔡文姬"] def card(): global num,rac_orange rac_puple=0.3 rac_blue=1-rac_orange-rac_puple if num==30: y=random.randint(0,len(cheng)-1) print("出橙: {}".format(cheng[y])) num=0 return cheng[y] x=random.randint(0,1000) if x<=rac_orange*1000: y=random.randint(0,len(cheng)-1) print("出橙: {}".format(cheng[y])) num=0 return cheng[y] elif x<=rac_puple*1000: print("出紫") num+=1 return 1 else: print("出蓝") num+=1 return 0 def tongji(): global num,n1,n2,n3,chucheng content="" for item in chucheng:content=content+item+"," content=content[:-1] label_num_1 = Label(root,text="共计出橙{}次".format(n1)).place(x=30,y=190) label_num_2 = Label(root,text="共计出紫{}次".format(n2)).place(x=30,y=210) label_num_3 = Label(root,text="共计出蓝{}次".format(n3)).place(x=30,y=230) label_num_4 = Label(root,text="还有{}次保底".format(30-num)).place(x=30,y=260) label_num_5 = Label(root,text="当前出橙:{}".format(content),wraplength=700).place(x=30,y=290) def on_click_1(): global num,n1,n2,n3,chucheng n=1 for i in range(n): z=card() if z==1:n2+=1 elif z==0:n3+=1 else: n1+=1 chucheng.append(z) tongji() def on_click_2(): global num,n1,n2,n3,chucheng n=10 for i in range(n): z=card() if z==1:n2+=1 elif z==0:n3+=1 else: n1+=1 chucheng.append(z) tongji() def on_click_3(): global num,n1,n2,n3,chucheng n=100 for i in range(n): z=card() if z==1:n2+=1 elif z==0:n3+=1 else: n1+=1 chucheng.append(z) tongji() def do_job1(): global var var=StringVar() r1 = Radiobutton(root, text='A:', variable=var, value='1').place(x=30,y=80)#单选框 label1 = Label(root,text="3%").place(x=80,y=80) r2 = Radiobutton(root, text='B:', variable=var, value='2').place(x=30,y=100) label2 = Label(root,text="5.6%").place(x=80,y=100) r3 = Radiobutton(root, text='C:', variable=var, value='3').place(x=30,y=120) label3 = Label(root,text="10%").place(x=80,y=120) r4 = Radiobutton(root, text='D:', variable=var, value='4').place(x=30,y=140) label4 = Label(root,text="20%").place(x=80,y=140) button = Button(root,text='确定',command=do_job4) button.place(x=30,y=160) def do_job2(): global num num=0 messagebox.showinfo(title='提示',message='保底已重置') def do_job4(): global var,rac_orange if var.get()=='1':rac_orange=0.03 elif var.get()=='2':rac_orange=0.056 elif var.get()=='3':rac_orange=0.1 elif var.get()=='4':rac_orange=0.2 else:rac_orange=0.03 messagebox.showinfo(title='提示',message='当前出橙概率:'+str(rac_orange)) def do_job3(): global n1,n2,n3,chucheng space=" "*1000 n1=n2=n3=0 chucheng=[] label_num_6 = Label(root,text=space).place(x=30,y=190) label_num_7 = Label(root,text=space).place(x=30,y=210) label_num_8 = Label(root,text=space).place(x=30,y=230) label_num_9 = Label(root,text=space,wraplength=700).place(x=30,y=290) label_num_4 = Label(root,text="还有{}次保底".format(30)).place(x=30,y=260) tongji() messagebox.showinfo(title='提示',message='计数已重置') if __name__=="__main__": global num,n1,n2,n3,chucheng,rac_orange num=n1=n2=n3=0 chucheng=[] rac_orange=0.03 root=Tk(className='三国志战略版抽卡模拟器')#程序窗口名称 root.geometry('800x400')#程序窗口大小 menu1=Menu(root)#主窗口 filemenu1=Menu(menu1,tearoff=0)#子窗口1 menu1.add_cascade(label='→菜单←',menu=filemenu1) filemenu1.add_command(label='出橙概率', command=do_job1)#label是名称,command是函数名称 filemenu1.add_command(label='重置保底', command=do_job2) filemenu1.add_command(label='重置计数', command=do_job3) root.config(menu=menu1) label=Label(root,text='点击开始抽卡',bg='orange') label.pack() button1 = Button(root,text='抽一次',command=on_click_1) button1.place(x=300,y=30) button2 = Button(root,text='抽十次',command=on_click_2) button2.place(x=360,y=30) button3 = Button(root,text='抽一百次',command=on_click_3) button3.place(x=420,y=30) mainloop()
仅供娱乐,哈哈