我一直在编写一个基于文本的黑客游戏,我的代码将在下面。
#SICCr4k2: Broke
#
#
#
#Remember whenever you are printing a random ip address to add the "." in between each part of the ip (each random number)
## LAST LEFT ON HERE: MAKE BUTTONS FOR NODES
## MAKE FILES FOR NULL'S NODE
## SET THE CORRECT PLACEMENTS FOR ALL THE BUTTONS
## nullMain referenced before assignment
## make it so that you send a message through the prompt to get their ip, then it automatically puts the ip in the nodes
## window. Like you send the person a message, and then it gets the ip and puts it in the nodes window
## take away the buttons in the nodes window, just at labels where it points to the host's ip address.
## Don't use tkinter buttons anymore
## Regular Campaign, separate program for free roam hacking
## At the end, make it so Null betrayed you and you have to destroy his computer, destroy him.
import random
import time
import sys
import os
import tkinter as tk
from tkinter import *
#def nodes():
# nodeWindow = tk.Tk()
# frame = tk.Frame(nodeWindow, width=700, height=400)
# frame.grid_propagate(0)
# frame.grid()
# nodeWindow.title("||| Nodes |||")
# nodeWindow.iconbitmap(r'C:\Users\John\Desktop\Programming\SICCr4k2BrokeFold\BrokeItems\NodeIcon.ico')
# nodeWindow.wm_resizable(0,0);
# nullMain = tk.Button(nodeWindow, text="Null", function=nullMainCallback())
# nullMain.config(height=1, width=100)
# nullMain.grid(row=0, column=0)
# def nullIpBackCallBack():
# nullMain = tk.Button(nodeWindow, text="Null", function=nullMainCallback())
# nullMain.config(height=1, width=100)
# nullMain.grid(row=0, column=0)
# def nullMainCallback():
# nullMain.destroy()
# nullIp = tk.Label(nodeWindow, text="Ip: 221.153.52.216")
# nullIp.grid(row=0, column=0)
# nullIpBack = tk.Button(nodeWindow, text="Back", function=nullIpBackCallBack())
# nullIpBack.grid(row=1, column=0)
sys.setrecursionlimit(99999)
def nodes1():
nullIp = ('18.226.109')
print('||| Nodes ||||')
print(' ')
print('Null')
print('')
nodeInput1 = input('>>> ')
if nodeInput1 == ('null') or ('Null'):
print("Null's ip: " + nullIp + " <<<back")
def connecting():
#TRY TO MAKE 'CONNECTING' CENTERED
time.sleep(1)
print('Connecting')
time.sleep(1)
os.system('cls')
print('Connecting.')
time.sleep(1)
os.system('cls')
print('Connecting..')
time.sleep(1)
os.system('cls')
print('Connecting...')
time.sleep(1)
os.system('cls')
print('Connecting')
time.sleep(1)
os.system('cls')
print('Connecting.')
time.sleep(1)
os.system('cls')
print('Connecting..')
time.sleep(1)
os.system('cls')
print('Connecting...')
time.sleep(1)
os.system('cls')
print('Connecting')
time.sleep(1)
os.system('cls')
print('Connecting.')
time.sleep(1)
os.system('cls')
print('Connecting..')
time.sleep(1)
os.system('cls')
print('Connecting...')
time.sleep(1)
os.system('cls')
print('You are now connected.')
def connectNull_Tutorial():
#MAKE EVERYTHING CENTERED WELL
numbers()
time.sleep(2)
os.system('cls')
connecting()
print('You now have access to (comp ID): Null')
time.sleep(2)
os.system('cls')
print('Type what you want access to:')
print('Files | Options | Mainframe')
time.sleep(2)
def nullFiles_Tutorial():
print('Go ahead and type Files.')
input('>>> ')
if ('files') or ('Files'):
print('Files:')
print('Key: (T)Text file | (E)Executable | (F)Folder')
print('')
print('')
print('')
print("""screenNames.T""")
time.sleep(2)
def screenNames_Tutorial():
print('Now type in screenNames.T, exactly as it is.')
input('>>> ')
if ('screenNames.T'):
print('|screenNames.T|')
print('')
print('ras1aB, p0Nk, killT0n, raspberryH4cker, 314dk0m')
print('h4ckB3rr13s, b3y0ndPyth0n, j03Dr4n, jitsl3d, 01f0r4')
time.sleep(2)
print('These names...')
time.sleep(2)
print('These people, they need to be dealt with.')
time.sleep(2)
print("It's time to start making this world a better place.")
print("Remember getIp()? Put it to good use with these names")
else:
screenNames_Tutorial()
screenNames_Tutorial()
else:
nullFiles_Tutorial()
nullFiles_Tutorial()
def numbers():
def numbersCode():
t_end = time.time() + 5
while time.time() < t_end:
number1 = random.randint(100, 999)
number2 = random.randint(100, 999)
number3 = random.randint(100, 999)
number4 = random.randint(100, 999)
print(str(number1) + ' ' + str(number2) + ' ' + str(number3) + ' ' + str(number4) + ' ' + str(number1) + ' ' + str(number2) + ' ' + str(number3) + ' ' + str(number4) + ' ' + str(number1) + ' ' + str(number2) + ' ' + str(number3) + ' ' + str(number4) + ' ' + str(number1) + ' ' + str(number2) + ' ' + str(number3) + ' ' + str(number4))
numbersCode()
#def getIp():
# x = random.randint(1, 222)
# if x == 127:
# x += 1
# return '{}.{}.{}.{}'.format(
# x,
# random.randint(0, 255),
# random.randint(0, 255),
# random.randint(0, 255))
def usernameCreation():
username = input(">>> ")
print("'" + username + "' is that correct?")
usernameInput = input(">>> ")
if usernameInput == ("yes"):
print("Okay...")
if usernameInput ==("no"):
usernameCreation()
def game():
def tutorial():
print('Hello.')
time.sleep(3)
print('Welcome back.')
time.sleep(3)
print("You're probably wondering who I am.")
time.sleep(3)
print("You might also be wondering what the hell is happening")
time.sleep(5)
print('Well, my name is Null')
time.sleep(3)
print("And I'm dead.")
time.sleep(5)
print("I've downloaded new software onto your computer.")
os.system('cls')
print("First thing's first, what shall I call you?")
usernameCreation()
time.sleep(3)
def firstMove():
print("""Let's give you some movement. What you're going to have to do
is type, getIp(Null), in other cases you will have to replace Null with
the person's screen name. It IS case sensitive""")
firstMove()
def repeatCommand1():
print('Go right ahead, getIp(Null)')
commandInput = input(">>> ")
if ('getIp(Null)'):
numbers()
time.sleep(3)
print('Ip address added to your nodes.')
time.sleep(2)
os.system('cls')
print("""Now you will need to type myNodes(), which will give you access to all the
ip addresses you have found out so far. Then you will need to type in the
screen name of the person you need the ip of.""")
def myNodes1():
print("So go ahead. myNodes()")
input(">>> ")
if ('myNodes()'):
nodes1()
print("""I just downloaded a bypasser and a password decrypter to your computer. I want you to try
to hack into my computer. First use, connectIp(18.226.109)""")
input(">>> ")
if ('connectIp(18.226.109)'):
connectNull_Tutorial()
else:
print('That is an incorrect command.')
myNodes1()
myNodes1()
else:
repeatCommand1()
repeatCommand1()
tutorial()
game()
程序的问题是,如果有if / else命令,它就不起作用。我刚刚测试了程序,看到当我输入任何类型的输入时(代码中的任何地方都显示input('>>> ')
然后:
if ('blah'):
print('blah')
然后:
else:
commandThatgoesBack
我会尽力澄清。在哪里说:
def repeatCommand1():
print('Go right ahead, getIp(Null)')
commandInput = input(">>> ")
if ('getIp(Null)'):
numbers()
time.sleep(3)
print('Ip address added to your nodes.')
time.sleep(2)
os.system('cls')
print("""Now you will need to type myNodes(), which will give you access to all the
ip addresses you have found out so far. Then you will need to type in the
screen name of the person you need the ip of.""")
def myNodes1():
print("So go ahead. myNodes()")
input(">>> ")
if ('myNodes()'):
nodes1()
print("""I just downloaded a bypasser and a password decrypter to your computer. I want you to try
to hack into my computer. First use, connectIp(18.226.109)""")
input(">>> ")
if ('connectIp(18.226.109)'):
connectNull_Tutorial()
else:
print('That is an incorrect command.')
myNodes1()
myNodes1()
else:
repeatCommand1()
显然,或者有点清楚地说明,如果你输入等等,如果你输入任何其他内容,请从头开始,然后重复输入,一遍又一遍,直到你输入正确的东西。如:
def goBack():
print('Enter getIp(Null)')
input()
if ('getIp(Null)'):
print('Good job mate')
else:
goBack()
goBack()
(请注意,上面的代码用作示例,而不一定是我的代码在实际程序中的确切方式)。该程序似乎接受了我输入的任何输入,并且仍然(使用上面的示例)打印'Good job mate',即使我没有输入getIp(Null)。我的代码中出现类似上面代码的每个地方都会弹出相同的错误。我可以直接运行该程序,只需输入即可播放整个(当前)游戏。谁知道该怎么办?
答案 0 :(得分:2)
result = input(">>>")
if result == "Something":
do_something()
这非常基本......你应该更频繁地运行你的代码......