Browse Source

Get rid of some edge cases

master
Noëlle 4 years ago
parent
commit
2fb45e244f
1 changed files with 13 additions and 9 deletions
  1. 13
    9
      koboldgen.py

+ 13
- 9
koboldgen.py View File

if morae[-1] == mora: if morae[-1] == mora:
mora = r.choice(mid) mora = r.choice(mid)
morae.append(mora) morae.append(mora)
return "".join(morae)
fname = "".join(morae)[:lgt]
return fname


class Plot: class Plot:
loc1 = ["friendly","hostile","derelict","airless","poison-filled/covered","overgrown","looted","burning","frozen","haunted","infested"] loc1 = ["friendly","hostile","derelict","airless","poison-filled/covered","overgrown","looted","burning","frozen","haunted","infested"]
self.career = "" self.career = ""
elif isinstance(career, str): elif isinstance(career, str):
self.career = career self.career = career
elif isinstance(career, int) and career < len(Character.CAREERS):
elif isinstance(career, int) and career in range(13):
self.career = [x for x in Character.CAREERS if x["id"] == career][0] self.career = [x for x in Character.CAREERS if x["id"] == career][0]
else: else:
self.career = "" self.career = ""


def gen_career(self): def gen_career(self):
cid = r.randint(0,12) cid = r.randint(0,12)
self.career = [x for x in Character.CAREERS if x["id"] == cid][0]
self.career = next((x for x in Character.CAREERS if x["id"] == cid), "")


def gen_gadget(self): def gen_gadget(self):
gid = r.randint(0,15) gid = r.randint(0,15)
def print_name(self, html=False): def print_name(self, html=False):
if isinstance(self.career, str): if isinstance(self.career, str):
cname = self.career cname = self.career
cid = next((x for x in Character.CAREERS if x["name"] == cname), "")
else: else:
cname = self.career["name"] cname = self.career["name"]
c = dict(next((x for x in Character.CAREERS if x["name"] == cname), ""))
cid = c["id"]
if html: if html:
charText = f"<h4>Name: {self.name} (Kobold {cname})</h4>" charText = f"<h4>Name: {self.name} (Kobold {cname})</h4>"
else: else:
charText = f"\nName: {self.name} (Kobold {cname})"
charText = f"\nName: {self.name} (Kobold {cname} {cid})"
print(charText) print(charText)


def print(self, html=False): def print(self, html=False):
l2 = bin(Plot.loc2.index(self.params.location))[2:] l2 = bin(Plot.loc2.index(self.params.location))[2:]
lb = bin(self.params.battlefield)[2:] lb = bin(self.params.battlefield)[2:]
op = bin(self.params.oops)[2:] op = bin(self.params.oops)[2:]
ms = bin(Plot.miss.index(self.params.mission))[2:]
ms = bin(self.params.missIndex)[2:]
pb1 = bin(self.params.probIndex)[2:] pb1 = bin(self.params.probIndex)[2:]
if self.params.probIndex == 10: if self.params.probIndex == 10:
pb2 = bin(self.params.secProbIndex)[2:] pb2 = bin(self.params.secProbIndex)[2:]
n2 = lpad(n2, 7) n2 = lpad(n2, 7)
gq = lpad(gq, 7) gq = lpad(gq, 7)
bq = lpad(bq, 7) bq = lpad(bq, 7)
self.key += l1 + l2 + lb + op + ms + pb1 + pbname + pb2 + n1 + n2 + gq + bq
self.key += l1 + l2 + lb + ms + op + pb1 + pbname + pb2 + n1 + n2 + gq + bq
for k,chct in chars.items(): for k,chct in chars.items():
chct["name"] = lpad(chct["name"], 40, "1") chct["name"] = lpad(chct["name"], 40, "1")
chct["career"] = lpad(chct["career"], 7) chct["career"] = lpad(chct["career"], 7)
self.key += chct["name"] + chct["career"] + chct["order"] + chct["chaos"] + chct["body"] + chct["brains"] + chct["gadget"] self.key += chct["name"] + chct["career"] + chct["order"] + chct["chaos"] + chct["body"] + chct["brains"] + chct["gadget"]
while len(self.key) < 509: while len(self.key) < 509:
self.key = self.key + "0" self.key = self.key + "0"
self.okey = ""
print(self.key)
letters = [] letters = []
letter = [] letter = []
for bit in self.key: for bit in self.key:
lines = [ lines = [
f"The Kobolds of the {self.ship.fullname}", f"The Kobolds of the {self.ship.fullname}",
f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location}!", f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location}!",
f"in order to {self.params.mission}",
f"in order to {mission}",
f"but they're challenged by {self.params.fullProblem}!", f"but they're challenged by {self.params.fullProblem}!",
f"The stats of the {self.params.problem['shortname']}", f"The stats of the {self.params.problem['shortname']}",
f"{cst}" f"{cst}"
f" The kobolds have been sent to {self.art} {self.params.loc_desc} {self.params.location}!\n" f" The kobolds have been sent to {self.art} {self.params.loc_desc} {self.params.location}!\n"
f" </span><br>\n" f" </span><br>\n"
f" <span id='missiontarget'>\n" f" <span id='missiontarget'>\n"
f" in order {self.params.mission}\n"
f" in order {mission}\n"
f" </span>\n" f" </span>\n"
f"</div>\n<br clear='all'>\n" f"</div>\n<br clear='all'>\n"
f"<div id='theadversary' class='firstrow'>\n" f"<div id='theadversary' class='firstrow'>\n"

Loading…
Cancel
Save