Added Docstrings and corrected for style.

This commit is contained in:
adamercat 2020-12-18 15:00:54 +01:00
parent 0f66134c40
commit 497ffd80c8
1 changed files with 30 additions and 11 deletions

View File

@ -1,11 +1,18 @@
"""user interface""" """This module has all the building blocks for a nice 16-is-dead user interface"""
__author__ = ""
__credits__ = ""
__email__ = ""
import time import time
import os import os
def dice_animation(): def dice_animation():
'''
This functions prints the rolling dice animation
return: None
'''
for i in range(4): for i in range(4):
plz_print('dice_animation1.txt') plz_print('dice_animation1.txt')
time.sleep(0.25) time.sleep(0.25)
@ -16,6 +23,11 @@ def dice_animation():
def plz_print(filename): def plz_print(filename):
'''
This functions reads a file line by line
and prints it in on call.
return: None
'''
with open(filename, 'r', encoding='utf8') as f: with open(filename, 'r', encoding='utf8') as f:
bigstring = "" bigstring = ""
for line in f: for line in f:
@ -24,12 +36,23 @@ def plz_print(filename):
def clear(): def clear():
'''
This functions clears the terminal screen,
it distinguishes between Linux and Windows
But it does not work in pycharm or idle.
return: None
'''
if os.name == 'nt': # for windows if os.name == 'nt': # for windows
os.system('cls') os.system('cls')
else: # for linux, mac else: # for linux, mac
os.system('clear') os.system('clear')
def pling(current_roll): def pling(current_roll):
'''
This functions prints the animation of the dice result
return: None
'''
with open('pling_animation', 'r', encoding='utf8') as f: with open('pling_animation', 'r', encoding='utf8') as f:
big_string = "" big_string = ""
animations = [] animations = []
@ -42,22 +65,18 @@ def pling(current_roll):
dice_result = animations[current_roll[0] - 1] dice_result = animations[current_roll[0] - 1]
for line in dice_result: for line in dice_result:
scan_lines += line scan_lines += line
if line[0] == '#': if line[0] == '#':
clear() clear()
print(scan_lines[:-2]) print(scan_lines[:-2])
time.sleep(0.5) time.sleep(0.5)
scan_lines = "" scan_lines = ""
#for item in animations:
#print(item)
#print('------------------------------------')
def the_end(): def the_end():
'''
This functions prints the end screen.
return: None
'''
print("--------------------------\n\/\/\/\ SPIEL ENDE /\/\/\/\n--------------------------") print("--------------------------\n\/\/\/\ SPIEL ENDE /\/\/\/\n--------------------------")
#dice_animation()
#for i in range(1,7):
#pling(i)
#the_end()