Quellcode durchsuchen

Get rid of commented print statements

master
Noëlle vor 4 Jahren
Ursprung
Commit
16435df685
1 geänderte Dateien mit 8 neuen und 36 gelöschten Zeilen
  1. 8
    36
      koboldgen.py

+ 8
- 36
koboldgen.py Datei anzeigen

@@ -342,8 +342,10 @@ class Campaign:
self.params = None
self.characters = None
self.art = None
self.masterpassword = pw
self.decode_key(pw)
else:
self.masterpassword = None
self.create_campaign(n, makeChars)

def create_campaign(self, n, makeChars):
@@ -457,49 +459,28 @@ class Campaign:
"gadget": bin(chct.gadget["id"])[2:]
}
i += 1
# print(chars)
l1 = lpad(l1, 7)
# print(f"Len(l1) = {len(l1)}")
l2 = lpad(l2, 7)
# print(f"Len(l2) = {len(l2)}")
ms = lpad(ms, 7)
# print(f"Len(ms) = {len(ms)}")
pb1 = lpad(pb1, 7)
# print(f"Len(pb1) = {len(pb1)}")
pb2 = lpad(pb2, 7)
# print(f"Len(pb2) = {len(pb2)}")
pbname = lpad(pbname, 40, "1")
# print(f"Len(pbname) = {len(pbname)}")
n1 = lpad(n1, 7)
# print(f"Len(n1) = {len(n1)}")
n2 = lpad(n2, 7)
# print(f"Len(n2) = {len(n2)}")
gq = lpad(gq, 7)
# print(f"Len(gq) = {len(gq)}")
bq = lpad(bq, 7)
# 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, "1")
# print(f"Len(chct.name) = {len(chct['name'])}")
chct["career"] = lpad(chct["career"], 7)
# print(f"Len(chct.career) = {len(chct['career'])}")
chct["order"] = lpad(chct["order"],3)
# print(f"Len(chct.order) = {len(chct['order'])}")
chct["chaos"] = lpad(chct["chaos"], 3)
# print(f"Len(chct.chaos) = {len(chct['chaos'])}")
chct["body"] = lpad(chct["body"], 3)
# print(f"Len(chct.body) = {len(chct['body'])}")
chct["brains"] = lpad(chct["brains"], 3)
# print(f"Len(chct.brains) = {len(chct['brains'])}")
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 = []
@@ -517,7 +498,6 @@ class Campaign:
word = []
words.append("".join(word))
self.password = " ".join(words)
# print(self.password)
return self.password

def decode_key(self, pw):
@@ -729,8 +709,6 @@ class Campaign:
# 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.art = "an" if self.params.loc_desc[0] in ["a","e","i","o","u"] else "a"
@@ -739,10 +717,7 @@ class Campaign:
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
#return self.newBitfield

def encode_name(self, name):
field = "".join([lpad(bin(Campaign.NAMELETS.index(c.lower()))[2:], 5) for c in name])
@@ -760,7 +735,6 @@ class Campaign:
return name

def print_params(self, endc=" ", html=False):
# 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:
@@ -856,7 +830,10 @@ class Campaign:
print(f"</div>\n<br clear='all'>\n")

def print_password(self, html=False):
pw = self.generate_key()
if self.masterpassword:
pw = self.masterpassword
else:
pw = self.generate_key()
if html:
out = (
f"<div id='password'>"
@@ -865,15 +842,13 @@ class Campaign:
f"</div>"
)
print(out)
print(f"<br clear='all'>\n")
else:
print(f"Password: {pw}")

def decode(self, pwd):
pass

class Password:
pass

def lpad(s, n, c="0"):
while len(s) < n:
s = c + s
@@ -890,11 +865,8 @@ if __name__ == "__main__":
group.add_argument("-pw", "--password", help="print the campaign defined by the submitted password", type=str, nargs="?", const=1, metavar="PW")
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.password:
#pw = Password(args.password)
# print(pw.newBitfield)
cmp = Campaign(fromPW = True, pw=args.password)
cmp.print_params(html=html)
cmp.print_chars(html=html)

Laden…
Abbrechen
Speichern