Simplify Python Code

print_with_tab / print_with_whitespace is trivial with Python
string formatting and was mostly used in only 2 lines.
This commit is contained in:
Martin Thoma
2022-04-02 07:32:09 +02:00
parent 354c1f9ab3
commit c500424956
47 changed files with 208 additions and 387 deletions

View File

@@ -4,9 +4,9 @@ from functools import partial
from typing import Callable, List, Set
def display_intro() -> None:
print("" * 33 + "BOMBARDMENT")
print("" * 15 + " CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
def print_intro() -> None:
print(" " * 33 + "BOMBARDMENT")
print(" " * 15 + " CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
print("\n\n")
print("YOU ARE ON A BATTLEFIELD WITH 4 PLATOONS AND YOU")
print("HAVE 25 OUTPOSTS AVAILABLE WHERE THEY MAY BE PLACED.")
@@ -28,7 +28,6 @@ def display_field() -> None:
for row in range(5):
initial = row * 5 + 1
print("\t".join([str(initial + column) for column in range(5)]))
print("\n" * 9)
@@ -128,8 +127,8 @@ ENEMY_PROGRESS_MESSAGES = (
)
def play() -> None:
display_intro()
def main() -> None:
print_intro()
display_field()
enemy_positions = generate_enemy_positions()
@@ -162,4 +161,4 @@ def play() -> None:
if __name__ == "__main__":
play()
main()