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.

4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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(length=None, minimum=3, maximum=9):
  6. if length == None:
  7. lgt = r.randint(minimum,maximum)
  8. else:
  9. lgt = length
  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 Plot:
  22. loc1 = ["friendly","hostile","derelict","airless","poison-filled/covered","overgrown","looted","burning","frozen","haunted","infested"]
  23. loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
  24. 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"]
  25. prob = [
  26. {
  27. "id": 0,
  28. "name": "an Undead Sample Pack (swarm of zombies and skeletons)",
  29. "shortname": "undead",
  30. "stats": [0,5,2,6],
  31. },
  32. {
  33. "id": 1,
  34. "name": "a rival band of kobolds",
  35. "shortname": "kobold rivals",
  36. "stats": [3,3,4,4],
  37. },
  38. {
  39. "id": 2,
  40. "name": "a detachment from the Elf Armada",
  41. "shortname": "elves",
  42. "stats": [4,3,5,4],
  43. },
  44. {
  45. "id": 3,
  46. "name": "refugees with parasites. Big parasites",
  47. "shortname": "refugees",
  48. "stats": [2,4,0,0],
  49. },
  50. {
  51. "id": 4,
  52. "name": "an artificial intelligence bent on multi-world domination",
  53. "shortname": "AI",
  54. "stats": [4,1,6,3],
  55. },
  56. {
  57. "id": 5,
  58. "name": "robot spiders",
  59. "shortname": "spiders",
  60. "stats": [3,3,2,4],
  61. },
  62. {
  63. "id": 6,
  64. "name": "semi-intelligent metal eating slime",
  65. "shortname": "slime",
  66. "stats": [0,2,1,5],
  67. },
  68. {
  69. "id": 7,
  70. "name": "a living asteroid that intends to follow the kobolds home like the largest puppy",
  71. "shortname": "asteroid",
  72. "stats": [2,3,1,6],
  73. },
  74. {
  75. "id": 8,
  76. "name": "an old lich that wants everyone to stay off of their 'lawn'",
  77. "shortname": "lich",
  78. "stats": [5,2,6,3],
  79. },
  80. {
  81. "id": 9,
  82. "name": "elder gods hailing from the dark spaces between the stars",
  83. "shortname": "gods",
  84. "stats": [6,6,6,6],
  85. },
  86. {
  87. "id": 10,
  88. "name": "a Flying Brain Monster",
  89. "shortname": "Flying Brain Monster",
  90. "stats": [2,3,6,1],
  91. },
  92. ]
  93. def __init__(self):
  94. self.loc_desc = Plot.loc1[r.randint(0, len(Plot.loc1)-1)]
  95. self.locIndex = r.randint(0, len(Plot.loc2)-1)
  96. if self.locIndex == len(Plot.loc2) - 1:
  97. self.location = "battlefield on "
  98. self.locIndex = r.randint(0, len(Plot.loc2)-2)
  99. self.mainLocation = Plot.loc2[self.locIndex]
  100. if self.mainLocation[0].lower() in ["a","e","i","o","u"]:
  101. self.location += "an "
  102. else:
  103. self.location += "a "
  104. self.location += self.mainLocation
  105. else:
  106. self.location = Plot.loc2[self.locIndex]
  107. self.missIndex = r.randint(0, len(Plot.miss)-1)
  108. self.oops = r.randint(1,12)
  109. self.mission = ""
  110. if self.oops == 12:
  111. self.mission += "...well, they weren't paying attention, so don't tell them, but they're supposed "
  112. self.mission += Plot.miss[r.randint(0, len(Plot.miss)-1)]
  113. self.probIndex = r.randint(0, len(Plot.prob)-1)
  114. self.problem = Plot.prob[self.probIndex]
  115. self.secProblem = None
  116. self.thirdProblem = None
  117. if self.problem["id"] in [1,2]:
  118. self.problem["name"] += " led by " + gen_name()
  119. if self.problem["id"] in [4,7,8,10]:
  120. self.problem["name"] += " named " + gen_name(minimum=5, maximum=12)
  121. if self.problem["id"] == 3:
  122. self.secProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]}
  123. if self.problem["id"] == 10:
  124. self.secProbIndex = r.randint(0, len(Plot.prob)-2)
  125. self.secProblem = Plot.prob[self.secProbIndex]
  126. if self.secProbIndex == 3:
  127. self.thirdProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]}
  128. self.fullProblem = self.problem["name"]
  129. if self.secProblem and self.secProblem["name"] != "Parasites":
  130. self.fullProblem += " and its minion, " + self.secProblem["name"]
  131. class Character:
  132. def __init__(self):
  133. self.name = ""
  134. self.career = ""
  135. self.stats = []
  136. def generate(self):
  137. self.gen_name()
  138. self.gen_stats()
  139. self.gen_career()
  140. def gen_name(self):
  141. self.name = gen_name()
  142. def gen_stats(self, n=12):
  143. if n < 0:
  144. print("Too few stat points!")
  145. return [0,0,0,0]
  146. stats = [0,0,0,0]
  147. points = n
  148. slots = [0,1,2,3]
  149. for _ in range(points):
  150. tgl = False
  151. while tgl == False:
  152. slt = r.choice(slots)
  153. if slt <= 1:
  154. if stats[slt] == 6: continue
  155. if stats[slt] == 5 and r.randint(0,1) != 1: continue
  156. else:
  157. if stats[slt] == 6: continue
  158. if stats[slt] > 2 and r.randint(0,stats[slt]-2) != 1: continue
  159. stats[slt] += 1
  160. tgl = True
  161. stats[3] = stats[3] + 2
  162. if stats[3] > 6:
  163. stats[3] = 6
  164. stats[2] = stats[2] + 2
  165. if stats[2] > 6:
  166. stats[2] = 6
  167. self.stats = stats
  168. def gen_career(self):
  169. self.career = r.choice(["Soldier/Guard","Pilot","Medic","Mechanic","Politician","Spellcaster","Performer","Historian","Spy","Cook","Cartographer","Inventor","Merchant"])
  170. def print_name(self, html=False):
  171. if html:
  172. charText = f"<h4>Name: {self.name} (Kobold {self.career})</h4>"
  173. else:
  174. charText = f"\nName: {self.name} (Kobold {self.career})"
  175. print(charText)
  176. def print(self, html=False):
  177. if html:
  178. out = (
  179. f"<div class='kobold'>\n"
  180. f" <span class='koboldname'>\n"
  181. f" {self.name} (Kobold {self.career})\n"
  182. f" </span>\n"
  183. f" <br>\n"
  184. f" <span class='koboldstats'>\n"
  185. f" <ul>\n"
  186. f" <li>Order: {self.stats[0]}</li>\n"
  187. f" <li>Chaos: {self.stats[1]}</li>\n"
  188. f" <li>Brain: {self.stats[2]}</li>\n"
  189. f" <li>Body: {self.stats[3]}</li>\n"
  190. f" </ul>\n"
  191. f" </span>\n"
  192. f"</div>\n"
  193. )
  194. print(out)
  195. else:
  196. self.print_name()
  197. print(f"Order: {self.stats[0]}")
  198. print(f"Chaos: {self.stats[1]}")
  199. print(f"Brain: {self.stats[2]}")
  200. print(f"Body: {self.stats[3]}")
  201. class Ship:
  202. def __init__(self):
  203. self.name1 = r.choice(["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"])
  204. self.name2 = r.choice(["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"])
  205. 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"])
  206. 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"])
  207. self.fullname = f"{self.name1} {self.name2}"
  208. def print(self, html=False):
  209. if (html):
  210. shipText = f"<p>The <strong>{self.fullname}</strong> <span style='color: blue;'>{self.gqual}</span>, but <span style='color: red;'>{self.bqual}</span>.</p>\n"
  211. else:
  212. shipText = f"The {self.fullname} {self.gqual}, but {self.bqual}.\n"
  213. print(shipText)
  214. class Campaign:
  215. def __init__(self, n=None, makeChars=True):
  216. n = 6 if n == None else n
  217. self.ship = Ship()
  218. self.params = Plot()
  219. if makeChars:
  220. self.characters = []
  221. for _ in range(n):
  222. c = Character()
  223. c.generate()
  224. self.characters.append(c)
  225. self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a"
  226. def print_params(self, endc=" ", html=False):
  227. st = ["Order:", "Chaos:", "Brains:", "Body:"]
  228. cst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.problem["stats"]]))])
  229. lines = [
  230. f"The Kobolds of the {self.ship.fullname}",
  231. f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location}",
  232. f"in order {self.params.mission}",
  233. f"but they're challenged by {self.params.fullProblem}!",
  234. f"The stats of the {self.params.problem['shortname']}",
  235. f"{cst}"
  236. ]
  237. if self.params.secProblem:
  238. mst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.secProblem["stats"]]))])
  239. lines.append(f"The stats of the {self.params.secProblem['shortname']}")
  240. lines.append(f"{mst}")
  241. if self.params.thirdProblem:
  242. pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.thirdProblem["stats"]]))])
  243. lines.append(f"The stats of the {self.params.thirdProblem['shortname']}")
  244. lines.append("{pst}")
  245. if html:
  246. out = (
  247. f"<div id='theship' class='firstrow'>\n"
  248. f" <span class='head'>The Ship</span>\n"
  249. f" <span id='shipname'>\n"
  250. f" The {self.ship.fullname}!\n"
  251. f" </span>\n"
  252. f" <br>\n"
  253. f" <span id='shipquality1'>\n"
  254. f" It {self.ship.gqual}\n"
  255. f" </span><br>\n"
  256. f" <span id='shipquality2'>\n"
  257. f" ... But {self.ship.bqual}!\n"
  258. f" </span>\n"
  259. f"</div>\n"
  260. f"<div id='themission' class='firstrow'>\n"
  261. f" <span class='head'>The Mission</span>\n"
  262. f" <span id='missionloc'>\n"
  263. f" The kobolds have been sent to {self.art} {self.params.loc_desc} {self.params.location}\n"
  264. f" </span><br>\n"
  265. f" <span id='missiontarget'>\n"
  266. f" in order {self.params.mission}.\n"
  267. f" </span>\n"
  268. f"</div>\n"
  269. f"<div id='theadversary' class='firstrow'>\n"
  270. f" <span class='head'>The Adversary</span>\n"
  271. f" They're challenged by <span id='advname'>{self.params.fullProblem}</span>!\n"
  272. f" <br>\n"
  273. f" <span id='problemstats'>\n"
  274. f" The stats of the {self.params.problem['shortname']}:<br>\n"
  275. f" {cst}\n"
  276. f" </span>\n"
  277. )
  278. if self.params.secProblem:
  279. out += (
  280. f" <br><span id='secprobstats'>\n"
  281. f" The stats of the {self.params.secProblem['shortname']}:<br>\n"
  282. f" {mst}\n"
  283. f" </span>\n"
  284. )
  285. if self.params.thirdProblem:
  286. out += (
  287. f" <br><span id='thirdprobstats'>\n"
  288. f" The stats of the {self.params.thirdProblem['shortname']}:<br>\n"
  289. f" {pst}\n"
  290. f" </span>\n"
  291. )
  292. out += f"</div>\n"
  293. print(out)
  294. print(f"<br clear='all'>\n")
  295. else:
  296. print(f"{lines[0]} {lines[1]} {lines[2]} -- {lines[3]}")
  297. print(f"{lines[4]}: {lines[5]}")
  298. if self.params.secProblem:
  299. print(f"- {lines[6]}: {lines[7]}")
  300. if self.params.thirdProblem:
  301. print(f"- - {lines[8]}: {lines[9]}")
  302. print()
  303. self.ship.print(html=html)
  304. def print_chars(self, html=False):
  305. if html:
  306. print(f"<div id='thekobolds'>\n")
  307. print(f"<span class='head'>The Kobolds</span>\n")
  308. else:
  309. print("The kobolds:")
  310. for k in self.characters:
  311. k.print(html=html)
  312. if html:
  313. print(f"</div>\n<br clear='all'>\n")
  314. if __name__ == "__main__":
  315. parser = argparse.ArgumentParser()
  316. group = parser.add_mutually_exclusive_group()
  317. group.add_argument("-c", "--campaign", help="print a full campaign block with N kobolds (default 6)", nargs="?", const=6, type=int, metavar="N")
  318. group.add_argument("-k", "--kobolds", help="print N kobolds", type=int, nargs="?", const=1, default=1, metavar="N")
  319. group.add_argument("-n", "--names", help="print N kobolds without stat blocks", nargs="?", const=1, type=int, metavar="N")
  320. group.add_argument("-p", "--params", help="print only the parameters of a campaign", action="store_true")
  321. group.add_argument("-s", "--ship", help="print only the ship name and description", action="store_true")
  322. parser.add_argument("--html", help="print in HTML instead of plain text", action="store_true")
  323. args = parser.parse_args()
  324. # print(args)
  325. html = True if args.html else False
  326. if args.campaign:
  327. cmp = Campaign(args.campaign)
  328. cmp.print_params(html=html)
  329. cmp.print_chars(html=html)
  330. elif args.params:
  331. cmp = Campaign(makeChars=False)
  332. cmp.print_params(html=html)
  333. elif args.ship:
  334. ship = Ship()
  335. ship.print(html=html)
  336. elif args.names:
  337. for _ in range(args.names):
  338. c = Character()
  339. c.generate()
  340. c.print_name(html=html)
  341. else:
  342. for _ in range(args.kobolds):
  343. c = Character()
  344. c.generate()
  345. c.print(html=html)