Fixed loading conf, medals will no longer disappear if you put an extra newline at the end, import won't crash if you have two newlines, etc.
This commit is contained in:
parent
cd2c4b637b
commit
df1a9c837b
@ -28,6 +28,8 @@ def load_conf():
|
|||||||
a=open(confp).read()
|
a=open(confp).read()
|
||||||
for n in a.split('\n\n'):
|
for n in a.split('\n\n'):
|
||||||
lines=n.split('\n')
|
lines=n.split('\n')
|
||||||
|
lines=list(filter(lambda x:x,lines))
|
||||||
|
if not lines: continue
|
||||||
header=lines[0].split(' ')
|
header=lines[0].split(' ')
|
||||||
nhash=int(header[0]); names=set(header[1:]) # Makes deduping way easier
|
nhash=int(header[0]); names=set(header[1:]) # Makes deduping way easier
|
||||||
medals={}
|
medals={}
|
||||||
@ -128,7 +130,8 @@ def generate(officer=None,name=None):
|
|||||||
pieces[0]='wm'
|
pieces[0]='wm'
|
||||||
else: gun=''
|
else: gun=''
|
||||||
out=[]
|
out=[]
|
||||||
rank,cap=12,12
|
if len(pieces)==6: rank=cap=int(pieces.pop(-1))
|
||||||
|
else: rank,cap=12,12
|
||||||
for n in zip(pieces,tables.displays_nogun,tables.displays_nogun_str):
|
for n in zip(pieces,tables.displays_nogun,tables.displays_nogun_str):
|
||||||
ind=lookup_piece(n[0],n[1])
|
ind=lookup_piece(n[0],n[1])
|
||||||
rank,cap=min(rank,pro[n[2]][ind][0]),min(cap,pro[n[2]][ind][1])
|
rank,cap=min(rank,pro[n[2]][ind][0]),min(cap,pro[n[2]][ind][1])
|
||||||
|
@ -71,6 +71,6 @@ def adjust_rank(rank,cap=-1, key=False,moh=False,pcc=False):
|
|||||||
|
|
||||||
def rand(seed,clas):
|
def rand(seed,clas):
|
||||||
if seed>-1: n=seed
|
if seed>-1: n=seed
|
||||||
else: n=int(random.random()*4)*2
|
else: n=int(random.random()*5)*2
|
||||||
if clas>9: return n+1,clas-10
|
if clas>9: return n+1,clas-10
|
||||||
return n,clas
|
return n,clas
|
@ -26,6 +26,7 @@ def combine(code,namehash=''):
|
|||||||
def fill0s(num,zeroes=0):
|
def fill0s(num,zeroes=0):
|
||||||
if not zeroes: return str(int(num))
|
if not zeroes: return str(int(num))
|
||||||
n=str(num)
|
n=str(num)
|
||||||
|
if len(n)>zeroes: raise Exception(f"can't pad {n} ({len(n)}) with {zeroes} 0s")
|
||||||
return '0'*(zeroes-len(n))+n
|
return '0'*(zeroes-len(n))+n
|
||||||
|
|
||||||
def muxhero(clas,trait,spec):
|
def muxhero(clas,trait,spec):
|
||||||
|
Loading…
Reference in New Issue
Block a user