Implement verse selection and difficulty filtering in Library class
This commit is contained in:
parent
af3721009a
commit
1307eb32f7
34
library.py
34
library.py
|
|
@ -5,6 +5,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game import Game
|
from game import Game
|
||||||
|
|
@ -32,14 +33,39 @@ class Library:
|
||||||
self.__games[game_num].add_player(name)
|
self.__games[game_num].add_player(name)
|
||||||
|
|
||||||
def get_verse(self, difficulty: int):
|
def get_verse(self, difficulty: int):
|
||||||
pass
|
print(self.__select_verse(difficulty))
|
||||||
|
|
||||||
def __select_verse(self, difficulty: int) -> str:
|
def __select_verse(self, difficulty: int) -> str:
|
||||||
pass
|
|
||||||
|
difficulty_verses = self.__get_verses_by_difficulty(difficulty)
|
||||||
|
|
||||||
|
# print(len(difficulty_verses))
|
||||||
|
|
||||||
|
return difficulty_verses[random.randint(0,len(difficulty_verses)-1)]
|
||||||
|
|
||||||
def __get_verse_text(self, url: str) -> str:
|
def __get_verse_text(self, url: str) -> str:
|
||||||
pass
|
volume, book, chapter, verse = url[1:].split('/')
|
||||||
|
|
||||||
|
if volume == 'ot': pass
|
||||||
|
elif volume == 'nt': pass
|
||||||
|
elif volume == 'bofm': pass
|
||||||
|
elif volume == 'dc-testament': pass
|
||||||
|
elif volume == 'pgp': pass
|
||||||
|
|
||||||
def __get_verses_by_difficulty(self, difficulty: int) -> list[str]:
|
def __get_verses_by_difficulty(self, difficulty: int) -> list[str]:
|
||||||
pass
|
real_difficulty_upper = pow((10-difficulty)/9, 2) * 500
|
||||||
|
real_difficulty_lower = pow((9-difficulty)/9.55, 3) * 500
|
||||||
|
|
||||||
|
difficulty_verses = []
|
||||||
|
for key, value in self.__verses.items():
|
||||||
|
for i, diff in enumerate(value):
|
||||||
|
if real_difficulty_lower <= diff <= real_difficulty_upper:
|
||||||
|
difficulty_verses.append(f"{key}/{i}")
|
||||||
|
|
||||||
|
return difficulty_verses
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
lib = Library()
|
||||||
|
for i in range(11): lib.get_verse(i)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue