36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
tracing=False
|
|
def trace(*args,**kwargs):
|
|
if tracing: print(*args,**kwargs)
|
|
|
|
def delimit(code,spacer=''):
|
|
if not spacer:
|
|
if len(code)==16: return code
|
|
if len(code)!=19: raise Exception('code length should be 19 for despacing, got',len(code),'from',code)
|
|
return code[0:4]+code[5:9]+code[10:14]+code[15:19]
|
|
if spacer:
|
|
if len(code)==19: return code
|
|
if len(code)!=16: raise Exception('code length should be 16 for spacing, got',len(code),'from',code)
|
|
return code[0:4]+spacer+code[4:8]+spacer+code[8:12]+spacer+code[12:16]
|
|
|
|
def scramble(code,unscramble=False):
|
|
n=int(code[0])
|
|
if unscramble: n=15-n # Because the 1st digit is left alone this needs to be +1
|
|
return code[0]+code[16-n:16]+code[1:16-n]
|
|
|
|
def combine(code,namehash=''):
|
|
if namehash: return code[0:2]+namehash[4:5]+code[2:6]+namehash[3:4]+code[6:8]+namehash[1:3]+code[8:11]+namehash[0:1]
|
|
charcode=code[0:2]+code[3:7]+code[8:10]+code[12:15]
|
|
namehash=code[15]+code[10:12]+code[7]+code[2]
|
|
return charcode,namehash
|
|
|
|
def fill0s(num,zeroes=0):
|
|
if not zeroes: return str(int(num))
|
|
n=str(num)
|
|
return '0'*(zeroes-len(n))+n
|
|
|
|
def muxhero(clas,trait,spec):
|
|
return clas+trait*12+spec*12*16 # It's actually stored backwards like this, spec is in the most significant bits. Whatever, it doesn't need to be reversable.
|
|
|
|
def muxmedals(key,moh=-1,pcc=-1,cob=-1,lsa=-1,rem=-1):
|
|
if moh!=-1: return key+moh*2+pcc*4+cob*8+lsa*16+rem*32
|
|
return bool(key&1),bool(key&2),bool(key&4),bool(key&8),bool(key&16),key//32 |