crack game 猜数字游戏 from 许添翼's blog

正在学习Python来着,我捏download 了一个许添翼做的Python GUI(tkinter)游戏呢来着,太难,我便修改了它来着,希望有人喜欢来着,哈~!
    FROM 许添翼's blog

# -*- coding: utf-8 -*-
import tkinter as tk
import sys
import random
import re

number = random.randint(0,1024)
running = True
num = 0
nmaxn = 1024
nminn = 0
def eBtnReset(event):
    global number
    number = random.randint(0,1024)
    global nmaxn
    nmaxn = 1024
    global nminn
    nminn = 0
    global num
    num = 0
    labelqval("请输入0到1024之间任意整数:")
def eBtnClose(event):
    root.destroy()
    
def eBtnGuess(event):
    global nmaxn
    global nminn
    global num
    val_a = int(entry_a.get())
    entry_a['show']=''
    if val_a == number:
        labelqval("恭喜答对了!")
        num+=1
        running = False
        numGuess()
    elif val_a == 67132455:
       labelqval("number was filled")
       e.set(str(number))
       num=0
       entry_a['show']='·'
    #this is how we cheat
    elif val_a < number:
        if val_a > nminn:
            nminn = val_a
            num+=1
            label_tip_min.config(label_tip_min,text=nminn)
        labelqval("小了哦,tip:center="+str((nmaxn+nminn)/2))
    else:
        if val_a < nmaxn:
            nmaxn = val_a
            num+=1
            label_tip_max.config(label_tip_max,text=nmaxn)
        labelqval("大了哦,tip:center="+str((nmaxn+nminn)/2))

def numGuess():
    if num == 1:
        labelqval('我靠!一次答对!')
    elif num < 11:
        labelqval('= =十一次以内就答对了牛逼。。。尝试次数:'+str(num))
    elif num < 50:
        labelqval('还行哦尝试次数:'+str(num))
    else:
        labelqval('好吧。。。。。您都试了超过50次了。。。。尝试次数:'+str(num))
        
def labelqval(vText):
    label_val_q.config(label_val_q,text=vText)   
   
root = tk.Tk(className="比大小游戏(ADDITIONAL){修改版}")
root.geometry("400x90+200+200")
e = tk.StringVar()
line_a_tip = tk.Frame(root)
label_tip_max = tk.Label(line_a_tip,text=nmaxn)
label_tip_min = tk.Label(line_a_tip,text=nminn)
label_tip_max.pack(side = "top",fill = "x")
label_tip_min.pack(side = "bottom",fill = "x")
line_a_tip.pack(side = "left",fill = "y")

line_question = tk.Frame(root)
label_val_q = tk.Label(line_question,width="80")
label_val_q.pack(side = "left")
line_question.pack(side = "top",fill = "x")

line_input = tk.Frame(root)
entry_a = tk.Entry(line_input,width="40",textvariable = e)
btnGuess = tk.Button(line_input,text="猜")
entry_a.pack(side = "left")
entry_a.bind('<Return>',eBtnGuess)
btnGuess.bind('<Button-1>',eBtnGuess)
btnGuess.pack(side = "left")
line_input.pack(side = "top",fill = "x")


line_btn = tk.Frame(root)
btnClose = tk.Button(line_btn,text="关闭")
btnClose.bind('<Button-1>',eBtnClose)
btnClose.pack(side="left")
line_btn.pack(side = "top")

line_x = tk.Frame(root)
btnReset = tk.Button(line_x,text="重设(不可用)",bg="#ffaaaa",fg="blue")
btnReset.bind('<Button-1>',eBtnReset)
btnReset.pack(side="left")
line_x.pack(side="top")

labelqval("请输入0到1024之间任意整数:")
entry_a.focus_set()

root.mainloop()
输入67132455就可以BT滴享受作弊的威力了哈~!

你可能感兴趣的:(游戏,python,作弊)