ソースを参照

Get rid of some edge cases

master
Noëlle 4年前
コミット
2fb45e244f
1個のファイルの変更13行の追加9行の削除
  1. 13
    9
      koboldgen.py

+ 13
- 9
koboldgen.py ファイルの表示

@@ -35,7 +35,8 @@ def gen_name(length=None, minimum=3):
if morae[-1] == mora:
mora = r.choice(mid)
morae.append(mora)
return "".join(morae)
fname = "".join(morae)[:lgt]
return fname

class Plot:
loc1 = ["friendly","hostile","derelict","airless","poison-filled/covered","overgrown","looted","burning","frozen","haunted","infested"]
@@ -197,7 +198,7 @@ class Character:
self.career = ""
elif isinstance(career, str):
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]
else:
self.career = ""
@@ -252,7 +253,7 @@ class Character:

def gen_career(self):
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):
gid = r.randint(0,15)
@@ -261,13 +262,16 @@ class Character:
def print_name(self, html=False):
if isinstance(self.career, str):
cname = self.career
cid = next((x for x in Character.CAREERS if x["name"] == cname), "")
else:
cname = self.career["name"]
c = dict(next((x for x in Character.CAREERS if x["name"] == cname), ""))
cid = c["id"]
if html:
charText = f"<h4>Name: {self.name} (Kobold {cname})</h4>"
else:
charText = f"\nName: {self.name} (Kobold {cname})"
charText = f"\nName: {self.name} (Kobold {cname} {cid})"
print(charText)

def print(self, html=False):
@@ -437,7 +441,7 @@ class Campaign:
l2 = bin(Plot.loc2.index(self.params.location))[2:]
lb = bin(self.params.battlefield)[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:]
if self.params.probIndex == 10:
pb2 = bin(self.params.secProbIndex)[2:]
@@ -471,7 +475,7 @@ class Campaign:
n2 = lpad(n2, 7)
gq = lpad(gq, 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():
chct["name"] = lpad(chct["name"], 40, "1")
chct["career"] = lpad(chct["career"], 7)
@@ -483,7 +487,7 @@ class Campaign:
self.key += chct["name"] + chct["career"] + chct["order"] + chct["chaos"] + chct["body"] + chct["brains"] + chct["gadget"]
while len(self.key) < 509:
self.key = self.key + "0"
self.okey = ""
print(self.key)
letters = []
letter = []
for bit in self.key:
@@ -747,7 +751,7 @@ class Campaign:
lines = [
f"The Kobolds of the {self.ship.fullname}",
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"The stats of the {self.params.problem['shortname']}",
f"{cst}"
@@ -781,7 +785,7 @@ class Campaign:
f" The kobolds have been sent to {self.art} {self.params.loc_desc} {self.params.location}!\n"
f" </span><br>\n"
f" <span id='missiontarget'>\n"
f" in order {self.params.mission}\n"
f" in order {mission}\n"
f" </span>\n"
f"</div>\n<br clear='all'>\n"
f"<div id='theadversary' class='firstrow'>\n"

読み込み中…
キャンセル
保存