2021-04-14 12:01:20 +02:00
|
|
|
# module for abstract classes
|
2021-03-26 15:46:00 +01:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
|
|
# type hints
|
|
|
|
from typing import Tuple
|
|
|
|
|
2021-06-06 22:00:42 +02:00
|
|
|
from disarming.parameters.mine_parameters import MineParameters
|
2021-05-23 20:20:02 +02:00
|
|
|
|
2021-04-14 12:01:20 +02:00
|
|
|
# Mine cannot be instantiated
|
|
|
|
# all abstract methods must be implemented in derived classes
|
2021-03-26 15:46:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Mine(ABC):
|
|
|
|
@abstractmethod
|
2021-05-23 20:20:02 +02:00
|
|
|
def __init__(self, _type, position: Tuple[int, int], active=True):
|
|
|
|
self.enum_type = _type
|
2021-03-26 15:46:00 +01:00
|
|
|
self.position = position
|
2021-05-23 20:20:02 +02:00
|
|
|
self.wire = None
|
2021-03-26 15:46:00 +01:00
|
|
|
self.active = active
|
|
|
|
|
|
|
|
@abstractmethod
|
2021-05-23 20:20:02 +02:00
|
|
|
def disarm(self, wire):
|
|
|
|
if wire == self.wire:
|
|
|
|
self.active = False
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def investigate(self):
|
|
|
|
mine_parameters = MineParameters(mine_type=self.enum_type).jsonifyable_dict()
|
|
|
|
wire = mine_parameters["wire"]
|
|
|
|
del mine_parameters["wire"]
|
|
|
|
self.wire = wire
|
|
|
|
|
|
|
|
return mine_parameters
|