123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import random as r
- import sys
-
- 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"]
- mid = beg + ["l","x","n","r"]
-
- def gen_name(n=None):
- if n == None:
- lgt = r.randint(3,9)
- else:
- lgt = n
- morae = []
- while len("".join(morae)) < lgt:
- if len(morae) == 0:
- mora = r.choice(beg)
- morae.append(mora[0].upper() + mora[1:])
- else:
- mora = r.choice(mid)
- if morae[-1] == mora:
- mora = r.choice(mid)
- morae.append(mora)
- return "".join(morae)
-
-
- def gen_stats(n):
- if n < 4:
- print("Too few stat points!")
- return [0,0,0,0]
- stats = [1,1,1,1]
- points = n - 4
- slots = [0,1,2,3]
- for _ in range(points):
- tgl = False
- while tgl == False:
- slt = r.choice(slots)
- if stats[slt] == 6:
- continue
- if stats[slt] == 5:
- if r.randint(0,1) == 1:
- continue
- stats[slt] += 1
- tgl = True
- return stats
-
- def gen_career():
- return r.choice(["Soldier/Guard","Pilot","Medic","Mechanic","Politician","Spellcaster","Performer","Historian","Spy","Cook","Cartographer"])
-
- def gen_plot():
- 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"]
- loc2 = ["asteroid","moon","space station","spaceship","ringworld","Dyson sphere","planet","Space Whale","pocket of folded space","time vortex","Reroll"]
- 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"]
- 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"]
- cl1 = r.choice(loc1)
- cl2 = r.choice(loc2)
- cm = r.choice(miss)
- cp = r.choice(prob)
- if cl2 == "Reroll":
- cl2p = r.choice(loc2[:-1])
- if cl2p == "Asteroid":
- cl2 = "battlefield on an asteroid"
- else:
- cl2 = "battlefield on a " + cl2p
- if cm == "Reroll":
- cm = "to ...well, the kobolds weren't paying attention, so don't tell them, but they're supposed to " + r.choice(miss[:-1])
- if cp == "Reroll":
- cp = "a Floating Brain Monster and its minion, " + r.choice(prob[:-1])
- return [cl1, cl2, cm, cp]
-
- def gen_transpo():
- name1 = ["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"]
- name2 = ["Moon","Comet","Star","Saber","World-Eater","Dancer","Looter","Phlogiston","Fireball","Mecha","Raptor"]
- 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"]
- 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"]
- return [r.choice(name1), r.choice(name2), r.choice(prop1), r.choice(prop2)]
-
- class Character:
- def __init__(self):
- self.name = ""
- self.career = ""
- self.stats = []
-
- def generate(self):
- self.gen_name()
- self.gen_stats()
- self.gen_career()
-
- def gen_name(self):
- self.name = gen_name()
-
- def gen_stats(self):
- self.stats = gen_stats(12)
-
- def gen_career(self):
- self.career = gen_career()
-
- def print(self):
- print(f"Name: {self.name} (Kobold {self.career})")
- print(f"Order: {self.stats[0]}")
- print(f"Chaos: {self.stats[1]}")
- print(f"Brain: {self.stats[2]}")
- print(f"Body: {self.stats[3]}")
-
- if __name__ == "__main__":
- args = sys.argv[1:]
- if "--campaign" in args or "-c" in args:
- cs = []
- for _ in range(6):
- c = Character()
- c.generate()
- cs.append(c)
- parameters = gen_plot()
- ship = gen_transpo()
- art = "an" if parameters[1] == "Asteroid" else "a"
- print(f"The Kobolds of the {ship[0]} {ship[1]}")
- print(f"have been sent out to {art} {parameters[0]} {parameters[1]}")
- print(f"in order {parameters[2]}")
- print(f"but they're challenged by {parameters[3]}!")
- print()
- print(f"The {ship[0]} {ship[1]} {ship[2]}, but {ship[3]}.")
- print()
- print("The kobolds:")
- for k in cs:
- k.print()
-
- else:
- if len(args) == 0:
- c = Character()
- c.generate()
- c.print()
- else:
- try:
- num = int(args[0])
- for _ in range(num):
- c = Character()
- c.generate()
- c.print()
- except:
- print(f"Invalid arguments: {', '.join(args)}")
- c = Character()
- c.generate()
- c.print()
|