-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitializer.py
97 lines (74 loc) · 2.47 KB
/
initializer.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
import random
import math
import keyboard
import time
from listHandling import *
def areYouTesting():
timer = 0
while timer < 100000:
if keyboard.is_pressed('s'):#standard
return True
timer += 1
else:
return False
def rollD20():
return random.randint(1, 20)
def createNPCfighters(combats,testing):
if testing:
numCombats = 9
hp = 9
else:
numCombats = int(input('How many enemys are there? ')) #npc count input
for idx in range(numCombats): # creates all npc combatants
idx = str(idx + 1)
name = 'Enemy' + ' ' + idx
if not testing:
hp = int(input('What is the hp of enemy %d? ' % (idx)))
name = combatant(name, 1, 2, hp)
combats.append(name)
return combats
def addPCs(combats,testing):
if testing:
numPlayers = 3
hp = 10
playerName = 'Testing!'
else:
numPlayers = int(input('How many PCs are there? '))
for idx in range(numPlayers):
if not testing:
hp = int(input('What is the current hp of %s? ' % (playerName)))
playerName = input('What is the name of PC %d? ' % (idx+1))
PC = combatant(playerName, 0, 2, hp)
combats.append(PC)
return combats
class combatant():
def __init__(self, name, enemOrFriend, dexMod, currentHP):
self.name = name
self.enemOrFriend = enemOrFriend
self.initiative = rollD20() + dexMod
self.hp = currentHP
self.status = set()
def makeAttack(self, roster):
while True:
try:
dmg = int(input('How much damage does this attack deal? '))
targetName = input('who is being attacked?')
break
except ValueError:
print('\nPlease enter the right type of data.\n')
for fighter in roster:
if fighter.name == targetName:
fighter.hp -= dmg
roster = removeTheDead(roster)
return roster
def applyStatus(self,roster,status,targetName):
while True:
try:
statusEff = input('What status effect has been applyed?')
targetName = input('And who has it been applied to?')
break
except ValueError:
print('\nPlease enter the right type of data.\n')
for fighter in roster:
if fighter.name == targetName:
fighter.status.add(status)