repl.it
@Dablux/

Random Gun Stat Generator

Python

Generates guns with codependent stats

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import random

statsnames = ['Damage' ,'Range', 'RPM', 'Reload', 'Weight', 'Recoil', 'Stagger', 'Accuracy', 'Magazine']

def value(num):
  if num is None:
    return(0)
  if num < 34:
    return(1)
  elif num < 67:
    return(2)
  else:
    return(3)

def stats():
  stats = [0, 0, 0, 0, 0, 0, 0, 0, 0]
  seeds = []
  s1 = None
  s2 = None
  s3 = None

  for s in range(len(stats)):
    stats[s] = random.randint(10, 100) 

  s1 = random.randint(0, len(stats)-1)
  s2 = random.randint(0, len(stats)-1)
  s3 = random.randint(0, len(stats)-1)

  while s2 == s1:
    s2 = random.randint(0, len(stats)-1)
  while s3 == s1 or s3 == s2:
    s3 = random.randint(0, len(stats)-1)

  seeds.append(s1)
  seeds.append(s2)
  seeds.append(s3)

  for i in range(len(stats)):
    if i not in seeds:
      stats[i] = None

  for i in range(1):
    dmg = stats[0]
    rng = stats[1]
    rpm = stats[2]
    rld = stats[3]
    wgt = stats[4]
    rcl = stats[5]
    sgr = stats[6]
    acr = stats[7]
    mag = stats[8]

    #damage
    if sgr or mag or rng or rcl or acr is not None:
      if 0 not in seeds:
        dmg = round((value(sgr) + value(acr) - round(value(mag) / 2) + value(rng) + value(rcl)) / 5)
      if dmg <= 0:
        dmg = 1
    
    #range
    if dmg or acr or rcl or rpm is not None:
      if 1 not in seeds:
        rng = round((value(dmg) + value(acr) + value(rcl) - round(value(rpm) / 2)) / 4)
      if rng <= 0:
        rng = 1

    #rpm
    if mag or dmg or acr is not None:
      if 2 not in seeds:
        rpm = round((value(mag) * 2) - ((value(dmg) + value(acr)) / 4))
      if rpm <= 0:
        rpm = 1

    #reload
    if mag or wgt is not None:
      if 3 not in seeds:
        rld = round((value(mag) + value(wgt)) / 2)
      if rld <= 0:
        rld = 1

    #weight
    if mag or dmg or rcl is not None:
      if 4 not in seeds:
        wgt = round((value(mag) + value(dmg) - round(value(rcl) / 2)) / 3)
      if wgt <= 0:
        wgt = 1

    #recoil
    if wgt or mag or acr is not None:
      if 5 not in seeds:
        rcl = round((value(wgt) + value(mag) + value(acr)) / 3)
      if rcl <= 0:
        rcl = 1
    
    #stagger
    if dmg or acr or wgt or rcl is not None:
      if 6 not in seeds:
        sgr = round((value(dmg) + value(acr) + value(wgt) + value(rcl)) / 4)
      if sgr <= 0:
        sgr = 1
    
    #accuracy
    if rpm or wgt or dmg or rng is not None:
      if 7 not in seeds:
        acr = round((value(wgt) + value(dmg) + value(rng) - round(value(rpm) / 2)) / 4)
      if acr <= 0:
        acr = 1

    #magazine
    if rpm or wgt or dmg  or rld is not None:
      if 8 not in seeds:
        mag = round((value(wgt) + value(rld) - round(value(rpm) / 2) - round(value(dmg) / 2)) / 4)

    stats[0] = dmg
    stats[1] = rng
    stats[2] = rpm
    stats[3] = rld
    stats[4] = wgt
    stats[5] = rcl
    stats[6] = sgr
    stats[7] = acr
    stats[8] = mag

    print('defined')
    print(stats)

    for i in range(9):
      if stats[i] == 1:
        stats[i] = random.randint(10, 33)
      if stats[i] == 2:
        stats[i] = random.randint(34, 66)
      if stats[i] >= 3 and stats.index(stats[i]) not in seeds:
        stats[i] = random.randint(67, 100)

  print(stats)
  for i in range(3):
    print(statsnames[seeds[i]])
  
  return(stats)
      
stats()
Fetching token
?