-
Notifications
You must be signed in to change notification settings - Fork 0
/
shadowdark.py
403 lines (367 loc) · 15.6 KB
/
shadowdark.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
###############################
# Shadowsdark.py 1.1 #
# By Chris Stoddard, Aug 2023 #
# Based on the Shadowdark RPG #
# by Arcane Library #
# This code is licensed under #
# the Creative Commons #
# Attribution-NonCommercial #
# 4.0 License. #
###############################
###############################
# Import needed libraries
import random
###############################
# Define functions
# 4d6 take the best 3 for rolling ability scores
def roll_4d6():
dice_rolls = [random.randint(1, 6) for _ in range(4)]
return sum(sorted(dice_rolls, reverse=True)[:3])
# 3d6 for rolling ability scores
def roll_3d6():
dice_rolls = [random.randint(1, 6) for _ in range(3)]
return sum(sorted(dice_rolls, reverse=True)[:3])
# Rolls 2d6 for various purposes
def roll_2d6():
dice_rolls = [random.randint(1, 6) for _ in range(2)]
return sum(sorted(dice_rolls, reverse=True)[:2])
###############################
# Print Legal Statement.
print ("-------------------------------------------------------")
print ("Legal Statement:")
print ("This Shadowdark Character Generator is an independent")
print ("product published under the Shadowdark RPG Third-Party")
print ("License and is not affiliated with The Arcane Library,")
print ("LLC. Shadowdark RPG © 2023 The Arcane Library, LLC.")
print ("-------------------------------------------------------")
###############################
# Roll ability scores
print ('\n')
print ("Choose which method of attribute generation you want to use:")
print (" 1 Roll 3d6 for attributes")
print (" 2 Roll 4d6 take the best 3 for attributes")
RollChoice = input ("? ")
if RollChoice == "2":
ability_scores = [roll_4d6() for _ in range(6)]
if RollChoice == "1":
ability_scores = [roll_3d6() for _ in range(6)]
###############################
# Sort out what number go where
# Assign Ability Scores
Strength = (ability_scores[0])
Dexterity = (ability_scores[1])
Constitution = (ability_scores[2])
Intellegence = (ability_scores[3])
Wisdom = (ability_scores[4])
Charisma = (ability_scores[5])
# Determines Modifiers
counter = range(6)
for count in counter:
temp = ability_scores[count]
if temp == 3:
temp_mod = "-4"
if temp == 4 or temp == 5:
temp_mod = "-3"
if temp == 6 or temp == 7:
temp_mod = "-2"
if temp == 8 or temp == 9:
temp_mod = "-1"
if temp == 10 or temp == 11:
temp_mod = "0"
if temp == 12 or temp == 13:
temp_mod = "+1"
if temp == 14 or temp == 15:
temp_mod = "+2"
if temp == 16 or temp == 17:
temp_mod = "+3"
if temp == 18:
temp_mod = "+4"
# Assign Modifiers
if count == 0:
Strength_mod = temp_mod
if count == 1:
Dexterity_mod = temp_mod
if count == 2:
Constitution_mod = temp_mod
if count == 3:
Intellegence_mod = temp_mod
if count == 4:
Wisdom_mod = temp_mod
if count == 5:
Charisma_mod = temp_mod
###############################
# Print Ability scores to screen
print ('\n')
print ("STR: " + str(Strength) + " / " + Strength_mod)
print ("DEX: " + str(Dexterity) + " / " + Dexterity_mod)
print ("CON: " + str(Constitution) + " / " + Constitution_mod)
print ("INT: " + str(Intellegence) + " / " + Intellegence_mod)
print ("WIS: " + str(Wisdom) + " / " + Wisdom_mod)
print ("CHR: " + str(Charisma) + " / " + Charisma_mod)
YN = input ("Do you want to keep this character, Y or N? ")
if YN == "N" or YN == "n":
exit()
###############################
# Ancestry Section
print ('\n')
print ("Choose an Ancestry for your character:")
print (" 1 Dwarf")
print (" 2 Elf")
print (" 3 Goblin")
print (" 4 Half-Orc")
print (" 5 Halfling")
print (" 6 Human")
Choose_Ancestry = input ("? ")
if Choose_Ancestry == "1":
Ancestry = "Dwarf"
Language = "Common and Dwarvish"
AncestryFeature = "Stout. +2 HP at 1st level, each level there after, roll hit points with advantage."
if Choose_Ancestry == "2":
Ancestry = "Elf"
Language = "Common, Elvish, and Sylvan"
AncestryFeature = "Farsight. Choose; +1 bonus to ranged weapon attacks or +1 bonus to spellcasting checks."
if Choose_Ancestry == "3":
Ancestry = "Goblin"
Language = "Common and Goblin"
AncestryFeature = "Keen Senses. Character cannot be surprised."
if Choose_Ancestry == "4":
Ancestry = "Half-Orc"
Language = "Common and Orcish"
AncestryFeature = "Mighty. +1 bonus to hit and damage with melee weapons."
if Choose_Ancestry == "5":
Ancestry = "Halfling"
Language = "Common"
AncestryFeature = "Stealthy. You become invisible for 3 rounds, use this ability once per day"
if Choose_Ancestry == "6":
Ancestry = "Human"
Language = "Common and one additional common language."
AncestryFeature = "Ambitious. Roll one additional on the talent table at 1st level."
###############################
# Class Section
print ('\n')
print ("Choose a Class for your character:")
print (" 1 Fighter")
print (" 2 Priest")
print (" 3 Thief")
print (" 4 Wizard")
print (" 5 Zero Level")
Choose_Class = input ("? ")
if Choose_Class == "1":
Class = "Fighter"
HITPOINTS = random.randint(1, 8)
Weapon = "Weapons: All weapons"
Armor = "Armor: All armor and shields"
ClassFeature1 = "Hauler. You gain additional gear slots equal to you Constitution modifier, if positive."
ClassFeature2 = "Weapon Mastery. With one type of weapon, you gain +1 to attack and damage with that weapon type. Also, add half your level to attack and damage rolls (round down)."
ClassFeature3 = "Grit. Choose Strength or Dexterity. You have advantage on checks based on that attribute."
talent_roll_sum = (roll_2d6())
if talent_roll_sum == 2:
ClassTalent = "Gain Weapon Mastery with another weapon type"
if talent_roll_sum == 3 or talent_roll_sum == 4 or talent_roll_sum == 5 or talent_roll_sum == 6:
ClassTalent = "+1 bonus to melee and ranged attacks"
if talent_roll_sum == 7 or talent_roll_sum == 8 or talent_roll_sum == 9:
ClassTalent = "+2 bonus to Strength, Dexterity, or Constitution attribute"
if talent_roll_sum == 10 or talent_roll_sum == 11:
ClassTalent = "Choose one type of armor. You get +1 your AC when wearing that armor"
if talent_roll_sum == 12:
ClassTalent = "Choose a talent or +2 points to distribute to attributes"
if Choose_Class == "2":
Class = "Priest"
HITPOINTS = random.randint(1, 6)
Weapon = "Weapons: Club, crossbow, dagger, mace, longsword, staff, warhammer"
Armor = "Armor: All armor and shields"
Language = Language + " and you know either Celestial, Diabolic, or Primordial."
ClassFeature1 = "Turn Undead. You know the turn undead spell, this does not count toward your number of known spells."
ClassFeature2 = "Spellcasting. You can cast priest spells you have prepared."
ClassFeature3 = " "
talent_roll_sum = (roll_2d6())
if talent_roll_sum == 2:
ClassTalent = "Gain advantage with one spell you know, when roll to cast."
if talent_roll_sum == 3 or talent_roll_sum == 4 or talent_roll_sum == 5 or talent_roll_sum == 6:
ClassTalent = "+1 bonus to melee or ranged attacks"
if talent_roll_sum == 7 or talent_roll_sum == 8 or talent_roll_sum == 9:
ClassTalent = "+1 bonus to priest spellcasting checks"
if talent_roll_sum == 10 or talent_roll_sum == 11:
ClassTalent = "+2 to Strength or Wisdom attribute"
if talent_roll_sum == 12:
ClassTalent = "Choose a talent or +2 points to distribute to attributes"
if Choose_Class == "3":
Class = "Thief"
HITPOINTS = random.randint(1, 4)
Weapon = "Weapons: Club, crossbow, dagger, shortbow, shortsword"
Armor = "Armor: Leather armor, mithral chainmail"
ClassFeature1 = "Backstab. On successful attack roll, If the target is unaware of your attack, you deal an extra die of damage and an additional die of damage equal to half your level (round down)."
ClassFeature2 = "Thievery. You are trained thieving skills and have can carry the necessary tools at no equipment slot cost."
ClassFeature3 = "You are adept in the skills associated with thievery, you have advantage on any associated checks"
talent_roll_sum = (roll_2d6())
if talent_roll_sum == 2:
ClassTalent = "You have advantage on initiative rolls (reroll if duplicate)"
if talent_roll_sum == 3 or talent_roll_sum == 4 or talent_roll_sum == 5 or talent_roll_sum == 6:
ClassTalent = "Your Backstab deals +1 die of damage"
if talent_roll_sum == 7 or talent_roll_sum == 8 or talent_roll_sum == 9:
ClassTalent = "+2 bonus to Strength, Dexterity, or Charisma attribute"
if talent_roll_sum == 10 or talent_roll_sum == 11:
ClassTalent = "+1 bonus to melee and ranged attacks"
if talent_roll_sum == 12:
ClassTalent = "Choose a talent or +2 points to distribute to atributes"
if Choose_Class == "4":
Class = "Wizard"
HITPOINTS = random.randint(1, 4)
Weapon = "Weapons: Dagger, staff"
Armor = "Armor: None"
Language = Language + " and you know two additional common languages and two rare languages"
ClassFeature1 = "Learning Spells. You can learn new wizard spells from a scroll by studying it for a day and succeeding on a DC 15 INT check."
ClassFeature2 = "Spellcasting. You can cast wizard spells you have prepared."
ClassFeature3 = " "
talent_roll_sum = (roll_2d6())
if talent_roll_sum == 2:
ClassTalent = "Make a single random magic item of a type you choose"
if talent_roll_sum == 3 or talent_roll_sum == 4 or talent_roll_sum == 5 or talent_roll_sum == 6:
ClassTalent = "+2 to Intelligence attribute or +1 bonus to wizard spellcasting checks"
if talent_roll_sum == 7 or talent_roll_sum == 8 or talent_roll_sum == 9:
ClassTalent = "Gain advantage on casting a single spell you know"
if talent_roll_sum == 10 or talent_roll_sum == 11:
ClassTalent = "Learn one additional wizard spell of any tier you know"
if talent_roll_sum == 12:
ClassTalent = "Choose a talent or +2 points to distribute to attribute"
if Choose_Class == "5":
Class = "Zero Level"
HITPOINTS = 0
Weapon = "Weapons: All weapons until 1st level"
Armor = "Armor: All armor and shields until 1st level"
ClassFeature1 = "Beginner's luck, you can wield any and all equipment until 1st level."
ClassFeature2 = " "
ClassFeature3 = " "
ClassTalent = " "
###############################
# Modify hit Points by Constitution
if Constitution_mod == "-1":
HITPOINTS = HITPOINTS - 1
if Constitution_mod == "-2":
HITPOINTS = HITPOINTS - 2
if Constitution_mod == "-3":
HITPOINTS = HITPOINTS - 3
if Constitution_mod == "-4":
HITPOINTS = HITPOINTS - 4
if Constitution_mod == "+1":
HITPOINTS = HITPOINTS + 1
if Constitution_mod == "+2":
HITPOINTS = HITPOINTS + 2
if Constitution_mod == "+3":
HITPOINTS = HITPOINTS + 3
if Constitution_mod == "+4":
HITPOINTS = HITPOINTS + 4
if HITPOINTS < 1:
HITPOINTS = 1
###############################
# Randomly chooses background
Random_Backgrounds = ['Urchin','Wanted', 'Cult Initiate', 'Thieves Guild', 'Banished', 'Orphaned', 'Wizards Apprentice', 'Jeweler', 'Herbalist', 'Barbarian', 'Mercenary', 'Sailor', 'Alcolyte', 'Soldier', 'Ranger', 'Scout', 'Minstrel', 'Scholar', 'Nobel', 'Chirurgeon' ]
Background = random.choice(Random_Backgrounds)
###############################
# Choose Alignment
print ('\n')
print ("Choose an Alignment for your character:")
print (" 1 Chaotic")
print (" 2 Lawful")
print (" 3 Neutral")
Choose_Alignment = input ("? ")
if Choose_Alignment == "1":
Alignment = "Chaotic"
if Choose_Alignment == "2":
Alignment = "Lawful"
if Choose_Alignment == "3":
Alignment = "Neutral"
###############################
# Generate Starting gold or random equipment for Zero level character
if Choose_Class == "5":
Equipment_List = (" ")
Random_Equipment = ['Torch,', 'Dagger,', 'Pole,', 'Shortbow and 5 arrows,', '60 Feet of Rope,', 'Flask of Oil,', 'Crowbar,', 'Iron spikes x10,', 'Flint and steel,', 'Grappling hook,', 'Club,', 'Bag of Caltrops,']
Equipment_Count = random.randint(1, 4)
counter = range(Equipment_Count)
for count in counter:
Equipment_Item = random.choice(Random_Equipment)
Equipment_List = (Equipment_List + " " + Equipment_Item)
else:
Starting_Gold = (roll_2d6())
Starting_Gold = (Starting_Gold * 5)
Equipment_List = (str(Starting_Gold) + " Gold Pieces")
###############################
# Prints out the finished character to the screen
print ('\n')
Character_name = input ("What is your characters name? ")
print ('\n')
print ("Shadowdark Character Sheet 1.1")
print ("------------------------------")
print ("Character Name: " + Character_name)
print ("Ancestry " + Ancestry)
print ("Background: " + Background)
print ("Alignment: " + Alignment)
print ("Deity: _______________________")
print ("Character Class: " + Class)
print ("XP: _____")
print ("Level: _____")
print ("------------------------------")
print ("STR: " + str(Strength) + " / " + Strength_mod)
print ("DEX: " + str(Dexterity) + " / " + Dexterity_mod)
print ("CON: " + str(Constitution) + " / " + Constitution_mod)
print ("INT: " + str(Intellegence) + " / " + Intellegence_mod)
print ("WIS: " + str(Wisdom) + " / " + Wisdom_mod)
print ("CHR: " + str(Charisma) + " / " + Charisma_mod)
print ('\n')
print ("Hit Points: " + str(HITPOINTS))
print ('\n')
print ("------------------------------")
print ("Ancestry Feature: " + AncestryFeature)
print ("Languages: " + Language)
print ("Class Features:")
print (" " + Weapon)
print (" " + Armor)
print (" " + ClassFeature1)
print (" " + ClassFeature2)
print (" " + ClassFeature3)
print ("Class Talent: " + ClassTalent)
print ("------------------------------")
print ("EQUIPMENT:")
print (Equipment_List)
###############################
# Write character to a text file using the character name
YN = input ("Do you want to save this character to a text file, Y or N? ")
if YN == "N" or YN == "n":
exit()
with open(Character_name + '.txt', 'w') as f:
f.write ('\n')
f.write ("Shadowdark Character Sheet 1.1" + '\n')
f.write ("------------------------------" + '\n')
f.write ("Character Name: " + Character_name + '\n')
f.write ("Ancestry " + Ancestry + '\n')
f.write ("Background: " + Background + '\n')
f.write ("Alignment: " + Alignment + '\n')
f.write ("Deity: _______________________" + '\n')
f.write ("Character Class: " + Class + '\n')
f.write ("XP: _____" + '\n')
f.write ("Level: _____" + '\n')
f.write ("------------------------------" + '\n')
f.write ('\n')
f.write ("STR: " + str(Strength) + " / " + Strength_mod + '\n')
f.write ("DEX: " + str(Dexterity) + " / " + Dexterity_mod + '\n')
f.write ("CON: " + str(Constitution) + " / " + Constitution_mod + '\n')
f.write ("INT: " + str(Intellegence) + " / " + Intellegence_mod + '\n')
f.write ("WIS: " + str(Wisdom) + " / " + Wisdom_mod + '\n')
f.write ("CHR: " + str(Charisma) + " / " + Charisma_mod + '\n')
f.write ('\n')
f.write ("Hit Points: " + str(HITPOINTS) + '\n')
f.write ('\n')
f.write ("------------------------------" + '\n')
f.write ("Ancestry Feature: " + AncestryFeature + '\n')
f.write ("Languages: " + Language + '\n')
f.write ("Class Features:" + '\n')
f.write (" " + Weapon + '\n')
f.write (" " + Armor + '\n')
f.write (" " + ClassFeature1 + '\n')
f.write (" " + ClassFeature2 + '\n')
f.write (" " + ClassFeature3 + '\n')
f.write ("Class Talent: " + ClassTalent + '\n')
f.write ("------------------------------" + '\n')
f.write ("EQUIPMENT:" + '\n')
f.write (Equipment_List)
exit()