Browse Source

Add python file

master
noelle 4 years ago
parent
commit
484a02a343
1 changed files with 125 additions and 0 deletions
  1. 125
    0
      koboldgen.py

+ 125
- 0
koboldgen.py View File

@@ -0,0 +1,125 @@
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","za","ze","zi","zo","zu","zy"]
mid = beg + ["l","x","n"]

def gen_name(n=None):
if n == None:
lgt = r.randint(3,10)
else:
lgt = n
nm = ""
while len(nm) < lgt:
if nm == "":
mora = r.choice(beg)
nm += mora[0].upper() + mora[1:]
else:
nm += r.choice(mid)
return nm


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 = ["Friendly","Hostile","Derelict","Airless","Poison-filled/covered","Overgrown","Looted","Burning","Frozen","Haunted","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 [location] 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 = ["Army of undead","Rival band of kobolds","Detachment from the Elf Armada","Refugees with parasites. Big parasites","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","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 = "The kobolds weren't paying attention, so don't tell them, but it's " + r.choice(miss[:-1])
if cp == "Reroll":
cp = "A Floating Brain Monster and its servitor " + 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 = ["Stealthy & unarmored","Speedy & unarmored","Maneuverable & unarmored","Reliable (May override Attribute 2)","Self-Repairing","Flamboyant & speedy","Slow & armored","Flamboyant & armored","Hard to maneuver & armored","Too Many Weapons!","Prototype hyperdrive"]
prop2 = ["Annoying AI","Inconveniently crossed circuits","Unpredictable power source","Drifts to the right","Haunted","Recently “found” ","Too cold","Constant odd smell","Interior design … changes","Water pressure shifts between slow drip and power wash","Leaves 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:
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"{parameters[2]}")
print(f"but they're challenged by {parameters[3]}!")
print()
print(f"The {ship[0]} {ship[1]} has the qualities [{ship[2]}] and [{ship[3]}].")
print()
print("The kobolds:")
for k in cs:
k.print()

else:
c = Character()
c.generate()
c.print()

Loading…
Cancel
Save