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 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. class Character:
  22. def __init__(self):
  23. self.name = ""
  24. self.career = ""
  25. self.stats = []
  26. def generate(self):
  27. self.gen_name()
  28. self.gen_stats()
  29. self.gen_career()
  30. def gen_name(self):
  31. self.name = gen_name()
  32. def gen_stats(self, n=12):
  33. if n < 4:
  34. print("Too few stat points!")
  35. return [0,0,0,0]
  36. stats = [0,0,0,0]
  37. points = n
  38. slots = [0,1,2,3]
  39. for _ in range(points):
  40. tgl = False
  41. while tgl == False:
  42. slt = r.choice(slots)
  43. if slt <= 1:
  44. if stats[slt] == 6:
  45. continue
  46. if stats[slt] == 5:
  47. if r.randint(0,1) != 1:
  48. continue
  49. else:
  50. if stats[slt] == 6:
  51. continue
  52. if stats[slt] == 5:
  53. if r.randint(0,3) != 1:
  54. continue
  55. if stats[slt] == 4:
  56. if r.randint(0,2) != 1:
  57. continue
  58. if stats[slt] == 3:
  59. if r.randint(0,1) != 1:
  60. continue
  61. stats[slt] += 1
  62. tgl = True
  63. stats[3] = stats[3] + 2
  64. if stats[3] > 6:
  65. stats[3] = 6
  66. stats[2] = stats[2] + 2
  67. if stats[2] > 6:
  68. stats[2] = 6
  69. self.stats = stats
  70. def gen_career(self):
  71. self.career = r.choice(["Soldier/Guard","Pilot","Medic","Mechanic","Politician","Spellcaster","Performer","Historian","Spy","Cook","Cartographer","Inventor","Merchant"])
  72. def print_name(self):
  73. print(f"Name: {self.name} (Kobold {self.career})")
  74. def print(self):
  75. self.print_name()
  76. print(f"Order: {self.stats[0]}")
  77. print(f"Chaos: {self.stats[1]}")
  78. print(f"Brain: {self.stats[2]}")
  79. print(f"Body: {self.stats[3]}")
  80. class Ship:
  81. def __init__(self):
  82. self.name1 = r.choice(["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"])
  83. self.name2 = r.choice(["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"])
  84. 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"])
  85. 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"])
  86. self.fullname = f"{self.name1} {self.name2}"
  87. def print(self):
  88. print(f"The {self.fullname} {self.gqual}, but {self.bqual}.")
  89. class Campaign:
  90. def __init__(self, n=None):
  91. n = 6 if n == None else n
  92. self.ship = Ship()
  93. self.gen_plot()
  94. self.characters = []
  95. for _ in range(n):
  96. c = Character()
  97. c.generate()
  98. self.characters.append(c)
  99. self.art = "an" if self.params[1][0] in ["A","E","I","O","U"] else "a"
  100. def gen_plot(self):
  101. 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"]
  102. loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
  103. 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"]
  104. prob = ["an Undead Sample Pack (swarm of zombies and skeletons)","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"]
  105. pstats = {
  106. "an Undead Sample Pack (swarm of zombies and skeletons)": [0,5,2,6],
  107. "a rival band of kobolds": [3,3,4,4],
  108. "a detachment from the Elf Armada": [4,3,5,4],
  109. "refugees with parasites. Big parasites": [2,4,0,0],
  110. "an artificial intelligence bent on multi-world domination": [4,1,6,3],
  111. "robot spiders": [3,3,2,4],
  112. "semi-intelligent metal eating slime": [0,2,1,5],
  113. "a living asteroid that intends to follow the kobolds home like the largest puppy": [2,3,1,6],
  114. "an old lich that wants everyone to stay off of their “lawn”": [5,2,6,3],
  115. "elder gods hailing from the dark spaces between the stars": [6,6,6,6],
  116. "Reroll": [2,3,6,1]
  117. }
  118. cl1 = r.choice(loc1)
  119. cl2 = r.choice(loc2)
  120. cm = r.choice(miss)
  121. cp = r.choice(prob)
  122. cs1 = pstats[cp]
  123. cs2 = None
  124. cs3 = None
  125. if cp == "refugees with parasites. Big parasites":
  126. cs2 = [3,4,2,3]
  127. if cl2 == "Reroll":
  128. cl2p = r.choice(loc2[:-1])
  129. if cl2p == "Asteroid":
  130. cl2 = "battlefield on an asteroid"
  131. else:
  132. cl2 = "battlefield on a " + cl2p
  133. if cm == "Reroll":
  134. cm = "to ...well, the kobolds weren't paying attention, so don't tell them, but they're supposed to " + r.choice(miss[:-1])
  135. if cp == "Reroll":
  136. newprob = r.choice(prob[:-1])
  137. if newprob == "refugees with parasites. Big parasites":
  138. cs3 = [3,4,2,3]
  139. cs2 = pstats[newprob]
  140. cp = "a Floating Brain Monster and its minion, " + newprob
  141. self.params = [cl1, cl2, cm, cp, cs1, cs2, cs3]
  142. def print_params(self, endc=""):
  143. st = ["Order:", "Chaos:", "Brains:", "Body:"]
  144. print(f"The Kobolds of the {self.ship.fullname} ", end=endc)
  145. print(f"have been sent out to {self.art} {self.params[0]} {self.params[1]} ", end=endc)
  146. print(f"in order {self.params[2]} ", end=endc)
  147. print(f"-- but they're challenged by {self.params[3]}!")
  148. cst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[4]]))])
  149. print(f"The challenger's stats: {cst}")
  150. if self.params[5] != None:
  151. mst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[5]]))])
  152. if self.params[3][0] == "r":
  153. print(f"- The parasites' stats: {mst}")
  154. else:
  155. print(f"- Its minion's stats: {mst}")
  156. if self.params[6] != None:
  157. pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params[6]]))])
  158. print(f"- - The parasites' stats: {pst}")
  159. print()
  160. self.ship.print()
  161. def print_chars(self):
  162. print("The kobolds:")
  163. for k in self.characters:
  164. k.print()
  165. if __name__ == "__main__":
  166. parser = argparse.ArgumentParser()
  167. group = parser.add_mutually_exclusive_group()
  168. group.add_argument("-c", "--campaign", help="print a full campaign block with N kobolds (default 6)", nargs="?", const=6, type=int, metavar="N")
  169. group.add_argument("-k", "--kobolds", help="print N kobolds", type=int, nargs="?", const=1, default=1, metavar="N")
  170. group.add_argument("-n", "--names", help="print N kobolds without stat blocks", nargs="?", const=1, type=int, metavar="N")
  171. group.add_argument("-p", "--params", help="print only the parameters of a campaign", action="store_true")
  172. group.add_argument("-s", "--ship", help="print only the ship name and description", action="store_true")
  173. args = parser.parse_args()
  174. # print(args)
  175. if args.campaign:
  176. cmp = Campaign(args.campaign)
  177. cmp.print_params()
  178. cmp.print_chars()
  179. elif args.params:
  180. cmp = Campaign()
  181. cmp.print_params()
  182. elif args.ship:
  183. ship = Ship()
  184. ship.print()
  185. elif args.names:
  186. for _ in range(args.names):
  187. c = Character()
  188. c.generate()
  189. c.print_name()
  190. else:
  191. for _ in range(args.kobolds):
  192. c = Character()
  193. c.generate()
  194. c.print()