Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pretty_shown_crew(crew):
- """
- Shows crew and threat as a ASCII dice roll
- Parameters
- ----------
- crew : array or int
- Result of the dice roll.
- Returns
- -------
- None.
- """
- # Threat's dice sides in ascii
- PRETTY_DICE = {
- 1: (
- "┌─────────┐",
- "│ │",
- "│ ● │",
- "│ │",
- "└─────────┘",
- ),
- 2: (
- "┌─────────┐",
- "│ ● │",
- "│ │",
- "│ ● │",
- "└─────────┘",
- ),
- 3: (
- "┌─────────┐",
- "│ ● │",
- "│ ● │",
- "│ ● │",
- "└─────────┘",
- ),
- 4: (
- "┌─────────┐",
- "│ ● ● │",
- "│ │",
- "│ ● ● │",
- "└─────────┘",
- ),
- 5: (
- "┌─────────┐",
- "│ ● ● │",
- "│ ● │",
- "│ ● ● │",
- "└─────────┘",
- ),
- 6: (
- "┌─────────┐",
- "│ ● ● │",
- "│ ● ● │",
- "│ ● ● │",
- "└─────────┘",
- ),
- }
- # Crew dice sides in ascii
- PRETTY_CREW = {
- 1: (
- "┌─────────┐",
- "│ \\\\ // │", # SCAPE \
- "│ \\▼/ │", # SCAPE \
- "│ └│┘ │",
- "│ ║ 1│",
- "└─────────┘",
- ),
- 2: (
- "┌─────────┐",
- "│ ▲ │",
- "│ /█\\ │", # SCAPE \
- "│ ║ │",
- "│ │ 2│",
- "└─────────┘",
- ),
- 3: (
- "┌─────────┐",
- "│ ╞█╡ │",
- "│ ╞█► ◄█╡ │",
- "│ ╞█╡ │",
- "│ 3│",
- "└─────────┘",
- ),
- 4: (
- "┌─────────┐",
- "│ O__ │",
- "│ __ ● │",
- "│ ╔╗/ │",
- "│ ╚╝ 4│",
- "└─────────┘",
- ),
- 5: (
- "┌─────────┐",
- "│ ╔╪╗ │",
- "│ ╠ ╣ │",
- "│ ╚╪╝ ╔╗ │",
- "│ ╚╝ 5│",
- "└─────────┘",
- ),
- 6: (
- "┌────╥────┐",
- "│ ║ │",
- "│ ╔╩╗ │",
- "│ ║☺║ │",
- "│ ╚═╝ 6│",
- "└─────────┘",
- ),
- }
- # If the function receives an array, use the crew dice.
- if isinstance(crew, list):
- DICE = PRETTY_CREW
- DICE_ROWS = len(DICE[1])
- DICE_SEP = ' '
- pretty_faces = []
- for n in crew:
- pretty_faces.append(DICE[n])
- dice_faces_rows = []
- for row_id in range(DICE_ROWS):
- row_components = []
- for die in pretty_faces:
- row_components.append(die[row_id])
- row_string = DICE_SEP.join(row_components)
- dice_faces_rows.append(row_string)
- width = len(dice_faces_rows[0])
- diagram_header = " CREW ".center(width, "~")
- dice_faces_diagram = "\n".join([diagram_header] + dice_faces_rows)
- # If the function receives an integer, it uses traditional dice.
- if isinstance(crew, int):
- DICE = PRETTY_DICE
- DICE_ROWS = len(DICE[1])
- DICE_SEP = ' '
- pretty_faces = []
- pretty_faces.append(DICE[crew])
- dice_faces_rows = []
- for row_id in range(DICE_ROWS):
- row_components = []
- for die in pretty_faces:
- row_components.append(die[row_id])
- row_string = DICE_SEP.join(row_components)
- dice_faces_rows.append(row_string)
- width = len(dice_faces_rows[0])
- diagram_header = " THREAT ".center(width, "~")
- dice_faces_diagram = "\n".join([diagram_header] + dice_faces_rows)
- # the result is shown
- print(f"{dice_faces_diagram}\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement