-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvorogoth.py
executable file
·132 lines (115 loc) · 3.76 KB
/
vorogoth.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
#!/usr/bin/env python
import random
import sys
def roll(die, sides):
r = 0
for i in range(die):
r += random.randint(1,sides)
return r
def to_hit(mod):
result = roll(1,20)
if result == 20:
confirm = roll(1,20)+mod
print "Nat 20! Confirm: %s" % (confirm,)
if result == 1:
print "Nat 1!"
return result+mod
class Vorogoth(object):
def __init__(self):
self.acid_damage = []
self.attack = []
self.grabs = []
self.rend_hit = sys.maxint
def __clear(self):
self.acid_damage = []
self.attack = []
self.grabs = []
self.rend_hit = sys.maxint
def __acid(self, hit):
damage = roll(1,6)
self.acid_damage.append([hit, damage])
def __bite(self, enlarged=False):
hit = to_hit(13)
if enlarged:
damage = roll(3,6)+9
else:
damage = roll(1,8)+8 + roll(1,6)
self.attack.append([hit, damage])
return [hit, damage]
def __grab(self, enlarged=False):
if enlarged:
cmb = roll(1,20)+20
damage = roll(2,8)+roll(2,6)+18
else:
cmb = roll(1,20)+19
damage = roll(4,6)+16
return [cmb, damage]
def __claw(self, enlarged=False):
hit = to_hit(13)
if enlarged:
damage = roll(4,6)+9
else:
damage = roll(3,6)+8
if self.rend_hit > hit:
self.rend_hit = hit
self.attack.append([hit, damage])
return [hit, damage]
def __rend(self, enlarged=False):
if enlarged:
damage = roll(4,6)+13
else:
damage = roll(3,6)+12
self.attack.append([self.rend_hit, damage])
return damage
def bite(self, enlarged=False):
r = self.__bite(enlarged)
print " Bite AC %s [%s] for %s [%s] damage" % (r[0], r[0]-2, r[1], r[1]+4)
def claw(self, enlarged=False):
r = self.__claw(enlarged)
s = self.__grab(enlarged=enlarged)
self.grabs.append([r[0], s[0], s[1]])
print " Claw AC %s [%s] for %s [%s] damage" % (r[0], r[0]-2, r[1], r[1]+4)
print " Grab CMD %s [%s] for %s [%s] damage" % (s[0], s[0]-2, s[1], s[1]+4)
def rend(self, enlarged=False):
r = self.__rend(enlarged)
rend_hit = self.rend_hit
print " Rend AC %s [%s] for %s [%s] damage" % (rend_hit, rend_hit-2, r, r+4)
def attacks(self):
summed_attacks = set()
summed_grabs = set()
print
for rolls in self.attack:
hits = [x[1] for x in self.attack if x[0]>=rolls[0]]
summed_attacks.add((rolls[0], sum(hits), len(hits)))
for rolls in self.grabs:
#summed_grabs.add((rolls[0], rolls[1], sum([x[2] for x in self.grabs if x[0]>=rolls[0]])))
summed_grabs.add((rolls[0], rolls[1], rolls[2]))
for attack in sorted(summed_attacks):
print "Hit AC %s for %s damage over %s attacks" % (attack[0], attack[1], attack[2])
for grab in sorted(summed_grabs):
print "Grabbed AC %s CMD %s for %s damage over 2 attacks" % (grab[0], grab[1], grab[2])
def full_attack(self, enlarged=False):
self.__clear()
self.bite(enlarged)
self.claw(enlarged)
self.claw(enlarged)
self.rend(enlarged)
self.attacks()
def main():
v = Vorogoth()
print '-'*80
print 'Normal attack [Power attack]'
print '-'*80
print "Normal"
v.full_attack(enlarged=False)
print '-'*80
print "ENLARGED"
v.full_attack(enlarged=True)
print '-'*80
twenties = 'Have some twenties: '
for i in range(10):
twenties += '%s, ' % (roll(1,20),)
twenties += '%s' % (roll(1,20),)
print twenties
if __name__ == '__main__':
main()