A character/one-shot generator for KOBOLDS IN SPACE!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

koboldgen.py 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import random as r
  2. import argparse
  3. beg = ["a","e","i","o","u","ba","be","bi","bo","bu","by","y","da","de","di","do","du","dy","fa","fi","fo","fe","fu","ga","ge","gi","go","gu","ka","ke","ki","ko","ku","ky","ma","me","mi","mo","mu","na","ne","ni","no","nu","pa","pe","pi","po","pu","ra","re","ri","ro","ru","ry","sa","se","si","so","su","ta","te","ti","to","tu","ty","wa","we","wi","wo","wy","za","ze","zi","zo","zu","zy"]
  4. mid = beg + ["l","x","n","r"]
  5. def gen_name(n=None):
  6. if n == None:
  7. lgt = r.randint(3,9)
  8. else:
  9. lgt = n
  10. morae = []
  11. while len("".join(morae)) < lgt:
  12. if len(morae) == 0:
  13. mora = r.choice(beg)
  14. morae.append(mora[0].upper() + mora[1:])
  15. else:
  16. mora = r.choice(mid)
  17. if morae[-1] == mora:
  18. mora = r.choice(mid)
  19. morae.append(mora)
  20. return "".join(morae)
  21. def gen_stats(n):
  22. if n < 4:
  23. print("Too few stat points!")
  24. return [0,0,0,0]
  25. stats = [1,1,1,1]
  26. points = n - 4
  27. slots = [0,1,2,3]
  28. for _ in range(points):
  29. tgl = False
  30. while tgl == False:
  31. slt = r.choice(slots)
  32. if stats[slt] == 6:
  33. continue
  34. if stats[slt] == 5:
  35. if r.randint(0,1) == 1:
  36. continue
  37. stats[slt] += 1
  38. tgl = True
  39. return stats
  40. def gen_career():
  41. return r.choice(["Soldier/Guard","Pilot","Medic","Mechanic","Politician","Spellcaster","Performer","Historian","Spy","Cook","Cartographer"])
  42. def gen_plot():
  43. loc1 = ["a friendly","a hostile","a derelict","an airless","a poison-filled/covered","an overgrown","a looted","a burning","a frozen","a haunted","an infested"]
  44. loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
  45. miss = ["to explore!","to loot everything not bolted down too securely","to find the last group of kobolds who came here","to find a rumored secret weapon","to find a way to break someone else’s secret weapon","to claim this place in the name of the Kobold Empire!","to make friends!","to rediscover lost technology","to find lost magical items","to find and defeat a powerful enemy","Reroll"]
  46. prob = ["an army of undead","a rival band of kobolds","a detachment from the Elf Armada","refugees with parasites. Big parasites","an artificial intelligence bent on multi-world domination","robot spiders","semi-intelligent metal eating slime","a living asteroid that intends to follow the kobolds home like the largest puppy","an old lich that wants everyone to stay off of their “lawn”","elder gods hailing from the dark spaces between the stars","Reroll"]
  47. cl1 = r.choice(loc1)
  48. cl2 = r.choice(loc2)
  49. cm = r.choice(miss)
  50. cp = r.choice(prob)
  51. if cl2 == "Reroll":
  52. cl2p = r.choice(loc2[:-1])
  53. if cl2p == "Asteroid":
  54. cl2 = "battlefield on an asteroid"
  55. else:
  56. cl2 = "battlefield on a " + cl2p
  57. if cm == "Reroll":
  58. cm = "to ...well, the kobolds weren't paying attention, so don't tell them, but they're supposed to " + r.choice(miss[:-1])
  59. if cp == "Reroll":
  60. cp = "a Floating Brain Monster and its minion, " + r.choice(prob[:-1])
  61. return [cl1, cl2, cm, cp]
  62. # def gen_transpo():
  63. # name1 = ["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"]
  64. # name2 = ["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"]
  65. # prop1 = ["is stealthy & unarmored","is speedy & unarmored","is maneuverable & unarmored","is always repairable","is self-repairing","is flamboyant & speedy","is slow & armored","is flamboyant & armored","is hard to maneuver & armored","has Too Many Weapons!","has a prototype hyperdrive"]
  66. # prop2 = ["has an annoying AI","has inconveniently crossed circuits","has an unpredictable power source","drifts to the right","is haunted","was recently 'found' so the kobolds are unused to it","is too cold","has a constant odd smell","its interior design... changes","its water pressure shifts between slow drip and power wash","it leaves a visible smoke trail"]
  67. # return [r.choice(name1), r.choice(name2), r.choice(prop1), r.choice(prop2)]
  68. class Character:
  69. def __init__(self):
  70. self.name = ""
  71. self.career = ""
  72. self.stats = []
  73. def generate(self):
  74. self.gen_name()
  75. self.gen_stats()
  76. self.gen_career()
  77. def gen_name(self):
  78. self.name = gen_name()
  79. def gen_stats(self):
  80. self.stats = gen_stats(12)
  81. def gen_career(self):
  82. self.career = gen_career()
  83. def print_name(self):
  84. print(f"Name: {self.name} (Kobold {self.career})")
  85. def print(self):
  86. self.print_name()
  87. print(f"Order: {self.stats[0]}")
  88. print(f"Chaos: {self.stats[1]}")
  89. print(f"Brain: {self.stats[2]}")
  90. print(f"Body: {self.stats[3]}")
  91. class Ship:
  92. def __init__(self):
  93. self.name1 = r.choice(["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"])
  94. self.name2 = r.choice(["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"])
  95. self.gqual = r.choice(["is stealthy & unarmored","is speedy & unarmored","is maneuverable & unarmored","is always repairable","is self-repairing","is flamboyant & speedy","is slow & armored","is flamboyant & armored","is hard to maneuver & armored","has Too Many Weapons!","has a prototype hyperdrive"])
  96. self.bqual = r.choice(["has an annoying AI","has inconveniently crossed circuits","has an unpredictable power source","drifts to the right","is haunted","was recently 'found' so the kobolds are unused to it","is too cold","has a constant odd smell","its interior design... changes","its water pressure shifts between slow drip and power wash","it leaves a visible smoke trail"])
  97. self.fullname = f"{self.name1} {self.name2}"
  98. def print(self):
  99. print(f"The {self.fullname} {self.gqual}, but {self.bqual}.")
  100. class Campaign:
  101. def __init__(self, n=None):
  102. n = 6 if n == None else n
  103. self.ship = Ship()
  104. self.params = gen_plot()
  105. self.characters = []
  106. for _ in range(n):
  107. c = Character()
  108. c.generate()
  109. self.characters.append(c)
  110. self.art = "an" if self.params[1][0] in ["A","E","I","O","U"] else "a"
  111. def print_params(self):
  112. print(f"The Kobolds of the {self.ship.fullname}")
  113. print(f"have been sent out to {self.art} {self.params[0]} {self.params[1]}")
  114. print(f"in order {self.params[2]}")
  115. print(f"but they're challenged by {self.params[3]}!")
  116. print()
  117. self.ship.print()
  118. def print_chars(self):
  119. print("The kobolds:")
  120. for k in self.characters:
  121. k.print()
  122. if __name__ == "__main__":
  123. parser = argparse.ArgumentParser()
  124. group = parser.add_mutually_exclusive_group()
  125. group.add_argument("-c", "--campaign", help="print a full campaign block with N kobolds (default 6)", nargs="?", const=6, type=int, metavar="N")
  126. group.add_argument("-k", "--kobolds", help="print N kobolds", type=int, nargs="?", const=1, default=1, metavar="N")
  127. group.add_argument("-n", "--names", help="print N kobolds without stat blocks", nargs="?", const=1, type=int, metavar="N")
  128. group.add_argument("-p", "--params", help="print only the parameters of a campaign", action="store_true")
  129. group.add_argument("-s", "--ship", help="print only the ship name and description", action="store_true")
  130. args = parser.parse_args()
  131. # print(args)
  132. if args.campaign:
  133. cmp = Campaign(args.campaign)
  134. cmp.print_params()
  135. cmp.print_chars()
  136. elif args.params:
  137. cmp = Campaign()
  138. cmp.print_params()
  139. elif args.ship:
  140. ship = Ship()
  141. ship.print()
  142. elif args.names:
  143. for _ in range(args.names):
  144. c = Character()
  145. c.generate()
  146. c.print_name()
  147. else:
  148. for _ in range(args.kobolds):
  149. c = Character()
  150. c.generate()
  151. c.print()