|
|
@@ -39,7 +39,7 @@ def gen_name(length=None, minimum=3): |
|
|
|
class 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 place 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"] |
|
|
|
miss = ["explore","loot everything not bolted down too securely","find the last group of kobolds who came here","find a rumored secret weapon","find a way to break someone else's secret weapon","claim this place in the name of the Kobold Empire","make friends","rediscover lost technology","find lost magical items","find and defeat a powerful enemy"] |
|
|
|
prob = [ |
|
|
|
{ |
|
|
|
"id": 0, |
|
|
@@ -109,33 +109,32 @@ class Plot: |
|
|
|
}, |
|
|
|
] |
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
self.loc_desc = Plot.loc1[r.randint(0, len(Plot.loc1)-1)] |
|
|
|
self.locIndex = r.randint(0, len(Plot.loc2)-1) |
|
|
|
if self.locIndex == len(Plot.loc2) - 1: |
|
|
|
self.battlefield = 1 |
|
|
|
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 self.battlefield == 0: |
|
|
|
self.battlefield = 1 |
|
|
|
self.locIndex = r.randint(0, len(Plot.loc2)-2) |
|
|
|
self.location = Plot.loc2[self.locIndex] |
|
|
|
if self.location[0].lower() in ["a","e","i","o","u"]: |
|
|
|
self.locart = 1 |
|
|
|
else: |
|
|
|
self.locart = 0 |
|
|
|
elif locIndex == None and self.locIndex != len(Plot.loc2) - 1: |
|
|
|
if self.location == "": |
|
|
|
self.location = Plot.loc2[self.locIndex] |
|
|
|
if self.location[0].lower() in ["a","e","i","o","u"]: |
|
|
|
self.locart = 1 |
|
|
|
else: |
|
|
|
self.location = Plot.loc2[self.locIndex] |
|
|
|
self.battlefield = 0 |
|
|
|
self.locart = 0 |
|
|
|
self.missIndex = r.randint(0, len(Plot.miss)-1) |
|
|
|
self.oops = r.randint(1,12) |
|
|
|
if self.oops == 12: |
|
|
|
self.oops = 1 |
|
|
|
else: |
|
|
|
self.oops = 0 |
|
|
|
self.oops = int(oops) if oops != None else r.randint(1,12) |
|
|
|
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.problem = Plot.prob[self.probIndex] |
|
|
|
self.secProblem = None |
|
|
|
self.thirdProblem = None |
|
|
|
self.problem["name"] = gen_name() |
|
|
|
self.problem["name"] = 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: |
|
|
@@ -181,16 +180,22 @@ class Character: |
|
|
|
{"id": 12, "name": "Merchant"} |
|
|
|
] |
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
self.name = "" |
|
|
|
self.career = "" |
|
|
|
self.stats = [] |
|
|
|
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 "" |
|
|
|
self.stats = stats if stats != None else [] |
|
|
|
self.gadget = gadget if gadget != None else "" |
|
|
|
self.generate() |
|
|
|
|
|
|
|
def generate(self): |
|
|
|
self.gen_name() |
|
|
|
self.gen_stats() |
|
|
|
self.gen_career() |
|
|
|
self.gen_gadget() |
|
|
|
if self.name == "": |
|
|
|
self.gen_name() |
|
|
|
if self.stats == []: |
|
|
|
self.gen_stats() |
|
|
|
if self.career == "": |
|
|
|
self.gen_career() |
|
|
|
if self.gadget == "": |
|
|
|
self.gen_gadget() |
|
|
|
|
|
|
|
def gen_name(self): |
|
|
|
self.name = gen_name() |
|
|
@@ -295,26 +300,29 @@ class Campaign: |
|
|
|
def __init__(self, n=None, makeChars=True, fromPW=False, pw=None): |
|
|
|
if fromPW == True: |
|
|
|
self.ship = None |
|
|
|
self.params. = None |
|
|
|
self.params = None |
|
|
|
self.characters = None |
|
|
|
self.art = None |
|
|
|
self.decode_key(pw) |
|
|
|
else: |
|
|
|
n = 6 if n == None else n |
|
|
|
self.ship = Ship() |
|
|
|
self.params = Plot() |
|
|
|
self.params.problem["fullname"] = "" |
|
|
|
if self.params.problem["id"] in [1,2]: |
|
|
|
self.params.problem["fullname"] += " led by " + self.params.problem["name"] |
|
|
|
if self.params.problem["id"] in [4,7,8,10]: |
|
|
|
self.params.problem["fullname"] += " named " + self.params.problem["name"] |
|
|
|
if makeChars: |
|
|
|
self.characters = [] |
|
|
|
for _ in range(n): |
|
|
|
c = Character() |
|
|
|
c.generate() |
|
|
|
self.characters.append(c) |
|
|
|
self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a" |
|
|
|
self.create_campaign(n, makeChars) |
|
|
|
|
|
|
|
def create_campaign(self, n, makeChars): |
|
|
|
n = 6 if n == None else n |
|
|
|
self.ship = Ship() |
|
|
|
self.params = Plot() |
|
|
|
self.params.problem["fullname"] = "" |
|
|
|
if self.params.problem["id"] in [1,2]: |
|
|
|
self.params.problem["fullname"] += " led by " + self.params.problem["name"] |
|
|
|
if self.params.problem["id"] in [4,7,8,10]: |
|
|
|
self.params.problem["fullname"] += " named " + self.params.problem["name"] |
|
|
|
if makeChars: |
|
|
|
self.characters = [] |
|
|
|
for _ in range(n): |
|
|
|
c = Character() |
|
|
|
c.generate() |
|
|
|
self.characters.append(c) |
|
|
|
self.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a" |
|
|
|
|
|
|
|
def generate_key(self): |
|
|
|
""" |
|
|
@@ -392,7 +400,7 @@ class Campaign: |
|
|
|
pb2 = bin(self.params.secProbIndex)[2:] |
|
|
|
else: |
|
|
|
pb2 = bin(127)[2:] |
|
|
|
pbname = "".join([bin(Campaign.NAMELETS.index(x.lower()))[2:] for x in self.params.problem["name"]]) |
|
|
|
pbname = self.encode_name(self.params.problem["name"]) |
|
|
|
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:] |
|
|
@@ -401,7 +409,7 @@ class Campaign: |
|
|
|
i = 0 |
|
|
|
for chct in self.characters: |
|
|
|
chars[i] = { |
|
|
|
"name": "".join([bin(Campaign.NAMELETS.index(x.lower()))[2:] for x in chct.name]), |
|
|
|
"name": self.encode_name(chct.name), |
|
|
|
"career": bin(chct.career["id"])[2:], |
|
|
|
"order": bin(chct.stats[0])[2:], |
|
|
|
"chaos": bin(chct.stats[1])[2:], |
|
|
@@ -411,64 +419,48 @@ class Campaign: |
|
|
|
} |
|
|
|
i += 1 |
|
|
|
# print(chars) |
|
|
|
while len(l1) < 7: |
|
|
|
l1 = "0" + l1 |
|
|
|
l1 = lpad(l1, 7) |
|
|
|
# print(f"Len(l1) = {len(l1)}") |
|
|
|
while len(l2) < 7: |
|
|
|
l2 = "0" + l2 |
|
|
|
l2 = lpad(l2, 7) |
|
|
|
# print(f"Len(l2) = {len(l2)}") |
|
|
|
while len(ms) < 7: |
|
|
|
ms = "0" + ms |
|
|
|
ms = lpad(ms, 7) |
|
|
|
# print(f"Len(ms) = {len(ms)}") |
|
|
|
while len(pb1) < 7: |
|
|
|
pb1 = "0" + pb1 |
|
|
|
pb1 = lpad(pb1, 7) |
|
|
|
# print(f"Len(pb1) = {len(pb1)}") |
|
|
|
while len(pb2) < 7: |
|
|
|
pb2 = "0" + pb2 |
|
|
|
pb2 = lpad(pb2, 7) |
|
|
|
# print(f"Len(pb2) = {len(pb2)}") |
|
|
|
while len(pbname) < 40: |
|
|
|
pbname = "0" + pbname |
|
|
|
pbname = lpad(pbname, 40, "1") |
|
|
|
# print(f"Len(pbname) = {len(pbname)}") |
|
|
|
while len(n1) < 7: |
|
|
|
n1 = "0" + n1 |
|
|
|
n1 = lpad(n1, 7) |
|
|
|
# print(f"Len(n1) = {len(n1)}") |
|
|
|
while len(n2) < 7: |
|
|
|
n2 = "0" + n2 |
|
|
|
n2 = lpad(n2, 7) |
|
|
|
# print(f"Len(n2) = {len(n2)}") |
|
|
|
while len(gq) < 7: |
|
|
|
gq = "0" + gq |
|
|
|
gq = lpad(gq, 7) |
|
|
|
# print(f"Len(gq) = {len(gq)}") |
|
|
|
while len(bq) < 7: |
|
|
|
bq = "0" + bq |
|
|
|
bq = lpad(bq, 7) |
|
|
|
# print(f"Len(bq) = {len(bq)}") |
|
|
|
self.key += l1 + l2 + lb + op + ms + pb1 + pb2 + pbname + n1 + n2 + gq + bq |
|
|
|
self.key += l1 + l2 + lb + op + ms + pb1 + pbname + pb2 + n1 + n2 + gq + bq |
|
|
|
for k,chct in chars.items(): |
|
|
|
while len(chct["name"]) < 40: |
|
|
|
chct["name"] = "0" + chct["name"] |
|
|
|
chct["name"] = lpad(chct["name"], 40) |
|
|
|
# print(f"Len(chct.name) = {len(chct['name'])}") |
|
|
|
while len(chct["career"]) < 7: |
|
|
|
chct["career"] = "0" + chct["career"] |
|
|
|
chct["career"] = lpad(chct["career"], 7) |
|
|
|
# print(f"Len(chct.career) = {len(chct['career'])}") |
|
|
|
while len(chct["order"]) < 3: |
|
|
|
chct["order"] = "0" + chct["order"] |
|
|
|
chct["order"] = lpad(chct["order"],3) |
|
|
|
# print(f"Len(chct.order) = {len(chct['order'])}") |
|
|
|
while len(chct["chaos"]) < 3: |
|
|
|
chct["chaos"] = "0" + chct["chaos"] |
|
|
|
chct["chaos"] = lpad(chct["chaos"], 3) |
|
|
|
# print(f"Len(chct.chaos) = {len(chct['chaos'])}") |
|
|
|
while len(chct["body"]) < 3: |
|
|
|
chct["body"] = "0" + chct["body"] |
|
|
|
chct["body"] = lpad(chct["body"], 3) |
|
|
|
# print(f"Len(chct.body) = {len(chct['body'])}") |
|
|
|
while len(chct["brains"]) < 3: |
|
|
|
chct["brains"] = "0" + chct["brains"] |
|
|
|
chct["brains"] = lpad(chct["brains"], 3) |
|
|
|
# print(f"Len(chct.brains) = {len(chct['brains'])}") |
|
|
|
while len(chct["gadget"]) < 7: |
|
|
|
chct["gadget"] = "0" + chct["gadget"] |
|
|
|
chct["gadget"] = lpad(chct["gadget"], 7) |
|
|
|
# print(f"Len(chct.gadget) = {len(chct['gadget'])}") |
|
|
|
self.key += chct["name"] + chct["career"] + chct["order"] + chct["chaos"] + chct["body"] + chct["brains"] + chct["gadget"] |
|
|
|
# print(len(self.key)) |
|
|
|
while len(self.key) < 509: |
|
|
|
self.key = self.key + "0" |
|
|
|
# print(len(self.key)) |
|
|
|
print(self.key) |
|
|
|
self.okey = "" |
|
|
|
letters = [] |
|
|
|
letter = [] |
|
|
@@ -490,101 +482,226 @@ class Campaign: |
|
|
|
return self.password |
|
|
|
|
|
|
|
def decode_key(self, pw): |
|
|
|
""" |
|
|
|
Repeating this here for the sake of convenience. |
|
|
|
Location 1: 7 bits |
|
|
|
Location 2: 7 bits |
|
|
|
Location Battlefield: 1 bit |
|
|
|
Mission: 7 bits |
|
|
|
Oops: 1 bit |
|
|
|
Problem 1: 7 bits |
|
|
|
Problem 1 name: 40 bits |
|
|
|
Problem 2: 7 bits |
|
|
|
Ship name 1: 7 bits |
|
|
|
Ship name 2: 7 bits |
|
|
|
Ship gqual: 7 bits |
|
|
|
Ship bqual: 7 bits |
|
|
|
Character 1 name: 40 bits |
|
|
|
Character 1 career: 7 bits |
|
|
|
Character 1 order: 3 bits |
|
|
|
Character 1 chaos: 3 bits |
|
|
|
Character 1 body: 3 bits |
|
|
|
Character 1 brain: 3 bits |
|
|
|
Character 1 gadget: 7 bits |
|
|
|
Character 2 name: 40 bits |
|
|
|
Character 2 career: 7 bits |
|
|
|
Character 2 order: 3 bits |
|
|
|
Character 2 chaos: 3 bits |
|
|
|
Character 2 body: 3 bits |
|
|
|
Character 2 brain: 3 bits |
|
|
|
Character 2 gadget: 7 bits |
|
|
|
Character 3 name: 40 bits |
|
|
|
Character 3 career: 7 bits |
|
|
|
Character 3 order: 3 bits |
|
|
|
Character 3 chaos: 3 bits |
|
|
|
Character 3 body: 3 bits |
|
|
|
Character 3 brain: 3 bits |
|
|
|
Character 3 gadget: 7 bits |
|
|
|
Character 4 name: 40 bits |
|
|
|
Character 4 career: 7 bits |
|
|
|
Character 4 order: 3 bits |
|
|
|
Character 4 chaos: 3 bits |
|
|
|
Character 4 body: 3 bits |
|
|
|
Character 4 brain: 3 bits |
|
|
|
Character 4 gadget: 7 bits |
|
|
|
Character 5 name: 40 bits |
|
|
|
Character 5 career: 7 bits |
|
|
|
Character 5 order: 3 bits |
|
|
|
Character 5 chaos: 3 bits |
|
|
|
Character 5 body: 3 bits |
|
|
|
Character 5 brain: 3 bits |
|
|
|
Character 5 gadget: 7 bits |
|
|
|
Character 6 name: 40 bits |
|
|
|
Character 6 career: 7 bits |
|
|
|
Character 6 order: 3 bits |
|
|
|
Character 6 chaos: 3 bits |
|
|
|
Character 6 body: 3 bits |
|
|
|
Character 6 brain: 3 bits |
|
|
|
Character 6 gadget: 7 bits |
|
|
|
""" |
|
|
|
densePwd = pw.replace(" ", "") |
|
|
|
if densePwd == "PACKTACTICS!------------------------------------------------------------------------------------": |
|
|
|
# Create a campaign featuring the Season 3 Pack Tactics crew. |
|
|
|
return |
|
|
|
elif densePwd == "JUSTINBAILEY------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but everyone's Gadget is a leotard that somehow is also an environment suit |
|
|
|
return |
|
|
|
elif densePwd == "NARPASSWORD------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but all the kobolds' stats are set to 6 |
|
|
|
return |
|
|
|
numPwd = [] |
|
|
|
for c in densePwd: |
|
|
|
numPwd.append(Campaign.ALPHABET.index(c)) |
|
|
|
bitPwd = [bin(x).replace("0b","") for x in numPwd] |
|
|
|
longBitPwd = [] |
|
|
|
for word in bitPwd: |
|
|
|
longword = word |
|
|
|
while len(longword) < 6: |
|
|
|
longword = "0" + longword |
|
|
|
longBitPwd.append(longword) |
|
|
|
self.newBitfield = "".join(longBitPwd) |
|
|
|
print(self.newBitfield) |
|
|
|
return self.newBitfield |
|
|
|
densePwd = pw.replace(" ", "") |
|
|
|
if densePwd == "PACKTACTICS!------------------------------------------------------------------------------------": |
|
|
|
# Create a campaign featuring the Season 3 Pack Tactics crew. |
|
|
|
return |
|
|
|
elif densePwd == "JUSTINBAILEY------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but everyone's Gadget is a leotard that somehow is also an environment suit |
|
|
|
return |
|
|
|
elif densePwd == "NARPASSWORD------------------------------------------------------------------------------------": |
|
|
|
# Create a random campaign, but all the kobolds' stats are set to 6 |
|
|
|
return |
|
|
|
numPwd = [] |
|
|
|
for c in densePwd: |
|
|
|
numPwd.append(Campaign.ALPHABET.index(c)) |
|
|
|
bitPwd = [lpad(bin(x).replace("0b",""), 6) for x in numPwd] |
|
|
|
longBitPwd = [] |
|
|
|
for word in bitPwd: |
|
|
|
longword = lpad(word,6) |
|
|
|
longBitPwd.append(longword) |
|
|
|
self.newBitfield = "".join(longBitPwd) |
|
|
|
while len(self.newBitfield) < 509: |
|
|
|
self.newBitfield += "0" |
|
|
|
outkey = {} |
|
|
|
# Location 1: 7 bits |
|
|
|
i,j = 0,7 |
|
|
|
outkey["loc1"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Location 2: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["loc2"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Location Battlefield: 1 bit |
|
|
|
i,j = j,j+1 |
|
|
|
outkey["battlefield"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Mission: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["miss"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Oops: 1 bit |
|
|
|
i,j = j,j+1 |
|
|
|
outkey["oops"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Problem 1: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["prob1"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Problem 1 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["prob1name"] = self.newBitfield[i:j] |
|
|
|
# Problem 2: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["prob2"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Ship name 1: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["sname1"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Ship name 2: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["sname2"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Ship gqual: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["gqual"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Ship bqual: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["bqual"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char1name"] = self.newBitfield[i:j] |
|
|
|
# Character 1 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char1career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char1ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char1cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char1bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char1bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 1 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char1gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char2name"] = self.newBitfield[i:j] |
|
|
|
# Character 2 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char2career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char2ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char2cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char2bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char2bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 2 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char2gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char3name"] = self.newBitfield[i:j] |
|
|
|
# Character 3 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char3career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char3ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char3cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char3bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char3bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 3 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char3gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char4name"] = self.newBitfield[i:j] |
|
|
|
# Character 4 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char4career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char4ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char4cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char4bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char4bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 4 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char4gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char5name"] = self.newBitfield[i:j] |
|
|
|
# Character 5 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char5career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char5ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char5cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char5bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char5bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 5 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char5gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 name: 40 bits |
|
|
|
i,j = j,j+40 |
|
|
|
outkey["char6name"] = self.newBitfield[i:j] |
|
|
|
# Character 6 career: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char6career"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 order: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char6ord"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 chaos: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char6cha"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 body: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char6bod"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 brain: 3 bits |
|
|
|
i,j = j,j+3 |
|
|
|
outkey["char6bra"] = int(self.newBitfield[i:j], 2) |
|
|
|
# Character 6 gadget: 7 bits |
|
|
|
i,j = j,j+7 |
|
|
|
outkey["char6gad"] = int(self.newBitfield[i:j], 2) |
|
|
|
print(self.newBitfield) |
|
|
|
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() |
|
|
|
return self.newBitfield |
|
|
|
|
|
|
|
def encode_name(self, name): |
|
|
|
field = "".join([lpad(bin(Campaign.NAMELETS.index(c.lower()))[2:], 5) for c in name]) |
|
|
|
return field |
|
|
|
|
|
|
|
def decode_name(self, field): |
|
|
|
i,j = 35,40 |
|
|
|
name = "" |
|
|
|
for _ in range(8): |
|
|
|
k = int(field[i:j], 2) |
|
|
|
if k != 31: |
|
|
|
name = Campaign.NAMELETS[k] + name |
|
|
|
i,j = i-5, i |
|
|
|
name = name[0].upper() + name[1:] |
|
|
|
return name |
|
|
|
|
|
|
|
def print_params(self, endc=" ", html=False): |
|
|
|
print(len(Plot.miss)) |
|
|
|
# print(len(Plot.miss)) |
|
|
|
st = ["Order:", "Chaos:", "Brains:", "Body:"] |
|
|
|
cst = ", ".join([" ".join(y) for y in list(zip(st, [str(x) for x in self.params.problem["stats"]]))]) |
|
|
|
if self.params.oops == 1: |
|
|
|
oops = "...well, they weren't paying attention, so don't tell them, but they're supposed " |
|
|
|
oops = "...well, they weren't paying attention, so don't tell them, but they're supposed to" |
|
|
|
else: |
|
|
|
oops = "" |
|
|
|
location = oops + self.params.location |
|
|
|
mission = oops + self.params.mission |
|
|
|
lines = [ |
|
|
|
f"The Kobolds of the {self.ship.fullname}", |
|
|
|
f"have been sent out to {self.art} {self.params.loc_desc} {location}!", |
|
|
|
f"in order {self.params.mission}", |
|
|
|
f"have been sent out to {self.art} {self.params.loc_desc} {self.params.location}!", |
|
|
|
f"in order to {self.params.mission}", |
|
|
|
f"but they're challenged by {self.params.fullProblem}!", |
|
|
|
f"The stats of the {self.params.problem['shortname']}", |
|
|
|
f"{cst}" |
|
|
@@ -674,6 +791,11 @@ class Campaign: |
|
|
|
class Password: |
|
|
|
pass |
|
|
|
|
|
|
|
def lpad(s, n, c="0"): |
|
|
|
while len(s) < n: |
|
|
|
s = c + s |
|
|
|
return s |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
parser = argparse.ArgumentParser() |
|
|
|
group = parser.add_mutually_exclusive_group() |
|
|
@@ -688,10 +810,9 @@ if __name__ == "__main__": |
|
|
|
# print(args) |
|
|
|
html = True if args.html else False |
|
|
|
if args.password: |
|
|
|
pw = Password(args.password) |
|
|
|
#pw = Password(args.password) |
|
|
|
# print(pw.newBitfield) |
|
|
|
cmp = Campaign(fromPW = True) |
|
|
|
cmp.decode(pw) |
|
|
|
cmp = Campaign(fromPW = True, pw=args.password) |
|
|
|
elif args.campaign: |
|
|
|
cmp = Campaign(args.campaign) |
|
|
|
cmp.print_params(html=html) |