-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d5fb491
Showing
8 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# vsc | ||
.vscode/ | ||
|
||
# Windows: | ||
Thumbs.db | ||
ehthumbs.db | ||
Desktop.ini | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"comment": "The language file of PI terminator", | ||
"version": "1.0.4", | ||
|
||
"gui": { | ||
"title.1": "PI Terminator", | ||
"title.2": "PI Terminator (Score: {} point)", | ||
"menubar.help": "Help", | ||
"menubar.help.about": "About", | ||
"menubar.help.version": "Version", | ||
"text.question": "{} * 3.14 = ?", | ||
"button.i_finish": "I finish it" | ||
}, | ||
"message": { | ||
"right": { | ||
"msg1.title": "You're right", | ||
"msg1.text": "You're right, plus ont point!\nScore: {} point", | ||
|
||
"msg2.title": "Next", | ||
"msg2.text": "Next question!" | ||
}, | ||
"wrong": { | ||
"msg3.title": "Don't be too casual!", | ||
"msg3.text": "Answer the questions well and don't leave them empty.", | ||
|
||
"msg4.title": "The result of {} * 3.14", | ||
"msg4.text": "You're wrong, The correct answer is: {}.\nDeduct one point! Score: {} points", | ||
|
||
"msg5.title": "Just to remind you again..", | ||
"msg5.text": "You're wrong. The correct answer is: {}. Recite it." | ||
}, | ||
"menubar": { | ||
"msg6.title": "About \"PI Terminator\"", | ||
"msg6.text": "author: Doushabao\nI spent lots of effort on this program. I hope you like it!", | ||
|
||
"msg7.title": "PI Terminator - version", | ||
"msg7.text": "You are using version {}.\nThe version number of the language file matches the version number of this program. When it does not match, an error message will be automatically reported." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"comment": "每个人有毛毛的语言文件!!!!", | ||
"version": "1.0.4", | ||
|
||
"gui": { | ||
"title.1": "每个人的身上都有毛毛", | ||
"title.2": "每个人的身上都有毛毛 目前分数{}分", | ||
"menubar.help": "我咋不懂呢", | ||
"menubar.help.about": "你是什么垃圾", | ||
"menubar.help.version": "啥时候发的版本啊", | ||
"text.question": "{}拍=?", | ||
"button.i_finish": "赶紧提交啊啊啊" | ||
}, | ||
"message": { | ||
"right": { | ||
"msg1.title": "对咯!", | ||
"msg1.text": "真不错,我妈妈很帅,好了不说了,你答对了。\nScOre{}", | ||
|
||
"msg2.title": "You know the rules..", | ||
"msg2.text": "AND SO DO I" | ||
}, | ||
"wrong": { | ||
"msg3.title": "干啥呢!", | ||
"msg3.text": "好好做题,不要空着! A FULL COMMITS WHAT IM THINKING OF LOVE~", | ||
|
||
"msg4.title": "{}pai的结果", | ||
"msg4.text": "You wouldnt get this FROM ANY OTHER GUY!!\n答案错误,正确答案是{}。\n扣一分!目前分数:{}分", | ||
|
||
"msg5.title": "IIIIIIIIIIIIII JUST WANNA tell u how im felling…", | ||
"msg5.text": "答案错误。正确答案是:{},背下来吧。Gotta make U understand" | ||
}, | ||
"menubar": { | ||
"msg6.title": "破关于页面!!!!!", | ||
"msg6.text": "豆沙包做的!!\n我做这个程序费了很多心血!!你必须给我喜欢!!", | ||
|
||
"msg7.title": "啥时候发的版本????", | ||
"msg7.text": "{}!哈哈!猜猜是什么意思?\n语言文件的版本号和程序版本是匹配的!!记住!!当不匹配时,会爆炸!!小心小心,哈哈!!" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"comment": "圆周率终结者的语言文件", | ||
"version": "1.0.4", | ||
|
||
"gui": { | ||
"title.1": "圆周率终结者", | ||
"title.2": "圆周率终结者 目前分数{}分", | ||
"menubar.help": "帮助", | ||
"menubar.help.about": "关于", | ||
"menubar.help.version": "版本号", | ||
"text.question": "{}pai=?", | ||
"button.i_finish": "我做完了( ̄▽ ̄)" | ||
}, | ||
"message": { | ||
"right": { | ||
"msg1.title": "正确", | ||
"msg1.text": "答题正确!加一分!\n目前分数:{}分", | ||
|
||
"msg2.title": "继续", | ||
"msg2.text": "下一题!" | ||
}, | ||
"wrong": { | ||
"msg3.title": "干啥呢!", | ||
"msg3.text": "好好做题,不要空着!", | ||
|
||
"msg4.title": "{}pai的结果", | ||
"msg4.text": "答案错误,正确答案是{}。\n扣一分!目前分数:{}分", | ||
|
||
"msg5.title": "再强调一遍…", | ||
"msg5.text": "答案错误。正确答案是:{},背下来吧。" | ||
}, | ||
"menubar": { | ||
"msg6.title": "关于圆周率终结者", | ||
"msg6.text": "制作:豆沙包\n我做这个程序费了很多心血,希望你喜欢~", | ||
|
||
"msg7.title": "圆周率终结者 - 版本号", | ||
"msg7.text": "你目前使用的版本是{}\n语言文件的版本号匹配程序的版本号,当不匹配时,会自动报错。" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import json | ||
import random | ||
import hashlib | ||
import tkinter.messagebox as msgbox | ||
from sys import exit | ||
from tkinter import * | ||
from tkinter.ttk import * | ||
|
||
''' | ||
希望老天爷保佑,这个程序少出点BUG吧 | ||
''' | ||
window = Tk() | ||
window.resizable(False, False) | ||
|
||
# 圆周率 | ||
pi = 3.14 | ||
|
||
# 变量 | ||
current_version = '1.0.4' | ||
cheat = False | ||
question = StringVar() | ||
float_number = 0 # 计算机在后台计算出的答案结果,这才是答案 | ||
random_int_list = [2, 3, 4, 5, 6, 8, 10, 12, 16, 20] # 每次出题时的一个因数 用它 * 3.14 | ||
factor = 0 # 从上面选择出来的因数 | ||
score = 0 # 玩家分数 | ||
|
||
# 读取设置文件 | ||
with open('settings.json', 'r', encoding='utf-8') as f: | ||
settings = json.loads(f.read()) | ||
|
||
# 读取语言文件 | ||
with open('languages\\' + settings['language_file'], 'r', encoding='utf-8') as f: | ||
lang = json.loads(f.read()) | ||
# 如果版本号不匹配则自动报错 | ||
if lang['version'] != current_version: | ||
window.withdraw() | ||
msgbox.showerror('Error! 程序出错了!', 'The software version corresponding to the language file of the program is different, so the program cannot run now.\nYou can ask the original author of the software for the language file. At the same time, please do not modify the version in the language file without authorization.') | ||
msgbox.showinfo('Don\'nt worry', '如果你看不懂上面的语句,请借助翻译软件') | ||
exit() | ||
|
||
# 定义窗口 | ||
window.title(lang['gui']['title.1']) | ||
|
||
# 创建菜单栏 | ||
def about(): | ||
msgbox.showinfo(lang['message']['menubar']['msg6.title'], lang['message']['menubar']['msg6.text']) | ||
def version(): | ||
msgbox.showinfo(lang['message']['menubar']['msg7.title'], lang['message']['menubar']['msg7.text'].format(current_version)) | ||
|
||
menubar = Menu(window) | ||
menu_help = Menu(menubar, tearoff=0) | ||
menubar.add_cascade(label=lang['gui']['menubar.help'], menu=menu_help) | ||
|
||
menu_help.add_command(label=lang['gui']['menubar.help.about'], command=about) | ||
menu_help.add_command(label=lang['gui']['menubar.help.version'], command=version) | ||
|
||
window.config(menu=menubar) | ||
def generate_question(): | ||
# 出题 | ||
|
||
# 这些变量在外面 所以需要使用global | ||
global float_number, random_int_list, factor | ||
factor = random.choice(random_int_list) | ||
|
||
question.set(lang['gui']['text.question'].format(factor)) | ||
|
||
# 由于Python在浮点计算时会有精度问题 | ||
# 而本程序的出题范围均在两位小数以内 | ||
# 因此这里使用round函数避免问题 | ||
# 此解决方案以后可能会修改,因为不是最佳方案 | ||
float_number = round(factor * pi, 4) | ||
|
||
def check_answer(): | ||
# 当用户点击提交后的操作 | ||
global score, pi_answer | ||
if cheat or pi_answer.get() == str(float_number): | ||
score += 1 | ||
msgbox.showinfo(lang['message']['right']['msg1.title'], lang['message']['right']['msg1.text'].format(score)) | ||
msgbox.showinfo(lang['message']['right']['msg2.title'], lang['message']['right']['msg2.text']) | ||
else: | ||
if (pi_answer.get() == ''): | ||
msgbox.showwarning(lang['message']['wrong']['msg3.title'], lang['message']['wrong']['msg3.text']) | ||
score -= 1 | ||
window.title(lang['gui']['title.2'].format(score)) | ||
msgbox.showerror(lang['message']['wrong']['msg4.title'].format(factor), lang['message']['wrong']['msg4.text'].format(float_number, score)) | ||
msgbox.showerror(lang['message']['wrong']['msg5.title'], lang['message']['wrong']['msg5.text'].format(float_number)) | ||
generate_question() | ||
|
||
title = Label(text=lang['gui']['title.1'], font=('微软雅黑', 40)) | ||
title.grid(row=1, column=1, padx=15, pady=15) | ||
question_label = Label(textvariable=question, font=('等线', 20)) | ||
question_label.grid(row=2, column=1, padx=15, pady=15) | ||
button_finish = Button(text=lang['gui']['button.i_finish'], command=check_answer, width=43) | ||
button_finish.grid(row=4, column=1, padx=15, pady=15) | ||
pi_answer = Entry(width=30, font=('Comic Sans MS', 12)) # 答案输入框 | ||
pi_answer.grid(row=3, column=1, padx=15, pady=15) | ||
|
||
# 开始时需初始化,生成一次问题 | ||
generate_question() | ||
|
||
sha1 = hashlib.sha1(settings['secret_setting']['password'].encode('utf-8')).hexdigest() | ||
if settings['secret_setting']['enabled'] and sha1 == '801c9aaf56fa2e0de84b40967625157a120cb5c7': | ||
cheat = True | ||
msgbox.showinfo('你发现了神奇的入口 You found the magic entrance!', '哇。看看那是什么!你打开了作弊模式?天哪!!\nWow. Look what that is! You turned on cheating mode? My God?') | ||
|
||
window.mainloop() |
Oops, something went wrong.