Compare commits

...

3 Commits

Author SHA1 Message Date
Kyler Olsen 20fc64654b Added a bible only mode 2025-04-24 23:26:52 -06:00
Kyler Olsen e2dc2a0e5e Improved references handling 2025-04-24 23:23:47 -06:00
Kyler Olsen 2f710acba0 Fixed error in partially correct references 2025-04-24 23:23:18 -06:00
3 changed files with 18 additions and 9 deletions

View File

@ -19,8 +19,9 @@ class Library:
__host: str __host: str
__port: int __port: int
__socket: socket.socket __socket: socket.socket
__bible_only: bool
def __init__(self, host: str = '', port: int = 7788): def __init__(self, host: str = '', port: int = 7788, *, bible_only: bool = False):
with open("data/scripture-frequencies.json", encoding='utf-8') as file: with open("data/scripture-frequencies.json", encoding='utf-8') as file:
self.__verses = json.load(file) self.__verses = json.load(file)
self.__games = [] self.__games = []
@ -29,6 +30,8 @@ class Library:
self.__port = port self.__port = port
self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.__bible_only = bible_only
def serve_forever(self): def serve_forever(self):
try: try:
print(f"Starting server at {self.__host}:{self.__port}") print(f"Starting server at {self.__host}:{self.__port}")
@ -108,13 +111,17 @@ class Library:
difficulty_verses = [] difficulty_verses = []
for key, value in self.__verses.items(): for key, value in self.__verses.items():
if self.__bible_only and not (key.startswith('/ot') or key.startswith('/nt')):
continue
for i, diff in enumerate(value): for i, diff in enumerate(value):
if real_difficulty_lower <= diff <= real_difficulty_upper: if real_difficulty_lower <= diff <= real_difficulty_upper:
difficulty_verses.append(f"{key}/{i+1}") difficulty_verses.append(f"{key}/{i+1}")
if not difficulty_verses: difficulty_verses.append('/pgp/js-h/1/17')
return difficulty_verses return difficulty_verses
if __name__ == '__main__': if __name__ == '__main__':
lib = Library() lib = Library(bible_only=False)
lib.serve_forever() lib.serve_forever()

View File

@ -15,13 +15,13 @@ __LINKS = {
'/ot/2-sam': ("2 Sam.", "2 Samuel", ), '/ot/2-sam': ("2 Sam.", "2 Samuel", ),
'/ot/1-kgs': ("1 Kgs.", "1 Kings", ), '/ot/1-kgs': ("1 Kgs.", "1 Kings", ),
'/ot/2-kgs': ("2 Kgs.", "2 Kings", ), '/ot/2-kgs': ("2 Kgs.", "2 Kings", ),
'/ot/1-chr': ("1 Chr.", "1 Chronic, es", ), '/ot/1-chr': ("1 Chr.", "1 Chronicles", ),
'/ot/2-chr': ("2 Chr.", "2 Chronicles", ), '/ot/2-chr': ("2 Chr.", "2 Chronicles", ),
'/ot/ezra': ("Ezra", ), '/ot/ezra': ("Ezra", ),
'/ot/neh': ("Neh.", "Nehemiah", ), '/ot/neh': ("Neh.", "Nehemiah", ),
'/ot/esth': ("Esth.", "Esther", ), '/ot/esth': ("Esth.", "Esther", ),
'/ot/job': ("Job", ), '/ot/job': ("Job", ),
'/ot/ps': ("Ps.", "Psalms", "Psalm", ), '/ot/ps': ("Ps.", "Psalm", "Psalms", ),
'/ot/prov': ("Prov.", "Proverbs", ), '/ot/prov': ("Prov.", "Proverbs", ),
'/ot/eccl': ("Eccl.", "Ecclesiastes", ), '/ot/eccl': ("Eccl.", "Ecclesiastes", ),
'/ot/song': ("Song", "Song of Solomon", ), '/ot/song': ("Song", "Song of Solomon", ),
@ -75,7 +75,7 @@ __LINKS = {
'/bofm/enos': ("Enos", ), '/bofm/enos': ("Enos", ),
'/bofm/jarom': ("Jarom", ), '/bofm/jarom': ("Jarom", ),
'/bofm/omni': ("Omni", ), '/bofm/omni': ("Omni", ),
'/bofm/w-of-m': ("W of M", "Words of Mormon", ), '/bofm/w-of-m': ("WofM", "W of M", "Words of Mormon", ),
'/bofm/mosiah': ("Mosiah", ), '/bofm/mosiah': ("Mosiah", ),
'/bofm/alma': ("Alma", ), '/bofm/alma': ("Alma", ),
'/bofm/hel': ("Hel.", "Helaman", ), '/bofm/hel': ("Hel.", "Helaman", ),
@ -84,13 +84,13 @@ __LINKS = {
'/bofm/morm': ("Morm.", "Mormon", ), '/bofm/morm': ("Morm.", "Mormon", ),
'/bofm/ether': ("Ether", ), '/bofm/ether': ("Ether", ),
'/bofm/moro': ("Moro.", "Moroni", ), '/bofm/moro': ("Moro.", "Moroni", ),
'/dc-testament/dc': ("D&C", "Doctrine and Covenants", ), '/dc-testament/dc': ("D&C", "D & C", "DandC", "D and C", "D+C", "D + C", "Doctrine and Covenants", ),
'/dc-testament/od': ("OD", "Official Declaration", ), '/dc-testament/od': ("OD", "Official Declaration", ),
'/pgp/moses': ("Moses", ), '/pgp/moses': ("Moses", ),
'/pgp/abr': ("Abr.", "Abraham", ), '/pgp/abr': ("Abr.", "Abraham", ),
'/pgp/js-m': ("JS—M", "Joseph Smith—Matthew", "JS-M", "Joseph Smith-Matthew", ), '/pgp/js-m': ("JS—M", "Joseph Smith—Matthew", "JS-M", "JSM", "Joseph Smith-Matthew", ),
'/pgp/js-h': ("JS—H", "Joseph Smith—History", "JS-H", "Joseph Smith-History", ), '/pgp/js-h': ("JS—H", "Joseph Smith—History", "JS-H", "JSH", "Joseph Smith-History", ),
'/pgp/a-of-f': ("A of F", "Articles of Faith", ), '/pgp/a-of-f': ("A of F", "AofF", "Articles of Faith", ),
'/ot': ("OT", "Old Testament", "The Old Testament", ), '/ot': ("OT", "Old Testament", "The Old Testament", ),
'/nt': ("NT", "New Testament", "The New Testament", ), '/nt': ("NT", "New Testament", "The New Testament", ),
'/bofm': ("BofM", "Book of Mormon", "The Book of Mormon", ), '/bofm': ("BofM", "Book of Mormon", "The Book of Mormon", ),

View File

@ -90,6 +90,8 @@ class Game:
for player_url, current_url in zip(url.strip('/').split('/'), self.__current_url_parts): for player_url, current_url in zip(url.strip('/').split('/'), self.__current_url_parts):
if player_url == current_url: if player_url == current_url:
partially_correct.append(current_url) partially_correct.append(current_url)
else:
break
if partially_correct: if partially_correct:
player.guess_partial_correct(f"/{'/'.join(partially_correct)}") player.guess_partial_correct(f"/{'/'.join(partially_correct)}")
self.__round_points[self.__clients.index(player)] = len(partially_correct) self.__round_points[self.__clients.index(player)] = len(partially_correct)