Browse Source

Prepare for HTML output

master
Noëlle 4 years ago
parent
commit
4f82f43da8
1 changed files with 15 additions and 15 deletions
  1. 15
    15
      koboldgen.py

+ 15
- 15
koboldgen.py View File

@@ -4,10 +4,8 @@ import argparse
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(length=None, minimum=None, maximum=None):
def gen_name(length=None, minimum=3, maximum=9):
if length == None:
minimum = 3 if minimum == None else minimum
maximum = 9 if maximum == None else maximum
lgt = r.randint(minimum,maximum)
else:
lgt = length
@@ -183,7 +181,7 @@ class Character:
def print_name(self):
print(f"Name: {self.name} (Kobold {self.career})")

def print(self):
def print(self, html=False):
self.print_name()
print(f"Order: {self.stats[0]}")
print(f"Chaos: {self.stats[1]}")
@@ -198,7 +196,7 @@ class Ship:
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"])
self.fullname = f"{self.name1} {self.name2}"

def print(self):
def print(self, html=False):
print(f"The {self.fullname} {self.gqual}, but {self.bqual}.")
print()

@@ -216,7 +214,7 @@ class Campaign:
self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a"


def print_params(self, endc=""):
def print_params(self, endc="", html=False):
st = ["Order:", "Chaos:", "Brains:", "Body:"]
print(f"The Kobolds of the {self.ship.fullname} ", end=endc)
print(f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location} ", end=endc)
@@ -231,12 +229,12 @@ class Campaign:
pst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.thirdProblem["stats"]]))])
print(f"- - The stats of the {self.params.thirdProblem['shortname']}: {pst}")
print()
self.ship.print()
self.ship.print(html=html)

def print_chars(self):
def print_chars(self, html=False):
print("The kobolds:")
for k in self.characters:
k.print()
k.print(html=html)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
@@ -246,25 +244,27 @@ if __name__ == "__main__":
group.add_argument("-n", "--names", help="print N kobolds without stat blocks", nargs="?", const=1, type=int, metavar="N")
group.add_argument("-p", "--params", help="print only the parameters of a campaign", action="store_true")
group.add_argument("-s", "--ship", help="print only the ship name and description", action="store_true")
parser.add_argument("--html", help="print in HTML instead of plain text", action="store_true")
args = parser.parse_args()
# print(args)
html = True if args.html else False
if args.campaign:
cmp = Campaign(args.campaign)
cmp.print_params()
cmp.print_chars()
cmp.print_params(html=html)
cmp.print_chars(html=html)
elif args.params:
cmp = Campaign(makeChars=False)
cmp.print_params()
cmp.print_params(html=html)
elif args.ship:
ship = Ship()
ship.print()
ship.print(html=html)
elif args.names:
for _ in range(args.names):
c = Character()
c.generate()
c.print_name()
c.print_name(html=html)
else:
for _ in range(args.kobolds):
c = Character()
c.generate()
c.print()
c.print(html=html)

Loading…
Cancel
Save