Solved a missing dependancy
This commit is contained in:
@ -1,7 +1,88 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from .player_settings import Expansion
|
import abc
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from NoPELib.player_settings import ExpansionsManager
|
||||||
|
|
||||||
|
|
||||||
|
class Expansion:
|
||||||
|
"""
|
||||||
|
A meta class implementation meant to describe how to interact with any kind
|
||||||
|
of expansions.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
players (tuple of str):
|
||||||
|
tags (tuple of flag):
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
step:
|
||||||
|
reset:
|
||||||
|
close:
|
||||||
|
|
||||||
|
Signals:
|
||||||
|
onError:
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, ID: str, expansionsManager: ExpansionsManager):
|
||||||
|
"""
|
||||||
|
Initialise the creation of an expansion and raise an error if not
|
||||||
|
available.
|
||||||
|
"""
|
||||||
|
self._ID = ID
|
||||||
|
self._manager = expansionsManager
|
||||||
|
self.onError = Hook()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config(self):
|
||||||
|
return copy.deepcopy(self._manager.config[self._ID]["config"])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def players(self):
|
||||||
|
""" Players that have access to this expansion. """
|
||||||
|
return self._manager.config[self._ID]["players"]
|
||||||
|
|
||||||
|
@players.setter
|
||||||
|
def players(self, newPlayers):
|
||||||
|
""" Players that have access to this expansion. """
|
||||||
|
self._manager.config[self._ID]["players"] = tuple(newPlayers)
|
||||||
|
self._manager.expansionPlayersChanged(self._ID)
|
||||||
|
|
||||||
|
@players.deleter
|
||||||
|
def players(self):
|
||||||
|
self._manager.config[self._ID]["players"] = ()
|
||||||
|
self._manager.expansionPlayersChanged(self._ID)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tags(self):
|
||||||
|
""" Players that have access to this expansion. """
|
||||||
|
return self._manager.config[self._ID]["tags"]
|
||||||
|
|
||||||
|
@tags.setter
|
||||||
|
def tags(self, newPlayers):
|
||||||
|
""" Players that have access to this expansion. """
|
||||||
|
self._manager.config[self._ID]["tags"] = tuple(newPlayers)
|
||||||
|
|
||||||
|
@tags.deleter
|
||||||
|
def tags(self):
|
||||||
|
self._manager.config[self._ID]["tags"] = ()
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def step(self, action):
|
||||||
|
"""
|
||||||
|
Call close if an error is thrown
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def reset(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def close(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class serialShocker(Expansion):
|
class serialShocker(Expansion):
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import abc
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
Reference in New Issue
Block a user