Interrupting mid-attack, users can Continue/Skip/Exit.
This commit is contained in:
@@ -85,8 +85,13 @@ class AttackAll(object):
|
|||||||
continue
|
continue
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
Color.pl('\n{!} {O}Interrupted{W}\n')
|
Color.pl('\n{!} {O}Interrupted{W}\n')
|
||||||
if not cls.user_wants_to_continue(targets_remaining, len(attacks)):
|
answer = cls.user_wants_to_continue(targets_remaining, len(attacks))
|
||||||
return False # Stop attacking other targets
|
if answer is True:
|
||||||
|
continue # Keep attacking the same target (continue)
|
||||||
|
elif answer is None:
|
||||||
|
return True # Keep attacking other targets (skip)
|
||||||
|
else:
|
||||||
|
return False # Stop all attacks (exit)
|
||||||
|
|
||||||
if attack.success:
|
if attack.success:
|
||||||
attack.crack_result.save()
|
attack.crack_result.save()
|
||||||
@@ -109,15 +114,30 @@ class AttackAll(object):
|
|||||||
prompt_list.append(Color.s('{C}%d{W} attack(s)' % attacks_remaining))
|
prompt_list.append(Color.s('{C}%d{W} attack(s)' % attacks_remaining))
|
||||||
if targets_remaining > 0:
|
if targets_remaining > 0:
|
||||||
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
|
prompt_list.append(Color.s('{C}%d{W} target(s)' % targets_remaining))
|
||||||
prompt = ' and '.join(prompt_list)
|
prompt = ' and '.join(prompt_list) + ' remain'
|
||||||
Color.pl('{+} %s remain, Do you want to continue?' % prompt)
|
Color.pl('{+} %s' % prompt)
|
||||||
|
|
||||||
prompt = Color.s('{+} Type {G}c{W} to {G}continue{W}' +
|
prompt = '{+} Do you want to'
|
||||||
' or {R}s{W} to {R}stop{W}: ')
|
options = '('
|
||||||
|
|
||||||
|
if attacks_remaining > 0:
|
||||||
|
prompt += ' {G}continue{W} attacking,'
|
||||||
|
options += '{G}C{W}{D}, {W}'
|
||||||
|
|
||||||
|
if targets_remaining > 0:
|
||||||
|
prompt += ' {O}skip{W} to the next target,'
|
||||||
|
options += '{O}s{W}{D}, {W}'
|
||||||
|
|
||||||
|
options += '{R}e{W})'
|
||||||
|
prompt += ' or {R}exit{W} %s? {C}' % options
|
||||||
|
|
||||||
from ..util.input import raw_input
|
from ..util.input import raw_input
|
||||||
if raw_input(prompt).lower().startswith('s'):
|
answer = raw_input(Color.s(prompt)).lower()
|
||||||
return False
|
|
||||||
else:
|
if answer.startswith('s'):
|
||||||
return True
|
return None # Skip
|
||||||
|
elif answer.startswith('e'):
|
||||||
|
return False # Exit
|
||||||
|
else:
|
||||||
|
return True # Continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user