Compare commits
No commits in common. "6b28f5c00187feeba3c0f2f985c79c6f1c77b3e3" and "af025064f4ddabfa2a557a2f4d7f9c79ded10dae" have entirely different histories.
6b28f5c001
...
af025064f4
3 changed files with 12 additions and 14 deletions
|
@ -17,8 +17,6 @@ HIDDEN_MASK = '*'
|
||||||
|
|
||||||
NEWLINE = 10
|
NEWLINE = 10
|
||||||
|
|
||||||
SPACE = 32
|
|
||||||
|
|
||||||
DELETE = 330
|
DELETE = 330
|
||||||
|
|
||||||
BACKSPACE = 263
|
BACKSPACE = 263
|
||||||
|
|
|
@ -162,7 +162,7 @@ def moveInput(scr, inputPad):
|
||||||
size = scr.getmaxyx()
|
size = scr.getmaxyx()
|
||||||
height = size[0]
|
height = size[0]
|
||||||
width = size[1]
|
width = size[1]
|
||||||
|
|
||||||
inputPad.addstr('\n>')
|
inputPad.addstr('\n>')
|
||||||
|
|
||||||
# cursor position relative to inputPad
|
# cursor position relative to inputPad
|
||||||
|
@ -173,7 +173,7 @@ def moveInput(scr, inputPad):
|
||||||
int(width / 2 + CONST_CHARS),
|
int(width / 2 + CONST_CHARS),
|
||||||
int(height - 1),
|
int(height - 1),
|
||||||
int(width - 1))
|
int(width - 1))
|
||||||
|
|
||||||
|
|
||||||
def userInput(scr, passwords):
|
def userInput(scr, passwords):
|
||||||
"""
|
"""
|
||||||
|
@ -185,7 +185,7 @@ def userInput(scr, passwords):
|
||||||
size = scr.getmaxyx()
|
size = scr.getmaxyx()
|
||||||
height = size[0]
|
height = size[0]
|
||||||
width = size[1]
|
width = size[1]
|
||||||
|
|
||||||
# set up a pad for user input
|
# set up a pad for user input
|
||||||
inputPad = curses.newpad(height, int(width / 2 + CONST_CHARS))
|
inputPad = curses.newpad(height, int(width / 2 + CONST_CHARS))
|
||||||
|
|
||||||
|
@ -194,14 +194,14 @@ def userInput(scr, passwords):
|
||||||
# randomly pick a password from the list
|
# randomly pick a password from the list
|
||||||
pwd = passwords[random.randint(0, len(passwords) - 1)]
|
pwd = passwords[random.randint(0, len(passwords) - 1)]
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
|
|
||||||
while attempts > 0:
|
while attempts > 0:
|
||||||
# move the curser to the correct spot for typing
|
# move the curser to the correct spot for typing
|
||||||
scr.move(int(height - 1), int(width / 2 + CONST_CHARS + 1))
|
scr.move(int(height - 1), int(width / 2 + CONST_CHARS + 1))
|
||||||
|
|
||||||
# scroll user input up as the user tries passwords
|
# scroll user input up as the user tries passwords
|
||||||
moveInput(scr, inputPad)
|
moveInput(scr, inputPad)
|
||||||
|
|
||||||
guess = upperInput(scr, False, False)
|
guess = upperInput(scr, False, False)
|
||||||
cursorPos = inputPad.getyx()
|
cursorPos = inputPad.getyx()
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ def userInput(scr, passwords):
|
||||||
|
|
||||||
# user got password right
|
# user got password right
|
||||||
if guess.upper() == pwd.upper():
|
if guess.upper() == pwd.upper():
|
||||||
|
|
||||||
addSound("correctpass")
|
addSound("correctpass")
|
||||||
inputPad.addstr('>Exact match!\n')
|
inputPad.addstr('>Exact match!\n')
|
||||||
inputPad.addstr('>Please wait\n')
|
inputPad.addstr('>Please wait\n')
|
||||||
|
@ -222,7 +222,7 @@ def userInput(scr, passwords):
|
||||||
|
|
||||||
time.sleep(LOGIN_PAUSE)
|
time.sleep(LOGIN_PAUSE)
|
||||||
return pwd
|
return pwd
|
||||||
|
|
||||||
# wrong password
|
# wrong password
|
||||||
else:
|
else:
|
||||||
pwdLen = len(pwd)
|
pwdLen = len(pwd)
|
||||||
|
@ -233,12 +233,12 @@ def userInput(scr, passwords):
|
||||||
matched += 1
|
matched += 1
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass # user did not enter enough letters
|
pass # user did not enter enough letters
|
||||||
|
|
||||||
addSound("wrongpass")
|
addSound("wrongpass")
|
||||||
inputPad.addstr('>Entry denied\n')
|
inputPad.addstr('>Entry denied\n')
|
||||||
inputPad.addstr('>' + str(matched) + '/' + str(pwdLen) +
|
inputPad.addstr('>' + str(matched) + '/' + str(pwdLen) +
|
||||||
' correct.\n')
|
' correct.\n')
|
||||||
|
|
||||||
attempts -= 1
|
attempts -= 1
|
||||||
# show remaining attempts
|
# show remaining attempts
|
||||||
scr.move(SQUARE_Y, 0)
|
scr.move(SQUARE_Y, 0)
|
||||||
|
@ -253,7 +253,7 @@ def userInput(scr, passwords):
|
||||||
|
|
||||||
# Out of attempts
|
# Out of attempts
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def runLogin(scr):
|
def runLogin(scr):
|
||||||
"""
|
"""
|
||||||
Start the login portion of the terminal
|
Start the login portion of the terminal
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import curses
|
import curses
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from fallout_functions import slowWrite, centeredWrite, NEWLINE, SPACE, addSound
|
from fallout_functions import slowWrite, centeredWrite, NEWLINE, addSound
|
||||||
|
|
||||||
###################### Functions ############################
|
###################### Functions ############################
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ def makeSelection(scr, SELECTIONS, MSGS):
|
||||||
selection_start_y = scr.getyx()[0]
|
selection_start_y = scr.getyx()[0]
|
||||||
width = scr.getmaxyx()[1]
|
width = scr.getmaxyx()[1]
|
||||||
|
|
||||||
while inchar not in [NEWLINE, SPACE]:
|
while inchar != NEWLINE:
|
||||||
# move to start of selections and hightlight current selection
|
# move to start of selections and hightlight current selection
|
||||||
scr.move(selection_start_y, 0)
|
scr.move(selection_start_y, 0)
|
||||||
line = 0
|
line = 0
|
||||||
|
|
Loading…
Reference in a new issue