forked from rDrama/rDrama
pick the queen name based on first letter of username
parent
fe5261df36
commit
28cf9cc605
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
||||||
|
import string
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
|
@ -330,17 +331,24 @@ def award_thing(v, thing_type, id):
|
||||||
abort(409, f"{safe_username} is under the effect of a conflicting award: OwOify award!")
|
abort(409, f"{safe_username} is under the effect of a conflicting award: OwOify award!")
|
||||||
|
|
||||||
if not author.queen:
|
if not author.queen:
|
||||||
last_taken_name = g.db.query(User.username).filter(User.queen != None).order_by(User.queen.desc()).first()[0]
|
characters = list(filter(str.isalpha, author.username))
|
||||||
try: name_index = GIRL_NAMES.index(last_taken_name)
|
if characters:
|
||||||
except: name_index = 0
|
first_character = characters[0].upper()
|
||||||
|
else:
|
||||||
|
first_character = random.choice(string.ascii_letters).upper()
|
||||||
|
|
||||||
while True:
|
available_names = GIRL_NAMES[first_character]
|
||||||
new_name = GIRL_NAMES[name_index]
|
random.shuffle(available_names)
|
||||||
|
|
||||||
|
broken = False
|
||||||
|
for new_name in available_names:
|
||||||
existing = get_user(new_name, graceful=True)
|
existing = get_user(new_name, graceful=True)
|
||||||
if not existing: break
|
if not existing:
|
||||||
name_index += 1
|
broken = True
|
||||||
if name_index > (len(GIRL_NAMES) - 1):
|
break
|
||||||
name_index = 0
|
|
||||||
|
if not broken:
|
||||||
|
new_name = new_name + f'-{author.id}'
|
||||||
|
|
||||||
if not author.prelock_username:
|
if not author.prelock_username:
|
||||||
author.prelock_username = author.username
|
author.prelock_username = author.username
|
||||||
|
|
Loading…
Reference in New Issue