Advertisement
angeldp

scan_threats

Jan 2nd, 2024
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. def scan_threats(crew, scant, deck):
  2.     """
  3.    loops through the 'crew' array to get the number of sixes.
  4.    If 'scant' plus that number is less than 3 the variable 'scant'
  5.    is updated; If it is equal to or greater than 3, it calculates
  6.    the module of that value between 3 and saves it in 'scant'
  7.    and draws a new threat card [new_threat()].
  8.    It will have to do this as many times as the integer part
  9.    indicates by dividing the number of scanners by 3
  10.  
  11.    Parameters
  12.    ----------
  13.    crew : array
  14.        Result of the dice roll.
  15.    scant : int
  16.        Number of busy scanners. Value between 0 and 2.
  17.    Returns
  18.    -------
  19.    scant : int
  20.        Updated number of busy scanners. Value between 0 and 2.
  21.  
  22.    """
  23.     # 'n6' will store the number of sixes in 'crew'
  24.     n6 = 0
  25.     for i in crew:
  26.         if i == 6:
  27.             n6 += 1
  28.     # The number of scanners is updated
  29.     scant = scant + n6
  30.  
  31.     # If 'scant' is equal to or greater than 3,
  32.     # I draw as many threat cards as groups of 3
  33.     # have been obtained and I update scant
  34.     # with the rest of the division
  35.  
  36.     if scant >= 3:
  37.         rango = scant // 3
  38.         for n in range(rango):
  39.             new_threat(deck)
  40.         scant = scant % 3
  41.  
  42.     return scant
Tags: DeepSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement