Projekt_Sztuczna_Inteligencja/objects/mine_models/mine.py

39 lines
964 B
Python
Raw Normal View History

2021-04-14 12:01:20 +02:00
# module for abstract classes
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-04-14 12:01:20 +02:00
# Mine cannot be instantiated
# all abstract methods must be implemented in derived classes
class Mine(ABC):
@abstractmethod
def __init__(self, _type, position: Tuple[int, int], active=True):
self.enum_type = _type
self.position = position
self.wire = None
self.active = active
@abstractmethod
def disarm(self, wire):
if wire == self.wire:
self.active = False
return True
else:
self.active = False
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