init commit
This commit is contained in:
parent
4e6936cec3
commit
060b99ab59
11
codegen.py
11
codegen.py
|
@ -123,15 +123,20 @@ def generate(officer=None):
|
|||
rank,cap=min(rank,pro[n[2]][ind][0]),min(cap,pro[n[2]][ind][1])
|
||||
out.append(ind)
|
||||
cap=(cap-(cap<10)+(cap>10))//3 # Derp
|
||||
if gun: out.insert(1,lookup_piece(gun,displays.guns))
|
||||
if gun: out.insert(1,lookup_piece(gun,tables.guns,True))
|
||||
else: out.insert(1,tables.gunmaps_wrapped[out[0]])
|
||||
out[-1]=tables.clas[out[0]].index(out[-1])
|
||||
return encode.encode(active_profile,*out,rank,cap)
|
||||
|
||||
def lookup_piece(piece,table):
|
||||
def lookup_piece(piece,table,partial=False):
|
||||
if len(piece)<3: p=piece.upper()
|
||||
else: p=piece.capitalize() # Bloody Americans
|
||||
return table.index(p)
|
||||
if not partial:
|
||||
try: return table.index(p)
|
||||
except ValueError: return None
|
||||
res=list(filter(lambda x:x.startswith(p),table))
|
||||
if len(res)!=1: return None # Ambiguous lookups not allowed
|
||||
return table.index(res[0])
|
||||
|
||||
def ranks():
|
||||
for n,m in zip(tables.displays_str,tables.displays):
|
||||
|
|
Loading…
Reference in New Issue
Block a user