有没有大佬能帮我解决一下问题啊!急!
游戏名字:黑客游戏之这只是一场游戏
游戏进度:开发中
急需解决问题:当ep1()函数里面的操作步骤的命令文字在commanddirect列表(键盘记录器)里面时,自动运行ep2()函数,但是我改了很多地方,都无法跟我想的一样自动运行ep2()函数。
main.py源代码:
import tkinter as tk
from time import *
import boot, easygui
import os, sys
from xes.tool import *
from xes.AIspeak import *
from xes.ext import *
from xes.weather import *
from xes.sms import *
def logon():
global commanddirect, username, password, name, word, ep
commanddirect = []
path = xopen("hackergame")
if not os.path.exists(path+"username.txt") and not os.path.exists(path+"password.txt"):
print("\033[32;1mHacker System v1.0532_03 黑客系统 版本1.0532_03")
print("User, Administrator Rights Needed. 用户权限,需要管理员权限才能加权为管理员。")
print("")
username = input("Please type your user name: 请输入您的用户名:")
password = input("Please type your password: 请输入您的密码:")
with open(path+"username.txt", "w", encoding="UTF-8") as file:
file.write("{}".format(username))
with open(path+"password.txt", "w", encoding="UTF-8") as file:
file.write("{}".format(password))
print("恭喜您,{},注册成功!".format(username))
if os.path.exists(path+"username.txt") and os.path.exists(path+"password.txt"):
print("\033[32;1mHacker System v1.0532_03 黑客系统 版本1.0532_03")
print("User, Administrator Rights Needed. 用户权限,需要管理员权限才能加权为管理员。")
print("")
username = input("Please type your user name: 请输入您的用户名:")
password = input("Please type your password: 请输入您的密码:")
with open(path+"username.txt", "r", encoding="UTF-8") as file:
name = file.read()
with open(path+"password.txt", "r", encoding="UTF-8") as file:
word = file.read()
if username == name and password == word:
print("恭喜您,{},登录成功!".format(name))
else:
print("登录失败。")
sys.exit(0)
def system():
global commanddirect, ctext, ctext1, ctext2, name, word, ps, diskf, diskfile, removeps, ep
name = "{}".format(name)
word = "{}".format(word)
ctext1 = "[192.8.0.0/{}/".format(name)
ctext = "{}".format(ctext1)
ctext2 = "[165.44.71.38/admin/"
commanddirect = commanddirect
ep = 1
print("\033[32;1mHacker System v1.0532_03 黑客系统 版本1.0532_03")
print("User, Administrator Rights Needed. 用户权限,需要管理员权限才能加权为管理员。")
print("")
diskf = {"log":[], ".":["user", "config", "sys", "bios"], "main":["boot"], "command":[], "progra":["trans", "mess", "temp", "mail"]}
diskfile = [".", "main", "command", "progra"]
ps = ["system"]
removeps = []
print("欢迎!%s!"%(name))
ep1()
openfile()
if "hacknet 165.44.71.38" in commanddirect and "quit" in commanddirect:
ep2()
def s1control():
global commanddirect, ctext, ctext1, ctext2, name, word, ps, diskf, diskfile, removeps, ep
ctext = ctext1
if "copy /progra/hackgame.txt /main/" in commanddirect:
diskf["progra"] == ["trans", "mess", "temp", "mail", "hackergame.txt"]
else:
diskf["progra"] == ["trans", "mess", "temp", "mail"]
print("已成功断开连接。")
return ctext
def s2control():
global commanddirect, ctext, ctext1, ctext2, name, word, ps, diskf, diskfile, removeps, ep
ctext = ctext2
diskf["progra"] == ["trans", "mess", "temp", "mail", "hackergame.txt"]
print("欢迎,admin!")
return ctext
def cd():
global commanddirect, ctext, ctext1, ctext2, name, word, ps, diskf, diskfile,removeps, ep
commanddirect = commanddirect
commanddirect.append("cd")
ps.append("cd")
ctext = "{}".format(ctext1)
ctext1 = "[192.8.0.0/{}/".format(name)
ctext2 = "[165.44.71.38/admin/"
cdd = input("请输入想切换到的位置:")
if cdd == "log" and cdd == "." or cdd == "main" or cdd == "command" or cdd == "progra":
commanddirect.append(cdd)
ctext = "[192.8.0.0/{}/{}/".format(name, cdd)
print("已切换至此位置。")
return ctext
else:
print("找不到该位置。")
ps.remove("cd")
removeps.append("cd")
cdirectreturn()
def openfile():
global commanddirect, ctext, ctext1, ctext2, name, word, ps, diskf, diskfile, removeps
name = "{}".format(name)
word = "{}".format(word)
ctext = "{}".format(ctext1)
ctext1 = "[192.8.0.0/{}/".format(name)
ctext2 = "[165.44.71.38/admin/"
commanddirect = commanddirect
while True:
com = input(ctext)
if com == "cd":
cd()
elif "copy" in com and ctext == ctext2:
commanddirect.append("copy")
if "/progra/hackergame.txt" in com and "/main/" in com:
commanddirect.append("copy /progra/hackergame.txt /main/")
print("复制成功!")
else:
print("复制失败。")
cdirectreturn()
elif com == "dir":
commanddirect.append("dir")
ps.append("dir")
dicom = input("请输入要查看的文件夹:")
commanddirect.append(dicom)
if dicom == ".":
print(diskf["."])
elif dicom == "main":
print(diskf["main"])
elif dicom == "command":
print(diskf["command"])
elif dicom == "progra":
print(diskf["progra"])
elif dicom == "log":
print(diskf["log"])
else:
print("文件夹名称有误。")
ps.remove("dir")
removeps.append("dir")
cdirectreturn()
elif com == "dispf":
commanddirect.append("dispf")
ps.append("dispf")
print(diskfile)
ps.remove("dispf")
removeps.append("dispf")
cdirectreturn()
elif com == "timedis":
commanddirect.append("timedis")
ps.append("timedis")
print(strftime("%H:%M:%S"))
ps.remove("timedis")
removeps.append("timedis")
cdirectreturn()
elif com == "datedis":
commanddirect.append("datedis")
ps.append("datedis")
print(strftime("%y-%m-%d"))
ps.remove("datedis")
removeps.append("datadis")
cdirectreturn()
elif com == "mkfile":
commanddirect.append("mkfile")
ps.append("mkfile")
filemk = input("请输入文件名:")
commanddirect.append(filemk)
diskf.append(filemk)
ps.remove("mkfile")
removeps.append("mkfile")
cdirectreturn()
elif com == "rmfile":
commanddirect.append("rmfile")
ps.append("rmfile")
filerm = input("请输入文件名:")
commanddirect.append(filerm)
diskf.remove(filerm)
ps.remove("rmfile")
removeps.append("rmfile")
cdirectreturn()
elif com == "killall":
sys.exit(0)
elif com == "kill":
commanddirect.append("kill")
ps.append("kill")
pskill = input("请输入进程名:")
if pskill in ps:
commanddirect.append(pskill)
ps.remove(pskill)
removeps.append(pskill)
print("已结束此进程。")
else:
print("进程名错误。")
ps.remove("kill")
removeps.append("kill")
cdirectreturn()
elif com == "restartkps":
commanddirect.append("restartkps")
ps.append("restartkps")
psrestart = input("请输入进程名:")
if psrestart in removeps:
commanddirect.append(psrestart)
ps.append(psrestart)
removeps.remove(psrestart)
print("已重新启动结束的进程。")
ps.remove("restartkps")
removeps.append("restartkps")
cdirectreturn()
elif com == "dispslist":
commanddirect.append("dispslist")
ps.append("dispslist")
print(ps)
ps.remove("dispslist")
removeps.append("dispslist")
cdirectreturn()
elif com == "echo":
commanddirect.append("echo")
ps.append("echo")
content = input("请输入内容:")
commanddirect.append(content)
print(content)
ps.remove("echo")
removeps.append("echo")
cdirectreturn()
elif com == "usernc":
commanddirect.append("usernc")
ps.append("usernc")
nun = input("请输入用户名:")
commanddirect.append(nun)
name = nun
ps.remove("usernc")
removeps.append("usernc")
cdirectreturn()
elif com == "trans" and "/progra/" in ctext:
commanddirect.append("progra")
commanddirect.append("trans")
ps.append("trans")
print("欢迎来到翻译软件!")
print("提示:输入‘translate’来翻译,输入‘exit’退出")
while True:
trans = input("/")
if trans == "translate":
commanddirect.append("translate")
c = input("请输入内容:")
print(translate(c))
commanddirect.append(c)
elif trans == "exit":
commanddirect.append("exit")
break
else:
print("命令有误")
ps.remove("trans")
removeps.append("trans")
cdirectreturn()
elif com == "mess" and "/progra/" in ctext:
commanddirect.append("progra")
commanddirect.append("mess")
ps.append("mess")
print("-------\n信息发送\n-------")
while True:
ms = input("输入命令/")
if ms == "send":
commanddirect.append("send")
p = input("电话号码:")
co = input("内容:")
send_msg(p,co)
commanddirect.append(p)
commanddirect.append(co)
elif ms == "help":
commanddirect.append("help")
print("send(发送信息)\nexit(退出程序)\nhelp(显示所有命令)")
elif ms == "exit":
commanddirect.append("exit")
break
else:
print("命令有误")
ps.remove("mess")
removeps.append("mess")
cdirectreturn()
elif com == "temp" and "/progra/" in ctext:
commanddirect.append("progra")
commanddirect.append("temp")
ps.append("temp")
print("天气早报")
print("输入'city'来查询天气,输入'exit'退出")
while True:
line = input(">")
if line == "city":
commanddirect.append("city")
citya = input("请输入城市名称:")
temp = air_temp(citya)
commanddirect.append(citya)
print("该城市的温度是%i摄氏度"%(temp))
elif line == "exit":
commanddirect.append("exit")
break
else:
print("命令有误")
ps.remove("temp")
removeps.append("temp")
cdirectreturn()
elif com == "mail" and "/progra/" in ctext:
commanddirect.append("progra")
commanddirect.append("mail")
ps.append("mail")
print("黑客邮箱")
print("输入'starmail'来查看星标邮件,输入'starcontact'来查看星标联系人,输入'sendmail'来发送邮件,输入'exit'退出。")
while True:
ccom = input("/>")
if ccom == "starmail":
commanddirect.append("starmail")
print("<星标邮件>")
print("1. 16点40到我们家玩啊?(发自Andrew,2014年5月30日7时47分)")
print("2. 你如果不喜欢的话,我给你换一个?(发自Andrew,2015年12月25日14时01分)")
print("3. 我去4S店检车去了,10点回来。(发自Andrew,2018年6月5日8时18分)")
elif ccom == "starcontact":
commanddirect.append("starcontact")
print("<星标联系人>")
print("1. Andrew")
elif ccom == "sendmail":
commanddirect.append("sendmail")
send = input("发送至(如example@hackermail.com):")
smess = input("信息:")
if "@hackermail.com" in send:
commanddirect.append(send)
commanddirect.append(smess)
print("已成功发送至{}。".format(send))
elif "computer1326@hackermail.com" == send and "\{{file:///{}/progra/secretfile.zip}}" == smess:
commanddirect.append(send)
commanddirect.append(smess)
print("已成功发送至computer1326@hackermail.com。")
elif "computer1326@hackermail.com" == send:
commanddirect.append(send)
commanddirect.append(smess)
print("已成功发送至computer1326@hackermail.com。")
else:
print("发送失败。")
elif ccom == "exit":
commanddirect.append("exit")
break
else:
print("命令有误。")
cdirectreturn()
elif "hacknet" in com:
if com == "hacknet":
commanddirect.append("hacknet")
print("hacknet命令格式:hacknet [主机IP]")
elif com == "hacknet 165.44.71.38":
commanddirect.append("hacknet 165.44.71.38")
una = input("请输入远程主机的用户名:")
pas = input("请输入远程主机的密码:")
commanddirect.append(una)
commanddirect.append(pas)
if una == "admin" and pas == "happyflower" and ctext == ctext1:
print("请稍候......Hacker System HackNet Cilent(黑客系统HackNet客户端)正在为您连接中......")
s2control()
else:
print("无法连接至165.44.71.38。")
else:
print("主机IP地址错误。")
cdirectreturn()
elif com == "quit" and ctext == ctext2:
commanddirect.append("quit")
s1control()
cdirectreturn()
elif com == "about":
commanddirect.append("about")
ps.append("about")
print("Hacker System\nHacker System v1.0.0 (Build 3485)\n© No Name Studio\nAll Rights Reserved. \n")
ps.remove("about")
removeps.append("about")
cdirectreturn()
elif com == "help":
commanddirect.append("help")
ps.append("help")
helpt = """
cd --------- 切换到任意位置
copy ------- 复制一个文件
echo ------- 显示一段文本
dir -------- 查看一个文件夹
dispf ------ 显示磁盘文件
timedis ---- 显示当前时间
datedis ---- 显示当前日期
mkfile ----- 新建一个新的文件
rmfile ----- 删除一个文件
kill ------- 结束一个进程
killall ---- 结束所有进程
restartkps - 重新启动结束的进程
dispslist -- 显示所有进程
usernc ----- 更换用户名
hacknet ---- 连接到远程计算机
about ------ 关于 Hacker System 黑客系统
help ------- 显示所有命令
progra/trans 翻译软件(先使用cd命令进入progra文件夹,再输入trans)
progra/mess信息发送(先使用cd命令进入progra文件夹,再输入mess)
progra/temp天气早报(先使用cd命令进入progra文件夹,再输入temp)
progra/mail黑客邮箱(先使用cd命令进入progra文件夹,再输入mail)
"""
print(helpt)
ps.remove("help")
removeps.append("help")
cdirectreturn()
else:
print("命令有误")
cdirectreturn()
def ep1():
print("您收到了一封发自Andrew的邮件!邮件内容:")
print("Hi!老朋友!好久不见了吧?\n前几天听说你想和我一样当个黑客,我答应你。")
print("现在呢,咱们先来一个入门操作,你现在使用hacknet连接到我的个人服务器,IP地址是165.44.71.38。你连接上就立马用quit退出,之后我会给你发邮件。")
print("用户名是:admin,密码是:happyflower。")
print("命令:第一步:hacknet 165.44.71.38\n第二步:在用户名处输入admin,在密码处输入happyflower\n第三步:quit")
print("Andrew")
def ep2():
print("您收到了一封发自Andrew的邮件!邮件内容:")
print("干得不错!因为这对一个初学者来说,这已经很棒了。")
print("现在你需要再次使用hacknet连接到我的个人服务器,IP地址仍然不变。")
print("不过,你连接上了之后,需要使用copy命令把一个位于progra文件夹里面的一个叫hackergame.txt的一个文本文档复制到你的main文件夹里面,然后就立马退出,之后我会给你发邮件。")
print("用户名是:admin,密码是:happyflower")
print("命令:第一步:hacknet 165.44.71.38\n第二步:输入用户名和密码\n第三步:copy /progra/hackergame.txt /main/\n第四步:quit")
print("Andrew")
def cdirectreturn():
global commanddirect, ctext, name, word, ps, diskf, diskfile,removeps, ep
commanddirect = commanddirect
return commanddirect
boot.boot()
print("黑客游戏之")
sleep(4)
print("\033[31;1m这只是一场游戏")
bootmenu = easygui.buttonbox("请选择:", "游戏菜单", choices=("开始游戏", "选择关卡"))
if bootmenu == "开始游戏":
logon()
system()
boot.py源代码:
import pygame, sys, time, threading
from pygame.locals import MOUSEBUTTONDOWN
def boot():
pygame.init()
screen = pygame.display.set_mode((640, 400))
pygame.display.set_caption("黑客游戏")
screen.fill((0, 0, 0))
picList = ["NNS图标2.png"]
imgList = []
for i in picList:
myImage = pygame.image.load(i).convert()
imgList.append(myImage)
imgNum = 0
image = imgList
a = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
if event.type == pygame.MOUSEBUTTONDOWN:
a = 0
imgNum += 1
if imgNum > len(imgList) - 1:
pygame.quit()
return
image = imgList
a = a + 1
if a > 255:
a = 0
image.set_alpha(a)
screen.fill((0, 0, 0))
screen.blit(image, (0, 0))
'''screen.blit(FreeCreateImg, (0, 0))'''
pygame.display.update()
time.sleep(0.01) 一行注释都没有,告辞
页:
[1]