forked from wholesomedonut/pystermind
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
|
||||
|
||||
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"""
|
||||
class Error(Exception):
|
||||
|
@ -47,6 +57,8 @@ and what you got wrong.
|
|||
|
||||
"""
|
||||
|
||||
def format_message(message):
|
||||
return message.rjust(25)
|
||||
|
||||
def generateSecret(secret):
|
||||
for i in range(0, len(colors)):
|
||||
|
@ -97,7 +109,7 @@ print(rules)
|
|||
while game_continue:
|
||||
guess = []
|
||||
|
||||
temp = input('Choose your colors: ')
|
||||
temp = input(format_message('Choose your colors: '))
|
||||
if debug:
|
||||
print('Temp =', temp)
|
||||
guess = list(temp)
|
||||
|
@ -126,14 +138,16 @@ while game_continue:
|
|||
clue = compare(secret, guess, clue)
|
||||
# Finds differences between guess and secret
|
||||
win = calc(secret, guess, clue)
|
||||
# Calculates if you won or not and outputs it.
|
||||
# Calculates if you won or not.
|
||||
|
||||
if win:
|
||||
print('You won!')
|
||||
else:
|
||||
print('Not quite right.')
|
||||
clue_string = ''.join(clue)
|
||||
print('Your clue: ', clue_string)
|
||||
hint_text = ''.join(clue)
|
||||
message = remarks.get_message()["remark"];
|
||||
text = format_message(message + ": ")
|
||||
print(text + hint_text);
|
||||
print(' ');
|
||||
continue
|
||||
|
||||
except LengthException as e:
|
||||
|
|
|
@ -27,15 +27,3 @@ class MessageTable:
|
|||
if hit_value < running_value:
|
||||
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