nokey.games package
Submodules
nokey.games.free_to_game module
- class nokey.games.free_to_game.FreeToGame(use_caching=False, cache_name='freetogame_cache', backend='sqlite', expire_after=3600)[source]
Bases:
objectClass to interact with the Free To Game API.
- base_url
The base URL of the Free To Game API.
- about
A short description of the API.
- filter_games(tag, platform='all', sort_by=None)[source]
Returns a list of free games by category.
- Parameters:
tag (str) – The filter tags, representing the categories of the filtered games, period delimited, no spaces. Supported values are mmorpg, shooter, strategy, moba, racing, sports, social, sandbox, open-world, survival, pvp, pve, pixel, voxel, zombie, turn-based, first-person, third-Person, top-down, tank, space, sailing, side-scroller, superhero, permadeath, card, battle-royale, mmo, mmofps, mmotps, 3d, 2d, anime, fantasy, sci-fi, fighting, action-rpg, action, military, martial-arts, flight, low-spec, tower-defense, horror, mmorts.
platform (str) – Optional parameter representing the platform on which the games are played. Default is all, but other supported values are browser and pc.
sort_by (str) – Optional parameter by which to sort games if desired. Defaults to None, but supported values are release-date, popularity, alphabetical or relevance.
- Returns:
A dictionary containing the free games matching the given category.
- Return type:
dict
- get_all_live_games(sort_by=None)[source]
Returns the live games listed in the API.
- Parameters:
sort_by (str) – Optional parameter by which to sort games if desired. Defaults to None, but supported values are release-date, popularity, alphabetical or relevance.
- Returns:
A dictionary containing all the live games listed in the API.
- Return type:
dict
- get_docs_url()[source]
Returns the URL for the Free To Game API documentation.
- Parameters:
None –
- Returns:
The URL for the API docs.
- Return type:
string
- get_game_by_id(gameID)[source]
Returns information for a single game matching the id.
- Parameters:
gameID (int) – A number representing the unique id of the game as listed in the API.
- Returns:
A dictionary containing information for the game matching the given id.
- Return type:
dict
- get_games_by_category(category, sort_by=None)[source]
Returns a list of free games by category.
- Parameters:
category (str) – The category of the game. Supported values are mmorpg, shooter, strategy, moba, racing, sports, social, sandbox, open-world, survival, pvp, pve, pixel, voxel, zombie, turn-based, first-person, third-Person, top-down, tank, space, sailing, side-scroller, superhero, permadeath, card, battle-royale, mmo, mmofps, mmotps, 3d, 2d, anime, fantasy, sci-fi, fighting, action-rpg, action, military, martial-arts, flight, low-spec, tower-defense, horror, mmorts.
sort_by (str) – Optional parameter by which to sort games if desired. Defaults to None, but supported values are release-date, popularity, alphabetical or relevance.
- Returns:
A dictionary containing the free games matching the given category.
- Return type:
dict
- get_games_by_platform(platform, sort_by=None)[source]
Returns a list of free games by platform.
- Parameters:
platform (str) – The platform on which the game is played. Supported values are pc, browser, or all.
sort_by (str) – Optional parameter by which to sort games if desired. Defaults to None, but supported values are release-date, popularity, alphabetical or relevance.
- Returns:
A dictionary containing the free games played on the given platform.
- Return type:
dict
- get_games_by_platform_and_category(platform, category, sort_by=None)[source]
Returns a list of free games by category.
- Parameters:
platform (str) – The platform on which the game is played. Supported values are pc, browser, or all.
category (str) – The category of the game. Supported values are mmorpg, shooter, strategy, moba, racing, sports, social, sandbox, open-world, survival, pvp, pve, pixel, voxel, zombie, turn-based, first-person, third-Person, top-down, tank, space, sailing, side-scroller, superhero, permadeath, card, battle-royale, mmo, mmofps, mmotps, 3d, 2d, anime, fantasy, sci-fi, fighting, action-rpg, action, military, martial-arts, flight, low-spec, tower-defense, horror, mmorts.
sort_by (str) – Optional parameter by which to sort games if desired. Defaults to None, but supported values are release-date, popularity, alphabetical or relevance.
- Returns:
A dictionary containing the free games matching the given category.
- Return type:
dict
nokey.games.open_trivia_db module
- class nokey.games.open_trivia_db.OpenTriviaDB(use_caching=False, cache_name='open_trivia_cache', backend='sqlite', expire_after=3600)[source]
Bases:
objectA class for interacting with the Open Trivia Database API.
- base_url
The base URL of the API.
- about
A short description of the API.
- get_docs_url()[source]
Returns the URL for the Open Trivia Database API documentation.
- Parameters:
None –
- Returns:
The URL for the API docs.
- Return type:
string
- get_random_trivia_questions(amount)[source]
Returns the specified amount of random trivia questions of various difficulties and subjects, and the answers to those questions.
- Parameters:
amount (int) – The number of trivia desired.
- Returns:
A dictionary containing the specified amount of trivia questions along with relevant data and the answers.
- Return type:
dict
- get_specified_trivia_questions(amount, category=None, difficulty=None, q_type=None)[source]
Returns the specified amount of trivial questions matching the given parameters, along with relevant data and answers to the questions.
- Parameters:
amount (int) – The number of trivia questions to return.
category (int) – The category of trivia questions desired. Defaults to None, in which case any categories will be returned.
difficulty (str) – The difficulty level of the trivia questions. Defaults to None, in which case each question can be any difficulty level. Supported values are easy, medium, and hard.
q_type (str) – The type of questions. Defaults to None, in which case the types are random. Supported values are boolean (True or False) and multiple (Multiple Choice).
nokey.games.shadify module
- class nokey.games.shadify.Shadify(use_caching=False, cache_name='shadify_cache', backend='sqlite', expire_after=3600)[source]
Bases:
objectA class for interacting with the Shadify API.
- base_url
The base URL of the API.
- about
A short description of the API.
- about_anagram()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_camp()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_countries()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_kuromasu()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_math()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_memory()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_minesweeper()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_schulte()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_set()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_sudoku()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_takuzu()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- about_wordsearch()[source]
Returns a short description of the game.
- Parameters:
None –
- Returns:
A short description of the game.
- Return type:
string
- check_camp_task(row_tents, column_tents, solution)[source]
Checks the given camp task grid and returns whether or not it is correct.
- Parameters:
row_tents (list) – A list containing the row tents values.
column_tents (list) –
solution (array) – A two dimensional array containing the solution grid.
- Returns:
A dictionary containing whether or not the solution is valid, where the error occurs if it is not, and a message.
- Return type:
dict
- check_kuromasu_task(solution)[source]
Checks the given kuromasu task grid and returns whether or not it is correct.
- Parameters:
solution (array) – A two dimensional array containing the solution grid.
- Returns:
A dictionary containing whether or not the solution is valid, where the error occurs if it is not.
- Return type:
dict
- check_sudoku(puzzle_grid)[source]
Returns whether or not the provided sudoku grid is correct or not.
- Parameters:
puzzle_grid (array) – A two-dimensional grid (list of lists), where each list is a row in the sudoku grid.
- Returns:
A dictionary containing whether or not the given puzzle is correctly solved, as well as which row contains incorrect values.
- Return type:
dict
- check_takuzu(puzzle_grid)[source]
Returns whether or not the provided takuzu grid is correct or not.
- Parameters:
puzzle_grid (array) – A two-dimensional grid (list of lists), where each list is a row in the takuzu grid.
- Returns:
A dictionary containing whether or not the given puzzle is correctly solved, as well as which row contains incorrect values.
- Return type:
dict
- generate_addition(min_first=1, max_first=99, min_second=1, max_second=99)[source]
Returns a generated addition expression.
- Parameters:
min_first (int) – Optional. Minimum value of the first number in the expression. Default is 1.
max_first (int) – Optional. Maximum value of the first number in the expression. Default is 99.
min_second (int) – Optional. Minimum value of the second number in the expression. Default is 1.
max_second (int) – Optional. Maximum value of the second number in the expression. Default is 99.
- Returns:
A dictionary containing the generated expression.
- Return type:
dict
- generate_capital_quiz(variants=4, amount=1)[source]
Returns a country capital quiz and answer the the quiz.
- Parameters:
variants (int) – Optional. A number from 2 to 6 corresponding to the number of different options from which you have to choose the correct capital of the given country. Default is 4.
amount (int) – Optional. A number from 1 to 20 which is responsible for the number of quizzes returned. The use of this parameter ensures that among all quizzes received, all will be unique. Default is 1.
- Returns:
A dictionary containing a country name, a link to its flag, possible answers for its capital, and correct answer.
- Return type:
dict
- generate_country_quiz(variants=4, amount=1)[source]
Returns a country capital quiz and answer the the quiz.
- Parameters:
variants (int) – Optional. A number from 2 to 6 corresponding to the number of different options from which you have to choose the the correct country of the given flag image. Default is 4.
amount (int) – Optional. A number from 1 to 20 which is responsible for the number of quizzes returned. The use of this parameter ensures that among all quizzes received, all will be unique. Default is 1.
- Returns:
A dictionary containing a link to a country’s flag, possible answers for the country, and correct answer.
- Return type:
dict
- generate_division(min_first=1, max_first=99)[source]
Returns a generated division expression.
- Parameters:
min_first (int) – Optional. Minimum value of the first number in the expression. Default is 1.
max_first (int) – Optional. Maximum value of the first number in the expression. Default is 99.
- Returns:
A dictionary containing the generated expression.
- Return type:
dict
- generate_multiplication(min_first=1, max_first=99, min_second=1, max_second=99)[source]
Returns a generated multiplication expression.
- Parameters:
min_first (int) – Optional. Minimum value of the first number in the expression. Default is 1.
max_first (int) – Optional. Maximum value of the first number in the expression. Default is 99.
min_second (int) – Optional. Minimum value of the second number in the expression. Default is 1.
max_second (int) – Optional. Maximum value of the second number in the expression. Default is 99.
- Returns:
A dictionary containing the generated expression.
- Return type:
dict
- generate_quadratic_equation(min_a=1, max_a=20, min_b=1, max_b=40, min_c=1, max_c=20)[source]
Returns a generated quadratic equation.
- Parameters:
min_a (int) – Minimum value of coefficient a. Default is 1.
max_a (int) – Maximum value of coefficient a. Default is 20.
min_b (int) – Minimum value of coefficient b. Default is 1.
max_b (int) – Maximum value of coefficient b. Default is 40.
min_c (int) – Minimum value of coefficient c. Default is 1.
max_c (int) – Maximum value of coefficient c. Default is 20.
- Returns:
A dictionary containing the generated equation.
- Return type:
dict
- generate_random_anagram()[source]
Returns a word as the task and the possible words that can be composed from the word.
- Parameters:
None –
- Returns:
A dictionary containing a task word and a list of words that can be composed from this word.
- Return type:
dict
- generate_random_camp_task(width=7, height=7, solution=True)[source]
Returns a camp game grid and the solution.
- Parameters:
width (int) – Optional. A number from 5 to 15 which corresponds to the width of the generated field. Default is 7.
height (int) – Optional. A number from 5 to 15 which corresponds to the height of the generated field. Default is 7.
solution (bool) – Optional. The true/false value that specifies whether the solution should be sent with the task or not. Default is True.
- Returns:
A dictionary containing the camp grid task and the solution if solution is True.
- Return type:
dict
- generate_random_kuromasu_task(width=5, height=5, fill=30)[source]
Returns a kuromasu task grid and the solution.
- Parameters:
width (int) – Optional. A number from 4 to 15 which corresponds to the width of the generated field. Default is 5.
height (int) – Optional. A number from 4 to 15 which corresponds to the height of the generated field. Default is 5.
fill (int) – Optional. A number from 10 to 50 which corresponds to the % level of filling the task with ready cells.
- Returns:
A dictionary containing the kuromasu grid task and the solution.
- Return type:
dict
- generate_random_memory_grid(width=6, height=4, pair_size=3, show_positions=True)[source]
Returns a memory grid and pair positions.
- Parameters:
width (int) –
height (int) – Optional. A number corresponding to the height of the generated grid. The total number of cells in the grid must not exceed 52 multiplied by the pair-size. Default is 4.
pair_size (int) – Optional. A number corresponding to the size of a pair of identical elements. The value must be a multiple of the total number of cells in the grid. Available values: 2, 3, 4. Default is 3.
show_positions (bool) – Optional. A true/false value that determines whether to send position information for each pair of elements. Default is True.
- Returns:
A dictionary containing a memory grid and pair positions.
- Return type:
dict
- generate_random_minesweeper_field(start, width=9, height=9, mines=12)[source]
Returns a randomly generated minesweeper grid.
- Parameters:
start (str) – A string of the form 1-2, which sets the starting position of the player. There will never be mines in and around this position. The first number is the X coordinate (from 1 to the value of the widht parameter), the second number is the Y coordinate (from 1 to the value of the height parameter).
width (int) – The number that sets the width of the generated field. The total number of cells in the field must not exceed 1000. Default is 9.
height (int) – The number that sets the height of the generated field. The total number of cells in the field must not exceed 1000. Default is 9.
mines (int) – The number that sets the number of mines on the field. The number of mines must not exceed 25% of the total number of cells on the field. Default is 12.
- Returns:
A dictionary containing the minesweeper board grid and other data.
- Return type:
dict
- generate_random_schulte_table(size=5, mode='number')[source]
Returns a random schulte table.
- Parameters:
size (int) – The size of the generated table. The available range is from 1 to 15. Default is 5.
mode (str) – numbers or letters. If alphabet is selected, the size parameter will always be 5. Default is number
- Returns:
A dictionary containing a grid representing the schulte table.
- Return type:
dict
- generate_random_sudoku(fill=30)[source]
Returns a random sudoku puzzle, both the finished (“grid”) and the unfinished (“task”) versions.
- Parameters:
fill (int) – A number from 0 to 50 that corresponds to the field fill level (as a percentage). Default is 30.
- Returns:
A dictionary containing two grids: the unfinished and finished versions of the puzzle.
- Return type:
dict
- generate_random_takuzu(size=8, fill=33)[source]
Returns a random takuzu puzzle, both the finished (“field”) and the unfinished (“task”) versions.
- Parameters:
size (int) – An even number from 4 to 12, which specifies the size of the field. Default is 8.
fill (int) – A number from 0 to 100 that corresponds to the field fill level (as a percentage). Default is 33.
- Returns:
A dictionary containing two grids: the unfinished and finished versions of the puzzle, as well as the size of the grid.
- Return type:
dict
- generate_random_wordsearch_grid(width=9, height=9)[source]
Returns a randomly generated wordsearch grid.
- Parameters:
width (int) – A number from 5 to 20 that specifies the width of the grid. The total number of cells in the field must not exceed 256. Default is 9.
height (int) – A number from 5 to 20 that specifies the width of the grid. The total number of cells in the field must not exceed 256. Default is 9.
- Returns:
Returns a dictionary containing the wordsearch grid and the key.
- Return type:
dict
- generate_subtraction(min_first=1, max_first=99, min_second=1, max_second=99, negative=0)[source]
Returns a generated subtraction expression.
- Parameters:
min_first (int) – Optional. Minimum value of the first number in the expression. Default is 1.
max_first (int) – Optional. Maximum value of the first number in the expression. Default is 99.
min_second (int) – Optional. Minimum value of the second number in the expression. Default is 1.
max_second (int) – Optional. Maximum value of the second number in the expression. Default is 99.
negative (int) – Optional. The number 0/1 which enables/disables the possibility of generating a result with a negative value for expressions with subtraction. Initially, when generating an expression with subtraction, the first number is always greater than the second number. To change this behavior, use this parameter. Default is 0.
- Returns:
A dictionary containing the generated expression.
- Return type:
dict
- get_all_set_cards(possible_sets=True)[source]
Always returns the same array of 81 objects. Each object corresponds to one of the cards.
- Parameters:
possible_sets (bool) – A true/false string that enables/disables the search for possible sets in the current layout. The list of possible sets is not necessary for the game and acts only as a hint and evidence that sets exist in the current layout.
- Returns:
A dictionary containing
- Return type:
dict
- get_docs_url()[source]
Returns the URL for the Shadify API documentation.
- Parameters:
None –
- Returns:
The URL for the API docs.
- Return type:
string
- load_set_state(state, possible_sets=True, action=None, cards=None)[source]
Always returns the same array of 81 objects. Each object corresponds to one of the cards.
- Parameters:
state (str) – A string of hyphenated, no spaced numbers representing the state of the cards.
possible_sets (bool) – A true/false string that enables/disables the search for possible sets in the current layout. The list of possible sets is not necessary for the game and acts only as a hint and evidence that sets exist in the current layout.
action (str) – Optional. The add/remove string, which allows you to perform the appropriate action with the current game state. The add string adds 3 random cards from the current freeCards array to the current layout (available only if the layout size does not exceed 20 cards). The remove string removes the specified combination of three cards from the current layout. To do this you must use the cards parameter. Default is None.
cards (str) – Required if action=remove. A string of the form 1-2-3, where each number corresponds to the unique identifier of one of the cards that make up the set. Default is None.
- Returns:
A dictionary containing
- Return type:
dict