Advertisement
angeldp

assign_crew

Jan 2nd, 2024 (edited)
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. def assign_crew(crew):
  2.     """
  3.    If there are commanders in the roll, it is responsible for updating the
  4.    crew and, in any case, calls the functions of each crew member with
  5.    the number of them available.
  6.  
  7.    Parameters
  8.    ----------
  9.    crew : array
  10.        Result of the dice roll.
  11.  
  12.    Returns
  13.    -------
  14.    None.
  15.  
  16.    """
  17.     # The new crew
  18.     ncrew = []
  19.     # Number of crew members of each type
  20.     tacticn = 0
  21.     doctorn = 0
  22.     scientistn = 0
  23.     engineern = 0
  24.     # in search of the commander
  25.     for i in range(len(crew)):
  26.         if crew[i] == 1:
  27.             ncrew = commander(crew)
  28.     # Crew update if modified
  29.     if len(ncrew) != 0:
  30.         crew = ncrew
  31.     # For the rest of the tasks, the appropriate functions are called
  32.     # with the number of crew members of each type.
  33.     for i in range(len(crew)):
  34.         if crew[i] == 2:
  35.             tacticn += 1
  36.         elif crew[i] == 3:
  37.             doctorn += 1
  38.         elif crew[i] == 4:
  39.             scientistn += 1
  40.         elif crew[i] == 5:
  41.             engineern += 1
  42.     if tacticn > 0:
  43.         tactic(tacticn)
  44.     if doctorn > 0:
  45.         doctor(doctorn)
  46.     if scientistn > 0:
  47.         scientist(scientistn)
  48.     if engineern > 0:
  49.         engineer(engineern)
Tags: DeepSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement