Merge branch 'master' into 'ladders'

# Conflicts:
#   squirrelbattle/game.py
#   squirrelbattle/interfaces.py
#   squirrelbattle/tests/game_test.py
This commit is contained in:
2021-01-06 17:29:26 +01:00
27 changed files with 649 additions and 236 deletions

View File

@ -13,9 +13,10 @@ from .translations import gettext as _
class Settings:
"""
This class stores the settings of the game.
Settings can be get by using for example settings.TEXTURE_PACK directly.
The comment can be get by using settings.get_comment('TEXTURE_PACK').
We can define the setting by simply use settings.TEXTURE_PACK = 'new_key'
Settings can be obtained by using for example settings.TEXTURE_PACK
directly.
The comment can be obtained by using settings.get_comment('TEXTURE_PACK').
We can set the setting by simply using settings.TEXTURE_PACK = 'new_key'
"""
def __init__(self):
self.KEY_UP_PRIMARY = ['z', 'Main key to move up']
@ -51,7 +52,7 @@ class Settings:
def get_comment(self, item: str) -> str:
"""
Retrieve the comment of a setting.
Retrieves the comment relative to a setting.
"""
if item in self.settings_keys:
return _(object.__getattribute__(self, item)[1])
@ -62,13 +63,13 @@ class Settings:
@property
def settings_keys(self) -> Generator[str, Any, None]:
"""
Get the list of all parameters.
Gets the list of all parameters.
"""
return (key for key in self.__dict__)
def loads_from_string(self, json_str: str) -> None:
"""
Dump settings
Loads settings.
"""
d = json.loads(json_str)
for key in d:
@ -76,7 +77,7 @@ class Settings:
def dumps_to_string(self) -> str:
"""
Dump settings
Dumps settings.
"""
d = dict()
for key in self.settings_keys: