Compare commits

...

2 Commits

Author SHA1 Message Date
a7e9d92d82 I might be retarded 2024-06-17 19:12:08 +10:00
78e9f4de0e whatever 2024-06-17 19:11:52 +10:00
5 changed files with 12 additions and 2 deletions

View File

@ -6,7 +6,7 @@ conf={}
confp=os.path.expanduser('~/.config/swat.cfg') # This won't work on Windows. You'll need to tweak this to run it on Windows. Not my problem. confp=os.path.expanduser('~/.config/swat.cfg') # This won't work on Windows. You'll need to tweak this to run it on Windows. Not my problem.
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),(1,3)],'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':{}} 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),(1,3)],'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':{},'saves':{}}
def add_user(name): 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. 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)
@ -158,7 +158,7 @@ def lookup_piece(piece,table,name,partial=False):
if not partial: if not partial:
try: return table.index(p) try: return table.index(p)
except ValueError: raise LookupException(f"Couldn't resolve {piece} from {name}") except ValueError: raise LookupException(f"Couldn't resolve {piece} from {name}")
res=list(filter(lambda x:p in x,table)) res=list(filter(lambda x:x.startswith(p),table))
if len(res)!=1: raise LookupException(f"Couldn't resolve {piece} with partial match from {name} (found {len(res)} possibilities)") # Ambiguous lookups not allowed if len(res)!=1: raise LookupException(f"Couldn't resolve {piece} with partial match from {name} (found {len(res)} possibilities)") # Ambiguous lookups not allowed
return table.index(res[0]) return table.index(res[0])
class LookupException(Exception): pass class LookupException(Exception): pass
@ -170,6 +170,15 @@ def ranks():
print(f'{o[0]}: {o[1][0]}/{o[1][1]}',end=', ') print(f'{o[0]}: {o[1][0]}/{o[1][1]}',end=', ')
print() print()
def savebuild(code,name):
pass
def builds():
pass
def medals():
pass
load_conf() load_conf()

View File

@ -35,4 +35,5 @@ def muxhero(clas,trait,spec):
def muxmedals(key,moh=-1,pcc=-1,cob=-1,lsa=-1,rem=-1): def muxmedals(key,moh=-1,pcc=-1,cob=-1,lsa=-1,rem=-1):
print(key,moh,pcc,cob,lsa,rem) print(key,moh,pcc,cob,lsa,rem)
if moh!=-1: return key+moh*2+pcc*4+cob*8+lsa*16+rem*32 if moh!=-1: return key+moh*2+pcc*4+cob*8+lsa*16+rem*32
print(bool(key&1),bool(key&2),bool(key&4),bool(key&8),bool(key&16),key//32)
return bool(key&1),bool(key&2),bool(key&4),bool(key&8),bool(key&16),key//32 return bool(key&1),bool(key&2),bool(key&4),bool(key&8),bool(key&16),key//32