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
|
@ -9,7 +9,7 @@ confp=os.path.expanduser('~/.config/swat.cfg') # This won't work on Windows. You
|
|||
defaults={'classes':[(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(0,0),(0,0),(1,3),(1,3),(1,3)],'guns':[(1,3),(1,3),(1,3),(1,3),(1,3),(0,0),(0,0),(0,0)],'armour':[(1,3),(1,3),(1,3),(1,3)],'traits':[(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3)],'specs':[(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3)],'talents':[(12,12),(1,3),(1,3),(1,3),(1,3),(1,3),(1,3)],'medals':{}}
|
||||
def add_user(name):
|
||||
namehash=encode.hash_name(name) # Store the hash so that if they request a different name that happens to have the same hash, it can just be stored together.
|
||||
if namehash in conf : conf[namehash]['names'].add(name)
|
||||
if namehash in conf: conf[namehash]['names'].add(name)
|
||||
else: conf[namehash]=defaults.copy()|{'names':{name}}
|
||||
save_conf()
|
||||
global active_profile
|
||||
|
@ -28,6 +28,8 @@ def load_conf():
|
|||
a=open(confp).read()
|
||||
for n in a.split('\n\n'):
|
||||
lines=n.split('\n')
|
||||
lines=list(filter(lambda x:x,lines))
|
||||
if not lines: continue
|
||||
header=lines[0].split(' ')
|
||||
nhash=int(header[0]); names=set(header[1:]) # Makes deduping way easier
|
||||
medals={}
|
||||
|
@ -128,7 +130,8 @@ def generate(officer=None,name=None):
|
|||
pieces[0]='wm'
|
||||
else: gun=''
|
||||
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):
|
||||
ind=lookup_piece(n[0],n[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):
|
||||
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
|
||||
return n,clas
|
Loading…
Reference in New Issue
Block a user