Skip to content

Handler

progature.engine.core.game.handler

GameHandler

GameHandler(game_path)

This class is used to comunicate with JSON files, We use GameHandler in other part of our apps to change our JSON db. This class is an API between Python and JSON.

Attributes:

Name Type Description
game_path str

Path of the Game's JSON file.

game_json dict

dict representation of the Game's JSON file.

Examples:

>>> g_h = GameHandler("GAME_PATH")
>>> with g_h as handler:
>>>     handler.game_complete()

Game handler that handles game's files, This class is an interface between Python and JSON.

Parameters:

Name Type Description Default
game_path str

Path of the game we want to work with it's files.

required
game_path instance-attribute
game_path = game_path
game_json instance-attribute
game_json = {}
game_complete
game_complete()

Write True on is_complete for Game object. This method makes the Game and its JSON file completed.

chapter_complete
chapter_complete(chapter_index)

Write True on is_complete for Chapter object.

Parameters:

Name Type Description Default
chapter_index int

Index of the chapter you want to complete.

required
level_complete
level_complete(chapter_index, level_index)

Write True on is_complete for Level object.

Parameters:

Name Type Description Default
chapter_index int

Index of the level's chapter you want to complete.

required
level_index int

Index of the level you want to complete.

required
quest_complete
quest_complete(chapter_index, level_index, quest_index)

Write True on is_complete key for Quest.

Parameters:

Name Type Description Default
chapter_index int

Index of the quest's level's chapter you want to complete.

required
level_index int

Index of the quest's level you want to complete.

required
quest_index int

Index of the quest you want to complete.

required