forked from cosmicr/startrek1971
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDifficulity.py
49 lines (42 loc) · 1.04 KB
/
Difficulity.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
import random
class Probabilities:
'''
Extracting allows for easier customization.
'''
_LEVEL = 4
RANDOM = -1
NAV = 0
SRS = 1
LRS = 2
SHIELDS = 3
COMPUTER = 4
PHOTON = 5
PHASERS = 6
@staticmethod
def set_difficulity(game, level):
'''
The HIGHER the level, the MORE difficult
the game will be. 0 = EASY, 6 = HIGHEST
'''
if level < 0: level = 0
if level > 6: level = 6
Probabilities._LEVEL = level
@staticmethod
def calc_damage(game, item):
'''
How mch damage?
'''
return random.randint(1, 3)
@staticmethod
def should_damage_enterprise(game, item):
'''
Should we damage?
Lowest level (above) eliminates damage to ITEM
'''
if game.is_testing:
return False
if item == Probabilities.SHIELDS:
return False
if random.randint(0, 6) < Probabilities._LEVEL:
return True
return False