|
|
@@ -109,15 +109,15 @@ class Plot: |
|
|
|
}, |
|
|
|
] |
|
|
|
|
|
|
|
def __init__(self, loc_desc=None, locIndex=None, battlefield=None, location=None, missIndex=None, oops=None, mission=None, probIndex=None, problem=None, probName=None, secProblem=None, thirdProblem=None, ): |
|
|
|
def __init__(self, loc_desc=None, locIndex=None, battlefield=None, location=None, missIndex=None, oops=None, mission=None, probIndex=None, problem=None, probName=None, secProblem=None, thirdProblem=None): |
|
|
|
self.loc_desc = loc_desc if loc_desc != None else Plot.loc1[r.randint(0, len(Plot.loc1)-1)] |
|
|
|
self.locIndex = int(locIndex) if locIndex != None else r.randint(0, len(Plot.loc2)-1) |
|
|
|
self.battlefield = int(battlefield) if battlefield != None else 0 |
|
|
|
self.location = location if location != None else Plot.loc2[self.locIndex] |
|
|
|
if locIndex == None and self.locIndex == len(Plot.loc2) - 1: |
|
|
|
if locIndex == None and self.locIndex == len(Plot.loc2) - 2: |
|
|
|
if self.battlefield == 0: |
|
|
|
self.battlefield = 1 |
|
|
|
self.locIndex = r.randint(0, len(Plot.loc2)-2) |
|
|
|
self.locIndex = r.randint(0, len(Plot.loc2)-3) |
|
|
|
elif locIndex == None and self.locIndex != len(Plot.loc2) - 1: |
|
|
|
if self.location == "": |
|
|
|
self.location = Plot.loc2[self.locIndex] |
|
|
@@ -130,11 +130,11 @@ class Plot: |
|
|
|
if self.oops != 1: |
|
|
|
self.oops = 0 |
|
|
|
self.mission = Plot.miss[r.randint(0, len(Plot.miss)-1)] |
|
|
|
self.probIndex = r.randint(0, len(Plot.prob)-1) |
|
|
|
self.probIndex = probIndex if probIndex != None else r.randint(0, len(Plot.prob)-1) |
|
|
|
self.problem = Plot.prob[self.probIndex] |
|
|
|
self.secProblem = None |
|
|
|
self.thirdProblem = None |
|
|
|
self.problem["name"] = probName if probName != None else gen_name() |
|
|
|
self.secProblem = [x for x in Plot.prob if x["id"] == secProblem][0] if (secProblem != None and secProblem in list(filter(lambda x:x["id"], Plot.prob))) else None |
|
|
|
self.thirdProblem = [x for x in Plot.prob if x["id"] == thirdProblem][0] if (thirdProblem != None and thirdProblem in list(filter(lambda x:x["id"], Plot.prob))) else None |
|
|
|
self.problem["givenname"] = probName if probName != None else gen_name() |
|
|
|
if self.problem["id"] == 3: |
|
|
|
self.secProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]} |
|
|
|
if self.problem["id"] == 10: |
|
|
@@ -142,7 +142,7 @@ class Plot: |
|
|
|
self.secProblem = Plot.prob[self.secProbIndex] |
|
|
|
if self.secProbIndex == 3: |
|
|
|
self.thirdProblem = {"name": "Parasites", "shortname": "parasites", "stats": [3,4,2,3]} |
|
|
|
self.fullProblem = self.problem["name"] |
|
|
|
self.fullProblem = self.problem["givenname"] + ", " + self.problem["name"] |
|
|
|
if self.secProblem and self.secProblem["name"] != "Parasites": |
|
|
|
self.fullProblem += " and its minion, " + self.secProblem["name"] |
|
|
|
|
|
|
@@ -182,19 +182,33 @@ class Character: |
|
|
|
|
|
|
|
def __init__(self, name=None, career=None, stats=None, gadget=None): |
|
|
|
self.name = name if name != None else "" |
|
|
|
self.career = career if career != None else "" |
|
|
|
if career == None: |
|
|
|
self.career = "" |
|
|
|
elif isinstance(career, str): |
|
|
|
self.career = career |
|
|
|
elif isinstance(career, int) and career < len(Campaign.CAREERS): |
|
|
|
self.career = [x for x in Character.CAREERS if x["id"] == career][0]["name"] |
|
|
|
else: |
|
|
|
self.career = "" |
|
|
|
self.stats = stats if stats != None else [] |
|
|
|
self.gadget = gadget if gadget != None else "" |
|
|
|
if gadget == None: |
|
|
|
self.gadget = "" |
|
|
|
elif isinstance(gadget, str) or isinstance(gadget, object): |
|
|
|
self.gadget = gadget |
|
|
|
elif isinstance(gadget, int) and gadget < len(Campaign.GADGETS): |
|
|
|
self.gadget = [x for x in Character.GADGETS if x["id"] == gadget][0] |
|
|
|
else: |
|
|
|
self.gadget = "" |
|
|
|
self.generate() |
|
|
|
|
|
|
|
def generate(self): |
|
|
|
if self.name == "": |
|
|
|
if self.name == "" or self.name == None: |
|
|
|
self.gen_name() |
|
|
|
if self.stats == []: |
|
|
|
if self.stats == [] or self.stats == None: |
|
|
|
self.gen_stats() |
|
|
|
if self.career == "": |
|
|
|
if self.career == "" or self.career == None: |
|
|
|
self.gen_career() |
|
|
|
if self.gadget == "": |
|
|
|
if self.gadget == "" or self.gadget == None: |
|
|
|
self.gen_gadget() |
|
|
|
|
|
|
|
def gen_name(self): |
|
|
@@ -234,19 +248,32 @@ class Character: |
|
|
|
self.gadget = r.choice(Character.GADGETS) |
|
|
|
|
|
|
|
def print_name(self, html=False): |
|
|
|
if isinstance(self.career, str): |
|
|
|
cname = self.career |
|
|
|
else: |
|
|
|
cname = self.career["name"] |
|
|
|
|
|
|
|
if html: |
|
|
|
charText = f"<h4>Name: {self.name} (Kobold {self.career})</h4>" |
|
|
|
charText = f"<h4>Name: {self.name} (Kobold {cname})</h4>" |
|
|
|
else: |
|
|
|
charText = f"\nName: {self.name} (Kobold {self.career})" |
|
|
|
charText = f"\nName: {self.name} (Kobold {cname})" |
|
|
|
print(charText) |
|
|
|
|
|
|
|
def print(self, html=False): |
|
|
|
if html: |
|
|
|
if isinstance(self.career, str): |
|
|
|
cname = self.career |
|
|
|
else: |
|
|
|
cname = self.career["name"] |
|
|
|
if isinstance(self.gadget, str): |
|
|
|
gdg = {"id": 127, "name": self.gadget, "description": "", "reusable": True} |
|
|
|
else: |
|
|
|
gdg = self.gadget |
|
|
|
out = ( |
|
|
|
f"<div class='kobold'>\n" |
|
|
|
f" <span class='koboldid'>\n" |
|
|
|
f" <span class='koboldname'>{self.name}</span><br>\n" |
|
|
|
f" <span class='koboldcareer'>Kobold {self.career.name}</span>\n" |
|
|
|
f" <span class='koboldcareer'>Kobold {cname}</span>\n" |
|
|
|
f" </span>\n" |
|
|
|
f" <br>\n" |
|
|
|
f" <span class='koboldstats'>\n" |
|
|
@@ -259,9 +286,9 @@ class Character: |
|
|
|
f" </span>\n" |
|
|
|
f" <br>\n" |
|
|
|
f" <span class='koboldgadget'>\n" |
|
|
|
f" <span class='koboldgadgetname'>{self.gadget['name']}</span><br>\n" |
|
|
|
f" <span class='koboldgadgetdescription'>{self.gadget['description']}</span>\n" |
|
|
|
f" <span class='koboldgadgetreuse'>{'<br>Reusable' if self.gadget['reusable'] else ''}</span>\n" |
|
|
|
f" <span class='koboldgadgetname'>{gdg['name']}</span><br>\n" |
|
|
|
f" <span class='koboldgadgetdescription'>{gdg['description']}</span>\n" |
|
|
|
f" <span class='koboldgadgetreuse'>{'<br>Reusable' if gdg['reusable'] else ''}</span>\n" |
|
|
|
f" </span>" |
|
|
|
f"</div>\n" |
|
|
|
) |
|
|
@@ -272,7 +299,10 @@ class Character: |
|
|
|
print(f"Chaos: {self.stats[1]}") |
|
|
|
print(f"Brain: {self.stats[2]}") |
|
|
|
print(f"Body: {self.stats[3]}") |
|
|
|
print(f"Gadget: {self.gadget['name']} ({self.gadget['description']}{'- Reusable' if self.gadget['reusable'] else ''})") |
|
|
|
if isinstance(self.gadget, str): |
|
|
|
print(f"Gadget: {self.gadget}") |
|
|
|
else: |
|
|
|
print(f"Gadget: {self.gadget['name']} ({self.gadget['description']}{'- Reusable' if self.gadget['reusable'] else ''})") |
|
|
|
|
|
|
|
class Ship: |
|
|
|
NAME1 = ["Red","Orange","Yellow","Green","Blue","Violet","Dark","Light","Frenzied","Maniacal","Ancient"] |
|
|
@@ -400,7 +430,7 @@ class Campaign: |
|
|
|
pb2 = bin(self.params.secProbIndex)[2:] |
|
|
|
else: |
|
|
|
pb2 = bin(127)[2:] |
|
|
|
pbname = self.encode_name(self.params.problem["name"]) |
|
|
|
pbname = self.encode_name(self.params.problem["givenname"]) |
|
|
|
n1 = bin(Ship.NAME1.index(self.ship.name1))[2:] |
|
|
|
n2 = bin(Ship.NAME2.index(self.ship.name2))[2:] |
|
|
|
gq = bin(Ship.GQUAL.index(self.ship.gqual))[2:] |
|
|
@@ -441,7 +471,7 @@ class Campaign: |
|
|
|
# print(f"Len(bq) = {len(bq)}") |
|
|
|
self.key += l1 + l2 + lb + op + ms + pb1 + pbname + pb2 + n1 + n2 + gq + bq |
|
|
|
for k,chct in chars.items(): |
|
|
|
chct["name"] = lpad(chct["name"], 40) |
|
|
|
chct["name"] = lpad(chct["name"], 40, "1") |
|
|
|
# print(f"Len(chct.name) = {len(chct['name'])}") |
|
|
|
chct["career"] = lpad(chct["career"], 7) |
|
|
|
# print(f"Len(chct.career) = {len(chct['career'])}") |
|
|
@@ -485,12 +515,33 @@ class Campaign: |
|
|
|
densePwd = pw.replace(" ", "") |
|
|
|
if densePwd == "PACKTACTICS!------------------------------------------------------------------------------------": |
|
|
|
# Create a campaign featuring the Season 3 Pack Tactics crew. |
|
|
|
self.ship = Ship("Red", "Star", "is maneuverable & unarmored", "has a politician who thinks they're in charge of it") |
|
|
|
self.params = Plot() |
|
|
|
self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a" |
|
|
|
self.characters = [] |
|
|
|
self.characters.append(Character("Niwri", "Hunter", [3,4,4,3], "Shortbow of the Watch")) |
|
|
|
self.characters.append(Character("Zax", "Barbarian", [1, 6, 2, 5], "Hammer of Thunderbolts")) |
|
|
|
self.characters.append(Character("Chroma", "Artificer", [4, 2, 5, 3], "Eldritch Cannon")) |
|
|
|
self.characters.append(Character("Zenosha", "Druid", [3, 3, 5, 3], "Staff of Lightning")) |
|
|
|
self.characters.append(Character("Snax", "Wizard", [2, 4, 5, 1], "Voyager Staff")) |
|
|
|
# self.print_params() |
|
|
|
# self.print_chars() |
|
|
|
return |
|
|
|
elif densePwd == "JUSTINBAILEY------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but everyone's Gadget is a leotard that somehow is also an environment suit |
|
|
|
self.create_campaign(n=6, makeChars=True) |
|
|
|
for c in self.characters: |
|
|
|
c.gadget = {"id":127, "name": "The Bailey", "description": "A form-fitting leotard that somehow protects the wearer from all environmental effects except extreme heat - including vacuum and poison.", "reusable": True} |
|
|
|
# self.print_params() |
|
|
|
# self.print_chars() |
|
|
|
return |
|
|
|
elif densePwd == "NARPASSWORD------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but all the kobolds' stats are set to 6 |
|
|
|
self.create_campaign(n=6, makeChars=True) |
|
|
|
for c in self.characters: |
|
|
|
c.stats = [6,6,6,6] |
|
|
|
# self.print_params() |
|
|
|
# self.print_chars() |
|
|
|
return |
|
|
|
numPwd = [] |
|
|
|
for c in densePwd: |
|
|
@@ -670,8 +721,15 @@ class Campaign: |
|
|
|
print(outkey) |
|
|
|
self.ship = Ship(Ship.NAME1[outkey["sname1"]], Ship.NAME2[outkey["sname2"]], Ship.GQUAL[outkey["gqual"]], Ship.BQUAL[outkey["bqual"]]) |
|
|
|
self.params = Plot(loc_desc=Plot.loc1[outkey["loc1"]], locIndex=outkey["loc2"], battlefield=outkey["battlefield"], location=None, missIndex=outkey["miss"], oops=outkey["oops"], mission=None, probIndex=outkey["prob1"], problem=None, probName=self.decode_name(outkey["prob1name"]), secProblem=outkey["prob2"], thirdProblem=None) |
|
|
|
self.ship.print() |
|
|
|
self.print_params() |
|
|
|
self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a" |
|
|
|
self.characters = [] |
|
|
|
for q in range(1,7): |
|
|
|
keys = [f"char{q}name", f"char{q}career", f"char{q}ord", f"char{q}cha", f"char{q}bod", f"char{q}bra", f"char{q}gad"] |
|
|
|
c = Character(name=self.decode_name(outkey[keys[0]]), career=outkey[keys[1]], stats=[outkey[keys[2]], outkey[keys[3]], outkey[keys[4]], outkey[keys[5]]], gadget=outkey[keys[6]]) |
|
|
|
self.characters.append(c) |
|
|
|
#self.ship.print() |
|
|
|
# self.print_params() |
|
|
|
# self.print_chars() |
|
|
|
return self.newBitfield |
|
|
|
|
|
|
|
def encode_name(self, name): |
|
|
@@ -813,6 +871,8 @@ if __name__ == "__main__": |
|
|
|
#pw = Password(args.password) |
|
|
|
# print(pw.newBitfield) |
|
|
|
cmp = Campaign(fromPW = True, pw=args.password) |
|
|
|
cmp.print_params(html=html) |
|
|
|
cmp.print_chars(html=html) |
|
|
|
elif args.campaign: |
|
|
|
cmp = Campaign(args.campaign) |
|
|
|
cmp.print_params(html=html) |