Advertisement
angeldp

pretty_shown_crew

Jan 2nd, 2024 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.83 KB | None | 0 0
  1. def pretty_shown_crew(crew):
  2.     """
  3.    Shows crew and threat as a ASCII dice roll
  4.  
  5.    Parameters
  6.    ----------
  7.    crew : array or int
  8.        Result of the dice roll.
  9.  
  10.    Returns
  11.    -------
  12.    None.
  13.  
  14.    """
  15.     # Threat's dice sides in ascii
  16.     PRETTY_DICE = {
  17.         1: (
  18.             "┌─────────┐",
  19.             "│         │",
  20.             "│    ●    │",
  21.             "│         │",
  22.             "└─────────┘",
  23.         ),
  24.         2: (
  25.             "┌─────────┐",
  26.             "│  ●      │",
  27.             "│         │",
  28.             "│      ●  │",
  29.             "└─────────┘",
  30.         ),
  31.         3: (
  32.             "┌─────────┐",
  33.             "│  ●      │",
  34.             "│    ●    │",
  35.             "│      ●  │",
  36.             "└─────────┘",
  37.         ),
  38.         4: (
  39.             "┌─────────┐",
  40.             "│  ●   ●  │",
  41.             "│         │",
  42.             "│  ●   ●  │",
  43.             "└─────────┘",
  44.         ),
  45.         5: (
  46.             "┌─────────┐",
  47.             "│  ●   ●  │",
  48.             "│    ●    │",
  49.             "│  ●   ●  │",
  50.             "└─────────┘",
  51.         ),
  52.         6: (
  53.             "┌─────────┐",
  54.             "│  ●   ●  │",
  55.             "│  ●   ●  │",
  56.             "│  ●   ●  │",
  57.             "└─────────┘",
  58.         ),
  59.     }
  60.     # Crew dice sides in ascii
  61.     PRETTY_CREW = {
  62.         1: (
  63.             "┌─────────┐",
  64.             "│  \\\\ //  │",  # SCAPE \
  65.             "│   \\▼/   │",   # SCAPE \
  66.             "│   └│┘   │",
  67.             "│    ║   1│",
  68.             "└─────────┘",
  69.         ),
  70.         2: (
  71.             "┌─────────┐",
  72.             "│    ▲    │",
  73.             "│   /█\\   │",   # SCAPE \
  74.             "│    ║    │",
  75.             "│    │   2│",
  76.             "└─────────┘",
  77.         ),
  78.         3: (
  79.             "┌─────────┐",
  80.             "│   ╞█╡   │",
  81.             "│ ╞█► ◄█╡ │",
  82.             "│   ╞█╡   │",
  83.             "│        3│",
  84.             "└─────────┘",
  85.         ),
  86.         4: (
  87.             "┌─────────┐",
  88.             "│   O__   │",
  89.             "│    __ ● │",
  90.             "│ ╔╗/     │",
  91.             "│ ╚╝     4│",
  92.             "└─────────┘",
  93.         ),
  94.         5: (
  95.             "┌─────────┐",
  96.             "│ ╔╪╗     │",
  97.             "│ ╠ ╣     │",
  98.             "│ ╚╪╝ ╔╗  │",
  99.             "│     ╚╝ 5│",
  100.             "└─────────┘",
  101.         ),
  102.         6: (
  103.             "┌────╥────┐",
  104.             "│    ║    │",
  105.             "│   ╔╩╗   │",
  106.             "│   ║☺║   │",
  107.             "│   ╚═╝  6│",
  108.             "└─────────┘",
  109.         ),
  110.     }
  111.  
  112.     # If the function receives an array, use the crew dice.
  113.     if isinstance(crew, list):
  114.         DICE = PRETTY_CREW
  115.         DICE_ROWS = len(DICE[1])
  116.         DICE_SEP = ' '
  117.         pretty_faces = []
  118.         for n in crew:
  119.             pretty_faces.append(DICE[n])
  120.             dice_faces_rows = []
  121.             for row_id in range(DICE_ROWS):
  122.                 row_components = []
  123.                 for die in pretty_faces:
  124.                     row_components.append(die[row_id])
  125.                 row_string = DICE_SEP.join(row_components)
  126.                 dice_faces_rows.append(row_string)
  127.         width = len(dice_faces_rows[0])
  128.         diagram_header = " CREW ".center(width, "~")
  129.         dice_faces_diagram = "\n".join([diagram_header] + dice_faces_rows)
  130.     # If the function receives an integer, it uses traditional dice.
  131.     if isinstance(crew, int):
  132.         DICE = PRETTY_DICE
  133.         DICE_ROWS = len(DICE[1])
  134.         DICE_SEP = ' '
  135.         pretty_faces = []
  136.         pretty_faces.append(DICE[crew])
  137.         dice_faces_rows = []
  138.         for row_id in range(DICE_ROWS):
  139.             row_components = []
  140.             for die in pretty_faces:
  141.                 row_components.append(die[row_id])
  142.             row_string = DICE_SEP.join(row_components)
  143.             dice_faces_rows.append(row_string)
  144.         width = len(dice_faces_rows[0])
  145.         diagram_header = " THREAT ".center(width, "~")
  146.         dice_faces_diagram = "\n".join([diagram_header] + dice_faces_rows)
  147.     # the result is shown
  148.     print(f"{dice_faces_diagram}\n")
  149.  
Tags: DeepSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement