Changed the alignment of the output messages.
This commit is contained in:
parent
80e36e4aa5
commit
894dd6df84
24
main.py
24
main.py
|
@ -4,6 +4,16 @@
|
||||||
# Read below for how-to-play, or input ? after running
|
# Read below for how-to-play, or input ? after running
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
from witty_retort import MessageTable
|
||||||
|
|
||||||
|
remarks = MessageTable()
|
||||||
|
remarks.add_entry("Not quite", 30)
|
||||||
|
remarks.add_entry("Keep trying", 20)
|
||||||
|
remarks.add_entry("Intresting strategy", 15)
|
||||||
|
remarks.add_entry("Close", 10)
|
||||||
|
remarks.add_entry("Don't give up", 10)
|
||||||
|
remarks.add_entry("I though you had it", 10)
|
||||||
|
remarks.add_entry("You can do it!", 5)
|
||||||
|
|
||||||
""" Dummy class for Errors"""
|
""" Dummy class for Errors"""
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
|
@ -47,6 +57,8 @@ and what you got wrong.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def format_message(message):
|
||||||
|
return message.rjust(25)
|
||||||
|
|
||||||
def generateSecret(secret):
|
def generateSecret(secret):
|
||||||
for i in range(0, len(colors)):
|
for i in range(0, len(colors)):
|
||||||
|
@ -97,7 +109,7 @@ print(rules)
|
||||||
while game_continue:
|
while game_continue:
|
||||||
guess = []
|
guess = []
|
||||||
|
|
||||||
temp = input('Choose your colors: ')
|
temp = input(format_message('Choose your colors: '))
|
||||||
if debug:
|
if debug:
|
||||||
print('Temp =', temp)
|
print('Temp =', temp)
|
||||||
guess = list(temp)
|
guess = list(temp)
|
||||||
|
@ -126,14 +138,16 @@ while game_continue:
|
||||||
clue = compare(secret, guess, clue)
|
clue = compare(secret, guess, clue)
|
||||||
# Finds differences between guess and secret
|
# Finds differences between guess and secret
|
||||||
win = calc(secret, guess, clue)
|
win = calc(secret, guess, clue)
|
||||||
# Calculates if you won or not and outputs it.
|
# Calculates if you won or not.
|
||||||
|
|
||||||
if win:
|
if win:
|
||||||
print('You won!')
|
print('You won!')
|
||||||
else:
|
else:
|
||||||
print('Not quite right.')
|
hint_text = ''.join(clue)
|
||||||
clue_string = ''.join(clue)
|
message = remarks.get_message()["remark"];
|
||||||
print('Your clue: ', clue_string)
|
text = format_message(message + ": ")
|
||||||
|
print(text + hint_text);
|
||||||
|
print(' ');
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except LengthException as e:
|
except LengthException as e:
|
||||||
|
|
|
@ -27,15 +27,3 @@ class MessageTable:
|
||||||
if hit_value < running_value:
|
if hit_value < running_value:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
remarks = MessageTable()
|
|
||||||
remarks.add_entry("Not quite", 30)
|
|
||||||
remarks.add_entry("Keep trying", 20)
|
|
||||||
remarks.add_entry("Intresting strategy", 15)
|
|
||||||
remarks.add_entry("Close", 10)
|
|
||||||
remarks.add_entry("Don't give up", 10)
|
|
||||||
remarks.add_entry("I though you had it", 10)
|
|
||||||
remarks.add_entry("You can do it!", 5)
|
|
||||||
|
|
Loading…
Reference in New Issue