Projekt_Sztuczna_Inteligencja/objects/mines/mine_models/mine.py

41 lines
1.0 KiB
Python

# module for abstract classes
from abc import ABC, abstractmethod
# type hints
from typing import Tuple
from objects.mines.disarming.mine_parameters import MineParameters
# 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:
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
# TODO temporarily printing parameters and right wire
print("parameters:", mine_parameters, "\nright wire: " + wire)
return mine_parameters