Advertisement
MeckeOfficial

Farkle Point Logic

May 13th, 2024
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. def calc_points(points):
  2.  
  3.     result = 0
  4.  
  5.     score = {
  6.         "1":0,
  7.         "2":0,
  8.         "3":0,
  9.         "4":0,
  10.         "5":0,
  11.         "6":0,
  12.     }
  13.  
  14.     for p in points:
  15.         score[str(p)] += 1
  16.  
  17.     a = score["1"]
  18.     b = score["2"]
  19.     c = score["3"]
  20.     d = score["4"]
  21.     e = score["5"]
  22.     f = score["6"]
  23.  
  24.     if a and b and c and d and e and f == 1:
  25.         result += 1500
  26.        
  27.     elif a and b and c and d and e >= 1:
  28.  
  29.         if a == 2:
  30.             result += 100
  31.         elif e == 2:
  32.             result += 50
  33.        
  34.         result += 500
  35.    
  36.     elif b and c and d and e and f >= 1:
  37.  
  38.         if a == 2:
  39.             result += 100
  40.         elif e == 2:
  41.             result += 50
  42.        
  43.         result += 750
  44.  
  45.     for k in score:
  46.         if score[k] < 3:
  47.  
  48.             if int(k) == 1:
  49.                 result += 100 * score[k]
  50.             elif int(k) == 5:
  51.                 result += 50 * score[k]
  52.  
  53.         if score[k] == 3:
  54.             if int(k) == 1:
  55.                 result += 1000
  56.             else:
  57.                 result += int(k) * 100
  58.  
  59.         elif score[k] == 4:
  60.             if int(k) == 1:
  61.                 result += 2000
  62.             else:
  63.                 result += int(k) * 100 * 2
  64.  
  65.         elif score[k] == 5:
  66.             if int(k) == 1:
  67.                 result += 4000
  68.             else:
  69.                 result += int(k) * 100 * 4
  70.  
  71.         elif score[k] == 6:
  72.             if int(k) == 1:
  73.                 result += 8000
  74.             else:
  75.                 result += int(k) * 100 * 8
  76.  
  77.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement